GnuCash c935c2f+
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.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 27 of file test_price_and_wrapping.py.

Member Function Documentation

◆ setUp()

test_price_and_wrapping.PriceSession.setUp (   self)

Definition at line 30 of file test_price_and_wrapping.py.

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

◆ tearDown()

test_price_and_wrapping.PriceSession.tearDown (   self)

Definition at line 61 of file test_price_and_wrapping.py.

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

Field Documentation

◆ book

test_price_and_wrapping.PriceSession.book

Definition at line 32 of file test_price_and_wrapping.py.

◆ price1

test_price_and_wrapping.PriceSession.price1

Definition at line 45 of file test_price_and_wrapping.py.

◆ price2

test_price_and_wrapping.PriceSession.price2

Definition at line 53 of file test_price_and_wrapping.py.

◆ pricedb

test_price_and_wrapping.PriceSession.pricedb

Definition at line 43 of file test_price_and_wrapping.py.

◆ ses

test_price_and_wrapping.PriceSession.ses

Definition at line 31 of file test_price_and_wrapping.py.

◆ table

test_price_and_wrapping.PriceSession.table

Definition at line 33 of file test_price_and_wrapping.py.

◆ test_comm

test_price_and_wrapping.PriceSession.test_comm

Definition at line 37 of file test_price_and_wrapping.py.

◆ usd

test_price_and_wrapping.PriceSession.usd

Definition at line 34 of file test_price_and_wrapping.py.


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