You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_custom.py 1.2KB

1234567891011121314151617181920212223242526272829303132
  1. from django.test import TestCase
  2. from oscar.apps.offer import custom
  3. from tests._site.model_tests_app.models import (
  4. CustomBenefitModel, CustomBenefitWithoutName, CustomConditionModel,
  5. CustomConditionWithoutName)
  6. class TestCustomBenefit(TestCase):
  7. def setUp(self):
  8. self.custom_benefits = [
  9. custom.create_benefit(CustomBenefitModel), custom.create_benefit(CustomBenefitWithoutName)]
  10. def test_name(self):
  11. self.assertEqual(self.custom_benefits[0].name, 'Test benefit')
  12. def test_raises_assert_on_missing_name(self):
  13. with self.assertRaisesMessage(AssertionError, 'Name property is not defined on proxy class.'):
  14. str(self.custom_benefits[1])
  15. class TestCustomCondition(TestCase):
  16. def setUp(self):
  17. self.custom_conditions = [
  18. custom.create_condition(CustomConditionModel), custom.create_condition(CustomConditionWithoutName)]
  19. def test_name(self):
  20. self.assertEqual(self.custom_conditions[0].name, 'Test condition')
  21. def test_raises_assert_on_missing_name(self):
  22. with self.assertRaisesMessage(AssertionError, 'Name property is not defined on proxy class.'):
  23. str(self.custom_conditions[1])