32 def test_session_with_new_file(self):
33 """create Session with new xml file"""
34 from tempfile import TemporaryDirectory
35 from urllib.parse import urlunparse
36 with TemporaryDirectory() as tempdir:
37 uri = urlunparse(("xml", tempdir, "tempfile", "", "", ""))
38 with Session(uri, SessionOpenMode.SESSION_NEW_STORE) as ses:
39 pass
40
41
42 uri = urlunparse(("xml", tempdir, "tempfile2", "", "", ""))
43 with Session() as ses:
44 with self.assertRaises(GnuCashBackendException):
45 ses.begin(uri, mode=SessionOpenMode.SESSION_NORMAL_OPEN)
46
47
48
49 uri = urlunparse(("xml", tempdir, "tempfile2", "", "", ""))
50 with Session() as ses:
51 with self.assertRaises(GnuCashBackendException):
52 ses.begin(uri, is_new=False)
53
54 uri = urlunparse(("xml", tempdir, "tempfile3", "", "", ""))
55 with Session() as ses:
56 ses.begin(uri, mode=SessionOpenMode.SESSION_NEW_STORE)
57
58
59 uri = urlunparse(("xml", tempdir, "tempfile4", "", "", ""))
60 with Session() as ses:
61 ses.begin(uri, is_new=True)
62
63