def testPriceAttribute(self): e = TestMoneyModel() e.price = Money(0, "BGN") e.price.amount = 3 self.assertEqual(e.price, Money(3, "BGN")) e.price.from_string("BGN 5.0") self.assertEqual(e.price, Money(5, "BGN"))
def testAssign(self): ent = TestMoneyModel(name='test', price=Money(100, "USD")) ent.save() self.assertEquals(ent.price, Money(100, "USD")) ent.price = Money(10, "USD") ent.save() self.assertEquals(ent.price, Money(10, "USD")) ent_same = TestMoneyModel.objects.get(pk=ent.id) self.assertEquals(ent_same.price, Money(10, "USD"))
def testProxy(self): e = TestMoneyModel() e.price = Money(0, "BGN") e.price.amount = 3 self.assertEqual(e.price, Money(3, "BGN")) e.price.from_string("BGN 5.0") self.assertEqual(e.price, Money(5, "BGN")) e1 = TestMoneyModel(price=Money(100, "USD")) e2 = TestMoneyModel(price=Money(200, "USD")) self.assertEqual(e1.price, Money(100, "USD")) self.assertEqual(e2.price, Money(200, "USD")) e2.price = Money(300, "USD") self.assertEqual(e1.price, Money(100, "USD")) self.assertEqual(e2.price, Money(300, "USD")) e2.price.from_string("USD 400") self.assertEqual(e1.price, Money(100, "USD")) self.assertEqual(e2.price, Money(400, "USD"))
def testPriceAttributeUpdate(self): e2 = TestMoneyModel(price=Money(200, "JPY")) e2.price = Money(300, "USD") self.assertEqual(e2.price, Money(300, "USD"))