示例#1
0
	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"))
示例#2
0
    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"))
示例#3
0
    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"))
示例#4
0
    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"))
示例#5
0
    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"))
示例#6
0
	def testPriceAttributeUpdate(self):
		e2 = TestMoneyModel(price=Money(200, "JPY"))
		e2.price = Money(300, "USD")
		self.assertEqual(e2.price, Money(300, "USD"))