Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

test_custom.py 1.2KB

12345678910111213141516171819202122232425262728293031
  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, CustomConditionWithoutName)
  5. class TestCustomBenefit(TestCase):
  6. def setUp(self):
  7. self.custom_benefits = [
  8. custom.create_benefit(CustomBenefitModel), custom.create_benefit(CustomBenefitWithoutName)]
  9. def test_name(self):
  10. self.assertEquals(self.custom_benefits[0].name, 'Test benefit')
  11. def test_raises_assert_on_missing_name(self):
  12. with self.assertRaisesMessage(AssertionError, 'Name property is not defined on proxy class.'):
  13. str(self.custom_benefits[1])
  14. class TestCustomCondition(TestCase):
  15. def setUp(self):
  16. self.custom_conditions = [
  17. custom.create_condition(CustomConditionModel), custom.create_condition(CustomConditionWithoutName)]
  18. def test_name(self):
  19. self.assertEquals(self.custom_conditions[0].name, 'Test condition')
  20. def test_raises_assert_on_missing_name(self):
  21. with self.assertRaisesMessage(AssertionError, 'Name property is not defined on proxy class.'):
  22. str(self.custom_conditions[1])