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

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

◆ test_get_latest_price_returns_gnc_numeric()

test_price_and_wrapping.TestGetPriceReturnsGncNumeric.test_get_latest_price_returns_gnc_numeric (   self)

Definition at line 393 of file test_price_and_wrapping.py.

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

◆ 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 404 of file test_price_and_wrapping.py.

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

◆ test_get_nearest_price_returns_gnc_numeric()

test_price_and_wrapping.TestGetPriceReturnsGncNumeric.test_get_nearest_price_returns_gnc_numeric (   self)

Definition at line 399 of file test_price_and_wrapping.py.

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

Field Documentation

◆ test_comm

test_price_and_wrapping.TestGetPriceReturnsGncNumeric.test_comm

Definition at line 407 of file test_price_and_wrapping.py.

◆ usd

test_price_and_wrapping.TestGetPriceReturnsGncNumeric.usd

Definition at line 407 of file test_price_and_wrapping.py.


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