def testValidate(self): form = MoneyForm({"money": "10", "money_currency": "SEK"}) 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, moneyed.SEK)
def testValidate(self): form = MoneyForm({"money":"10", "money_currency":"SEK"}) 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, moneyed.SEK)
def testRender(self): form = MoneyForm() expected = """<tr><th><label for="id_money">Money:</label></th><td><input id="id_money" name="money" type="text" /><select id="id_money_currency" name="money_currency"> <option value="a">a</option> </select></td></tr>""" self.assertEquals(str(form), expected)
def testNonExistantCurrency(self): form = MoneyForm({"money": "10", "money_currency": "_XX!123_"}) self.assertRaises(moneyed.CurrencyDoesNotExist, form.is_valid)
def testNonExistantCurrency(self): form = MoneyForm({"money": "10", "money_currency": "_XX!123_"}) self.assertFalse(form.is_valid())
def testNonExistantCurrency(self): form = MoneyForm({"money":"10", "money_currency":"_XX!123_"}) self.assertFalse(form.is_valid())