Просмотр исходного кода

Fix broken functional tests!

I forgot to modify the test config to account for django-compressor.
master
David Winterbottom 13 лет назад
Родитель
Сommit
80c1b0b1a7
2 измененных файлов: 56 добавлений и 0 удалений
  1. 3
    0
      tests/config.py
  2. 53
    0
      tests/unit/offer/custom_benefit_tests.py

+ 3
- 0
tests/config.py Просмотреть файл

@@ -26,6 +26,7 @@ def configure(nose_args=None):
26 26
                 'django.contrib.sites',
27 27
                 'django.contrib.flatpages',
28 28
                 'sorl.thumbnail',
29
+                'compressor',
29 30
                 ] + OSCAR_CORE_APPS,
30 31
             TEMPLATE_CONTEXT_PROCESSORS=(
31 32
                 "django.contrib.auth.context_processors.auth",
@@ -58,6 +59,8 @@ def configure(nose_args=None):
58 59
             },
59 60
             ROOT_URLCONF='tests._site.urls',
60 61
             LOGIN_REDIRECT_URL='/accounts/',
62
+            STATIC_URL='/static/',
63
+            COMPRESS_ENABLED=False,
61 64
             DEBUG=False,
62 65
             SITE_ID=1,
63 66
             APPEND_SLASH=True,

+ 53
- 0
tests/unit/offer/custom_benefit_tests.py Просмотреть файл

@@ -0,0 +1,53 @@
1
+from decimal import Decimal as D
2
+
3
+from django.test import TestCase
4
+from django.contrib.auth.models import User
5
+from django_dynamic_fixture import G
6
+import mock
7
+
8
+from oscar.apps.offer import custom, models
9
+from oscar.apps.basket.models import Basket
10
+
11
+
12
+class ChangesOwnerName(models.Benefit):
13
+
14
+    class Meta:
15
+        proxy = True
16
+
17
+    def apply(self, basket, condition, offer=None):
18
+        basket.owner.first_name = "Terry"
19
+        basket.owner.save()
20
+        return D('0.00')
21
+
22
+    @property
23
+    def description(self):
24
+        return 'Changes owners name'
25
+
26
+
27
+class NoDescription(models.Benefit):
28
+
29
+    class Meta:
30
+        proxy = True
31
+
32
+    def apply(self, basket, condition, offer=None):
33
+        return D('0.00')
34
+
35
+
36
+class TestACustomBenefit(TestCase):
37
+
38
+    def test_must_implement_a_description_property(self):
39
+        with self.assertRaises(RuntimeError):
40
+            custom.create_benefit(NoDescription)
41
+
42
+
43
+class TestCustomBenefit(TestCase):
44
+
45
+    def setUp(self):
46
+        self.benefit = custom.create_benefit(ChangesOwnerName)
47
+        self.condition = mock.Mock()
48
+        self.basket = Basket()
49
+
50
+    def test_applies_correctly(self):
51
+        self.basket.owner = G(User, first_name="Alan")
52
+        self.benefit.proxy().apply(self.basket, self.condition)
53
+        self.assertEqual("Terry", self.basket.owner.first_name)

Загрузка…
Отмена
Сохранить