GnuCash c935c2f+
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
test_session.TestSession Class Reference
Inheritance diagram for test_session.TestSession:

Public Member Functions

 test_create_empty_session (self)
 
 test_session_deprecated_arguments (self)
 
 test_session_mode (self)
 
 test_session_with_new_file (self)
 
 test_app_utils_get_current_session (self)
 
 test_get_book_from_current_session (self)
 

Data Fields

 ses
 
 ses_instance
 
 book
 

Detailed Description

Definition at line 20 of file test_session.py.

Member Function Documentation

◆ test_app_utils_get_current_session()

test_session.TestSession.test_app_utils_get_current_session (   self)

Definition at line 64 of file test_session.py.

64 def test_app_utils_get_current_session(self):
65 from gnucash import _sw_app_utils
66 self.ses_instance = _sw_app_utils.gnc_get_current_session()
67 self.ses = Session(instance = self.ses_instance)
68 self.assertIsInstance(obj = self.ses, cls = Session)
69

◆ test_create_empty_session()

test_session.TestSession.test_create_empty_session (   self)

Definition at line 21 of file test_session.py.

21 def test_create_empty_session(self):
22 self.ses = Session()
23

◆ test_get_book_from_current_session()

test_session.TestSession.test_get_book_from_current_session (   self)

Definition at line 70 of file test_session.py.

70 def test_get_book_from_current_session(self):
71 from gnucash import _sw_app_utils
72 from gnucash import Book
73 self.ses_instance = _sw_app_utils.gnc_get_current_session()
74 self.ses = Session(instance = self.ses_instance)
75 self.book = self.ses.get_book()
76 self.assertIsInstance(obj = self.book, cls = Book)
77

◆ test_session_deprecated_arguments()

test_session.TestSession.test_session_deprecated_arguments (   self)
use deprecated arguments ignore_lock, is_new, force_new

Definition at line 24 of file test_session.py.

24 def test_session_deprecated_arguments(self):
25 """use deprecated arguments ignore_lock, is_new, force_new"""
26 self.ses = Session(ignore_lock=False, is_new=True, force_new=False)
27

◆ test_session_mode()

test_session.TestSession.test_session_mode (   self)
use mode argument

Definition at line 28 of file test_session.py.

28 def test_session_mode(self):
29 """use mode argument"""
30 self.ses = Session(mode=SessionOpenMode.SESSION_NORMAL_OPEN)
31

◆ test_session_with_new_file()

test_session.TestSession.test_session_with_new_file (   self)
create Session with new xml file

Definition at line 32 of file test_session.py.

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 # try to open nonexistent file without NEW mode - should raise Exception
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 # try to open nonexistent file without NEW mode - should raise Exception
48 # use deprecated arg is_new
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 # test using deprecated args
59 uri = urlunparse(("xml", tempdir, "tempfile4", "", "", ""))
60 with Session() as ses:
61 ses.begin(uri, is_new=True)
62
63

Field Documentation

◆ book

test_session.TestSession.book

Definition at line 75 of file test_session.py.

◆ ses

test_session.TestSession.ses

Definition at line 22 of file test_session.py.

◆ ses_instance

test_session.TestSession.ses_instance

Definition at line 66 of file test_session.py.


The documentation for this class was generated from the following file: