def test_price_with_numeric_string_with_dollar_sign(self): # self.assertRaisesMessage(ValidationError,_('Not a valid price. 2 decimals maximum and numbers only is allowed.'),v.price, '1246.78$') with self.assertRaises(ValidationError) as e: v.price('1246.78$') exc = e.exception self.assertEqual(exc.code, 'not_price_formatted')
def test_price_with_object(self): # self.assertRaisesMessage(ValidationError,_('Not a valid price. 2 decimals maximum and numbers only is allowed.'), v.price, object) with self.assertRaises(ValidationError) as e: v.price(object) exc = e.exception self.assertEqual(exc.code, 'not_price_formatted')
def test_price_with_numeric_string_correct_decimals(self): self.assertEquals(None, v.price('1246.78')) self.assertEquals(None, v.price('1245.34')) self.assertEquals(None, v.price('12431'))
def test_price_with_correct_integer(self): self.assertEquals(None, v.price(1246.78)) self.assertEquals(None, v.price(1245.34)) self.assertEquals(None, v.price(12431))
def test_price_with_incorrect_integer(self): # self.assertRaisesMessage(ValidationError,_('Not a valid price. 2 decimals maximum and numbers only is allowed.'),v.price, 12345.78978) with self.assertRaises(ValidationError) as e: v.price(12345.78978) exc = e.exception self.assertEqual(exc.code, 'not_price_formatted')