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

    a = AmountField(null=True)
    b = AmountField()
    c = AmountField()
Exemple #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'))
Exemple #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')))
Exemple #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'))
Exemple #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'))