GnuCash  5.6-150-g038405b370+
Public Member Functions | Data Fields
test_session.TestSession Class Reference
Inheritance diagram for test_session.TestSession:

Public Member Functions

def test_create_empty_session (self)
 
def test_session_deprecated_arguments (self)
 
def test_session_mode (self)
 
def test_session_with_new_file (self)
 
def test_app_utils_get_current_session (self)
 
def 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_session_deprecated_arguments()

def 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()

def 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()

def 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 

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