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