class AmountResource(odin.Resource): class Meta: namespace = "odin.tests" a = AmountField(null=True) b = AmountField() c = AmountField()
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'))
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')))
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'))
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'))