def test_greater_or_equal_condition_check(self): validator = SumCheck() mock_form = Mock() conditions = ['greater than', 'equals'] calculation_total = 11.99 target_total = 12.5 with self.assertRaises(ValidationError) as ite: validator(mock_form, conditions, calculation_total, target_total) self.assertEqual( error_messages['TOTAL_SUM_NOT_GREATER_THAN_OR_EQUALS'] % dict(total=format_playback_value(target_total)), str(ite.exception))
def test_currency_playback(self): validator = SumCheck(currency='EUR') mock_form = Mock() conditions = ['equals'] calculation_total = 10 target_total = 11.5 with self.assertRaises(ValidationError) as ite: validator(mock_form, conditions, calculation_total, target_total) self.assertEqual( error_messages['TOTAL_SUM_NOT_EQUALS'] % dict(total=format_playback_value(target_total, currency='EUR')), str(ite.exception))
def test_less_than_condition_check(self): validator = SumCheck() mock_form = Mock() conditions = ['less than'] calculation_total = 11.99 target_total = 11.5 with self.assertRaises(ValidationError) as ite: validator(mock_form, conditions, calculation_total, target_total) self.assertEqual( error_messages['TOTAL_SUM_NOT_LESS_THAN'] % dict(total=format_playback_value(target_total)), str(ite.exception))