GnuCash fec5643+
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
test_price_and_wrapping.PriceSession Class Reference
Inheritance diagram for test_price_and_wrapping.PriceSession:
test_price_and_wrapping.TestGetPriceReturnsGncNumeric test_price_and_wrapping.TestGncPriceWrapping test_price_and_wrapping.TestSetSourceStringGuard test_price_and_wrapping.TestSwigTypemapCompat

Public Member Functions

 setUp (self)
 
 tearDown (self)
 

Data Fields

 ses
 
 book
 
 table
 
 usd
 
 test_comm
 
 pricedb
 
 price1
 
 price2
 

Detailed Description

Base class that creates a session with a custom commodity and prices.

Definition at line 28 of file test_price_and_wrapping.py.

Member Function Documentation

◆ setUp()

test_price_and_wrapping.PriceSession.setUp (   self)

Definition at line 31 of file test_price_and_wrapping.py.

31 def setUp(self):
32 self.ses = Session()
33 self.book = self.ses.get_book()
34 self.table = self.book.get_table()
35 self.usd = self.table.lookup("CURRENCY", "USD")
36
37 # Create a custom commodity
38 self.test_comm = GncCommodity(
39 self.book, "Test Stock", "NASDAQ", "TSTK", "TSTK", 10000
40 )
41 self.table.insert(self.test_comm)
42
43 # Add prices to the price DB
44 self.pricedb = self.book.get_price_db()
45
46 self.price1 = GncPrice(self.book)
47 self.price1.set_commodity(self.test_comm)
48 self.price1.set_currency(self.usd)
49 self.price1.set_time64(datetime(2025, 1, 15))
50 self.price1.set_value(GncNumeric(4200, 100)) # 42.00
51 self.price1.set_typestr("last")
52 self.pricedb.add_price(self.price1)
53
54 self.price2 = GncPrice(self.book)
55 self.price2.set_commodity(self.test_comm)
56 self.price2.set_currency(self.usd)
57 self.price2.set_time64(datetime(2025, 6, 15))
58 self.price2.set_value(GncNumeric(4500, 100)) # 45.00
59 self.price2.set_typestr("last")
60 self.pricedb.add_price(self.price2)
61
The primary numeric class for representing amounts and values.

◆ tearDown()

test_price_and_wrapping.PriceSession.tearDown (   self)

Definition at line 62 of file test_price_and_wrapping.py.

62 def tearDown(self):
63 self.ses.end()
64
65
66# ---------------------------------------------------------------------------
67# Test: GncPrice and GncPriceDB wrapping
68# ---------------------------------------------------------------------------

Field Documentation

◆ book

test_price_and_wrapping.PriceSession.book

Definition at line 33 of file test_price_and_wrapping.py.

◆ price1

test_price_and_wrapping.PriceSession.price1

Definition at line 46 of file test_price_and_wrapping.py.

◆ price2

test_price_and_wrapping.PriceSession.price2

Definition at line 54 of file test_price_and_wrapping.py.

◆ pricedb

test_price_and_wrapping.PriceSession.pricedb

Definition at line 44 of file test_price_and_wrapping.py.

◆ ses

test_price_and_wrapping.PriceSession.ses

Definition at line 32 of file test_price_and_wrapping.py.

◆ table

test_price_and_wrapping.PriceSession.table

Definition at line 34 of file test_price_and_wrapping.py.

◆ test_comm

test_price_and_wrapping.PriceSession.test_comm

Definition at line 38 of file test_price_and_wrapping.py.

◆ usd

test_price_and_wrapping.PriceSession.usd

Definition at line 35 of file test_price_and_wrapping.py.


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