def test_assign(self): price = Money(100, "USD") ent = SimpleMoneyModel(name='test', price=price.amount, price_currency=price.currency) ent.save() self.assertEqual(ent.price, Money(100, "USD")) ent.price = Money(10, "USD") ent.save() self.assertEqual(ent.price, Money(10, "USD")) ent_same = SimpleMoneyModel.objects.get(pk=ent.id) self.assertEqual(ent_same.price, Money(10, "USD"))
def test_assign(self): price = Money(100, "USD") ent = SimpleMoneyModel(name='test', price=price.amount, price_currency=price.currency) 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 = SimpleMoneyModel.objects.get(pk=ent.id) self.assertEquals(ent_same.price, Money(10, "USD"))
def test_non_null(self): instance = SimpleMoneyModel() with pytest.raises(IntegrityError): instance.save()