def test_units1(self): inv = Inventory() self.assertEqual(inv.units(), Inventory.from_string('')) inv = Inventory.from_string('40.50 JPY, 40.51 USD {1.01 CAD}, 40.52 CAD') self.assertEqual(inv.units(), Inventory.from_string('40.50 JPY, 40.51 USD, 40.52 CAD')) # Check that the same units coalesce. inv = Inventory.from_string('2 HOOL {400 USD}, 3 HOOL {410 USD}') self.assertEqual(inv.units(), Inventory.from_string('5 HOOL')) inv = Inventory.from_string('2 HOOL {400 USD}, -3 HOOL {410 USD}') self.assertEqual(inv.units(), Inventory.from_string('-1 HOOL'))
def test_units(self): inv = Inventory(self.POSITIONS_ALL_KINDS + [position.from_string('50.00 CAD')]) inv_cost = inv.units() self.assertEqual(Inventory.from_string('121.50 USD, 50.00 CAD'), inv_cost)