GnuCash 7574033+
Loading...
Searching...
No Matches
test_price_and_wrapping.TestGetPriceReturnsGncNumeric Class Reference
Inheritance diagram for test_price_and_wrapping.TestGetPriceReturnsGncNumeric:
test_price_and_wrapping.PriceSession

Public Member Functions

 test_get_latest_price_returns_gnc_numeric (self)
 test_get_nearest_price_returns_gnc_numeric (self)
 test_get_nearest_before_price_returns_gnc_numeric (self)
 test_get_latest_price_arithmetic (self)
Public Member Functions inherited from test_price_and_wrapping.PriceSession
 setUp (self)
 tearDown (self)

Additional Inherited Members

Data Fields inherited from test_price_and_wrapping.PriceSession
 ses = Session()
 book = self.ses.get_book()
 table = self.book.get_table()
 usd = self.table.lookup("CURRENCY", "USD")
 test_comm
 pricedb = self.book.get_price_db()
 price1 = GncPrice(self.book)
 price2 = GncPrice(self.book)

Detailed Description

Verify that get_latest_price, get_nearest_price, and
get_nearest_before_price return GncNumeric instead of raw
_gnc_numeric.

Definition at line 389 of file test_price_and_wrapping.py.

Member Function Documentation

◆ test_get_latest_price_arithmetic()

test_price_and_wrapping.TestGetPriceReturnsGncNumeric.test_get_latest_price_arithmetic ( self)
Verify the returned GncNumeric supports arithmetic.

Definition at line 411 of file test_price_and_wrapping.py.

411 def test_get_latest_price_arithmetic(self):
412 """Verify the returned GncNumeric supports arithmetic."""
413 val = self.pricedb.get_latest_price(self.test_comm, self.usd)
414 doubled = val + val
415 self.assertIsInstance(doubled, GncNumeric)
416 self.assertAlmostEqual(float(doubled), float(val) * 2, places=6)
417
418
419# ---------------------------------------------------------------------------
420# Test: ClassFromFunctions double-wrap protection
421# ---------------------------------------------------------------------------

◆ test_get_latest_price_returns_gnc_numeric()

test_price_and_wrapping.TestGetPriceReturnsGncNumeric.test_get_latest_price_returns_gnc_numeric ( self)

Definition at line 394 of file test_price_and_wrapping.py.

394 def test_get_latest_price_returns_gnc_numeric(self):
395 val = self.pricedb.get_latest_price(self.test_comm, self.usd)
396 self.assertIsInstance(val, GncNumeric)
397 self.assertNotEqual(float(val), 0.0,
398 "Expected a non-zero price for TSTK/USD")
399

◆ test_get_nearest_before_price_returns_gnc_numeric()

test_price_and_wrapping.TestGetPriceReturnsGncNumeric.test_get_nearest_before_price_returns_gnc_numeric ( self)

Definition at line 405 of file test_price_and_wrapping.py.

405 def test_get_nearest_before_price_returns_gnc_numeric(self):
406 date = datetime(2025, 7, 1)
407 val = self.pricedb.get_nearest_before_price(
408 self.test_comm, self.usd, date)
409 self.assertIsInstance(val, GncNumeric)
410

◆ test_get_nearest_price_returns_gnc_numeric()

test_price_and_wrapping.TestGetPriceReturnsGncNumeric.test_get_nearest_price_returns_gnc_numeric ( self)

Definition at line 400 of file test_price_and_wrapping.py.

400 def test_get_nearest_price_returns_gnc_numeric(self):
401 date = datetime(2025, 1, 20)
402 val = self.pricedb.get_nearest_price(self.test_comm, self.usd, date)
403 self.assertIsInstance(val, GncNumeric)
404

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