GnuCash fec5643+
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
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)
 

Data Fields

 test_comm
 
 usd
 
- Data Fields inherited from test_price_and_wrapping.PriceSession
 ses
 
 book
 
 table
 
 usd
 
 test_comm
 
 pricedb
 
 price1
 
 price2
 

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

Field Documentation

◆ test_comm

test_price_and_wrapping.TestGetPriceReturnsGncNumeric.test_comm

Definition at line 408 of file test_price_and_wrapping.py.

◆ usd

test_price_and_wrapping.TestGetPriceReturnsGncNumeric.usd

Definition at line 408 of file test_price_and_wrapping.py.


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