class AmountResource(odin.Resource):
    class Meta:
        namespace = "odin.tests"

    a = AmountField(null=True)
    b = AmountField()
    c = AmountField()
示例#2
0
 def test_money_field_1(self):
     f = AmountField(allowed_currencies=('NZD', 'AUD'))
     self.assertEqual(d, f.clean((44, 'NZD')))
     self.assertRaises(ValidationError, f.clean, (22, 'USD'))
示例#3
0
 def test_money_field(self):
     f = AmountField()
     self.assertRaises(ValidationError, f.clean, None)
     self.assertRaises(ValidationError, f.clean, 'a')
     self.assertEqual(a, f.clean(11))
     self.assertEqual(b, f.clean((22, 'AUD')))
示例#4
0
 def test_money_field_1(self):
     f = AmountField(allowed_currencies=('NZD', 'AUD'))
     assert d == f.clean((44, 'NZD'))
     pytest.raises(ValidationError, f.clean, (22, 'USD'))
示例#5
0
 def test_money_field(self):
     f = AmountField()
     pytest.raises(ValidationError, f.clean, None)
     pytest.raises(ValidationError, f.clean, 'a')
     assert a == f.clean(11)
     assert b == f.clean((22, 'AUD'))