Beispiel #1
0
    def test_validators(self):
        SEK_currency = CURRENCIES['SEK']
        form = MoneyForm({"money":"xxx", "money_currency":SEK_currency.code})
        self.assertFalse(form.is_valid())

        form = MoneyForm({"money":"1.001", "money_currency":SEK_currency.code})
        self.assertFalse(form.is_valid())
Beispiel #2
0
 def test_validate(self):
     SEK_currency = CURRENCIES['SEK']
     form = MoneyForm({"money":"10", "money_currency":SEK_currency.code})
     self.assertTrue(form.is_valid())
     result = form.cleaned_data['money']
     self.assertTrue(isinstance(result, Money))
     self.assertEquals(result.amount, Decimal("10"))
     self.assertEquals(result.currency, SEK_currency)
Beispiel #3
0
 def test_non_existant_currency(self):
     form = MoneyForm({"money":"10", "money_currency":"_XX!123_"})
     self.assertFalse(form.is_valid())
     self.assertEquals({'money': [u"Unrecognized currency type '_XX!123_'."]}, form.errors)