def test_quantities(self): pos = Position(Lot("USD", None, None), D('10')) self.assertEqual(A('10 USD'), pos.get_units()) self.assertEqual(A('10 USD'), pos.get_cost()) self.assertEqual(A('10 USD'), pos.get_weight()) self.assertEqual(A('16 AUD'), pos.get_weight(A('1.6 AUD'))) pos = Position(Lot("USD", A('1.5 AUD'), None), D('10')) self.assertEqual(A('10 USD'), pos.get_units()) self.assertEqual(A('15 AUD'), pos.get_cost()) self.assertEqual(A('15 AUD'), pos.get_weight()) self.assertEqual(A('15 AUD'), pos.get_weight(A('1.6 AUD'))) cost_pos = pos.cost() self.assertEqual(A('15 AUD'), cost_pos.get_units()) self.assertEqual(A('15 AUD'), cost_pos.get_cost()) self.assertEqual(A('15 AUD'), cost_pos.get_weight()) with self.assertRaises(AssertionError): self.assertEqual(A('15 AUD'), cost_pos.get_weight(A('1.6 AUD')))
def test_add(self): pos = Position(Lot("USD", A('10 AUD'), None), D('28372')) pos.add(D('337')) self.assertEqual(A('28709 USD'), pos.get_units()) self.assertEqual(A('287090 AUD'), pos.get_cost())