소스 검색

Moved tests into separate package.

Also split them into unit and functional tests.
master
David Winterbottom 13 년 전
부모
커밋
feb8c9a327
49개의 변경된 파일225개의 추가작업 그리고 344개의 파일을 삭제
  1. 5
    4
      create_migration.py
  2. 0
    4
      oscar/apps/partner/tests/__init__.py
  3. 0
    2
      oscar/apps/payment/tests/__init__.py
  4. 0
    61
      oscar/apps/promotions/tests.py
  5. 0
    42
      oscar/apps/search/tests.py
  6. 4
    2
      oscar/defaults.py
  7. 1
    1
      oscar/test/helpers.py
  8. 0
    38
      oscar/tests.py
  9. 1
    1
      pre-commit.sh
  10. 6
    4
      runtests.py
  11. 53
    53
      tests/config.py
  12. 0
    0
      tests/functional/__init__.py
  13. 5
    52
      tests/functional/basket_tests.py
  14. 21
    0
      tests/functional/catalogue_tests.py
  15. 0
    0
      tests/functional/checkout_tests.py
  16. 2
    19
      tests/functional/customer_tests.py
  17. 0
    0
      tests/functional/dashboard/__init__.py
  18. 0
    0
      tests/functional/dashboard/catalogue_tests.py
  19. 0
    0
      tests/functional/dashboard/offer_tests.py
  20. 0
    0
      tests/functional/dashboard/order_tests.py
  21. 0
    0
      tests/functional/dashboard/page_tests.py
  22. 0
    0
      tests/functional/dashboard/promotion_tests.py
  23. 0
    0
      tests/functional/dashboard/range_tests.py
  24. 0
    0
      tests/functional/dashboard/reports_tests.py
  25. 0
    0
      tests/functional/dashboard/review_tests.py
  26. 0
    0
      tests/functional/dashboard/user_tests.py
  27. 0
    10
      tests/functional/dashboard_tests.py
  28. 0
    0
      tests/unit/__init__.py
  29. 4
    6
      tests/unit/address_tests.py
  30. 54
    0
      tests/unit/basket_tests.py
  31. 4
    21
      tests/unit/catalogue_tests.py
  32. 0
    0
      tests/unit/core_tests.py
  33. 19
    0
      tests/unit/customer_tests.py
  34. 0
    0
      tests/unit/logging_tests.py
  35. 0
    0
      tests/unit/offer_tests.py
  36. 1
    2
      tests/unit/order_tests.py
  37. 0
    0
      tests/unit/partner/__init__.py
  38. 0
    0
      tests/unit/partner/fixtures/books-small-semicolon.csv
  39. 0
    0
      tests/unit/partner/fixtures/books-small.csv
  40. 0
    0
      tests/unit/partner/import_tests.py
  41. 0
    0
      tests/unit/partner/model_tests.py
  42. 0
    0
      tests/unit/partner/stock_tests.py
  43. 0
    0
      tests/unit/partner/wrapper_tests.py
  44. 0
    0
      tests/unit/payment_tests.py
  45. 11
    0
      tests/unit/promotion_tests.py
  46. 5
    11
      tests/unit/review_tests.py
  47. 19
    0
      tests/unit/settings_tests.py
  48. 10
    11
      tests/unit/shipping_tests.py
  49. 0
    0
      tests/unit/voucher_tests.py

+ 5
- 4
create_migration.py 파일 보기

@@ -1,9 +1,11 @@
1 1
 #!/usr/bin/env python
2
-import sys
3
-import os
2
+"""
3
+Convenience script to create migrations
4
+"""
4 5
 from optparse import OptionParser
5 6
 
6
-import tests.config
7
+from tests.config import configure
8
+configure()
7 9
 
8 10
 
9 11
 def create_migration(app_label, **kwargs):
@@ -20,4 +22,3 @@ if __name__ == '__main__':
20 22
                       action='store_true', default=False)
21 23
     (options, args) = parser.parse_args()
22 24
     create_migration(args[0], initial=options.initial, auto=options.auto)
23
-

+ 0
- 4
oscar/apps/partner/tests/__init__.py 파일 보기

@@ -1,4 +0,0 @@
1
-from oscar.apps.partner.tests.models import *
2
-from oscar.apps.partner.tests.imports import *
3
-from oscar.apps.partner.tests.checkout import *
4
-from oscar.apps.partner.tests.wrappers import *

+ 0
- 2
oscar/apps/payment/tests/__init__.py 파일 보기

@@ -1,2 +0,0 @@
1
-from oscar.apps.payment.tests.main import *
2
-

+ 0
- 61
oscar/apps/promotions/tests.py 파일 보기

@@ -1,61 +0,0 @@
1
-import httplib
2
-
3
-from django.test import TestCase
4
-from django.core.exceptions import ValidationError
5
-from django.core.urlresolvers import resolve
6
-from django.test import Client
7
-
8
-from oscar.apps.promotions.models import * 
9
-
10
-
11
-class PromotionTest(TestCase):
12
-
13
-    def test_default_template_name(self):
14
-        promotion = Image.objects.create(name="dummy banner")
15
-        self.assertEqual('promotions/image.html', promotion.template_name())
16
-
17
-
18
-
19
-
20
-
21
-#class PagePromotionTest(unittest.TestCase):
22
-#    
23
-#    def setUp(self):
24
-#        self.promotion = Promotion.objects.create(name='Dummy', link_url='http://www.example.com')
25
-#        self.page_prom = PagePromotion.objects.create(promotion=self.promotion,
26
-#                                                      position=RAW_HTML,
27
-#                                                      page_url='/')
28
-#    
29
-#    def test_clicks_start_at_zero(self):
30
-#        self.assertEquals(0, self.page_prom.clicks)
31
-#    
32
-#    def test_click_is_recorded(self):
33
-#        self.page_prom.record_click()
34
-#        self.assertEquals(1, self.page_prom.clicks)
35
-#
36
-#    def test_get_link(self):
37
-#        link = self.page_prom.get_link()
38
-#        match = resolve(link)
39
-#        self.assertEquals('page-click', match.url_name)
40
-#
41
-#
42
-#class KeywordPromotionTest(unittest.TestCase):
43
-#    
44
-#    def setUp(self):
45
-#        self.promotion = Promotion.objects.create(name='Dummy', link_url='http://www.example.com')
46
-#        self.kw_prom = KeywordPromotion.objects.create(promotion=self.promotion,
47
-#                                                       position=RAW_HTML,
48
-#                                                       keyword='cheese')
49
-#    
50
-#    def test_clicks_start_at_zero(self):
51
-#        self.assertEquals(0, self.kw_prom.clicks)
52
-#    
53
-#    def test_click_is_recorded(self):
54
-#        self.kw_prom.record_click()
55
-#        self.assertEquals(1, self.kw_prom.clicks)
56
-#        
57
-#    def test_get_link(self):
58
-#        link = self.kw_prom.get_link()
59
-#        match = resolve(link)
60
-#        self.assertEquals('keyword-click', match.url_name)
61
-        

+ 0
- 42
oscar/apps/search/tests.py 파일 보기

@@ -1,42 +0,0 @@
1
-from django.test import TestCase, Client
2
-from django.core.urlresolvers import reverse
3
-
4
-from django.core import management
5
-from haystack import backend
6
-
7
-
8
-class SuggestViewTest(TestCase):
9
-    fixtures = ['sample-products']
10
-
11
-    def setUp(self):
12
-        #clear out existing index without prompting user and ensure that
13
-        #fixtures are indexed
14
-        self.client = Client()
15
-        sb = backend.SearchBackend()
16
-        sb.clear()
17
-        management.call_command('update_index', verbosity=0) #silenced
18
-
19
-    def test_term_in_fixtures_found(self):
20
-        url = reverse('oscar-search-suggest')
21
-        response = self.client.get(url, {'query_term': 'Pint'})
22
-        self.assertEquals(200, response.status_code)
23
-        self.assertTrue('Pint' in response.content) #ensuring we actually find a result in the response
24
-
25
-class MultiFacetedSearchViewTest(TestCase):
26
-    fixtures = ['sample-products']
27
-
28
-    def setUp(self):
29
-        #clear out existing index without prompting user and ensure that
30
-        #fixtures are indexed
31
-        self.client = Client()
32
-        sb = backend.SearchBackend()
33
-        sb.clear()
34
-        management.call_command('update_index', verbosity=0) #silenced
35
-
36
-    def test_with_query(self):
37
-        url = reverse('oscar-search')
38
-        response = self.client.get(url, {'q': 'Pint'})
39
-        self.assertEquals(200, response.status_code)
40
-        self.assertTrue('value="Pint"' in response.content) #ensuring query field is set
41
-    
42
-        

+ 4
- 2
oscar/defaults.py 파일 보기

@@ -53,5 +53,7 @@ OSCAR_OFFER_BLACKLIST_PRODUCT = None
53 53
 # Max total number of items in basket
54 54
 OSCAR_MAX_BASKET_QUANTITY_THRESHOLD = None
55 55
 
56
-#Cookies
57
-OSCAR_COOKIES_DELETE_ON_LOGOUT = ['oscar_recently_viewed_products', ]
56
+# Cookies
57
+OSCAR_COOKIES_DELETE_ON_LOGOUT = ['oscar_recently_viewed_products', ]
58
+
59
+OSCAR_SETTINGS = dict([(k, v) for k, v in locals().items() if k.startswith('OSCAR_')])

+ 1
- 1
oscar/test/helpers.py 파일 보기

@@ -16,7 +16,7 @@ from oscar.apps.shipping.methods import Free
16 16
 from oscar.apps.offer.models import Range, ConditionalOffer, Condition, Benefit
17 17
 
18 18
 
19
-def create_product(price=None, title="Dummy title", product_class="Dummy item class", 
19
+def create_product(price=None, title="Dummy title", product_class="Dummy item class",
20 20
         partner="Dummy partner", partner_sku=None, upc=None, num_in_stock=10, attributes=None):
21 21
     """
22 22
     Helper method for creating products that are used in tests.

+ 0
- 38
oscar/tests.py 파일 보기

@@ -1,38 +0,0 @@
1
-from django.test import TestCase
2
-
3
-from oscar.apps.address.tests import *
4
-from oscar.apps.basket.tests import *
5
-from oscar.apps.order.tests import *
6
-from oscar.apps.catalogue.tests import *
7
-from oscar.apps.partner.tests import *
8
-from oscar.apps.checkout.tests import *
9
-from oscar.apps.payment.tests import *
10
-from oscar.apps.offer.tests import *
11
-from oscar.apps.shipping.tests import *
12
-from oscar.apps.customer.tests import *
13
-from oscar.apps.promotions.tests import *
14
-from oscar.apps.catalogue.reviews.tests import *
15
-from oscar.apps.voucher.tests import *
16
-from oscar.apps.partner.tests import *
17
-from oscar.apps.dashboard.tests import *
18
-
19
-from oscar.core.tests import *
20
-from oscar.core.logging.tests import *
21
-
22
-import oscar
23
-
24
-
25
-class OscarTests(TestCase):
26
-
27
-    def test_app_list_exists(self):
28
-        core_apps = oscar.OSCAR_CORE_APPS
29
-        self.assertTrue('oscar' in core_apps)
30
-
31
-    def test_app_list_can_be_accessed_through_fn(self):
32
-        core_apps = oscar.get_core_apps()
33
-        self.assertTrue('oscar' in core_apps)
34
-
35
-    def test_app_list_can_be_accessed_with_overrides(self):
36
-        apps = oscar.get_core_apps(overrides=['apps.shipping'])
37
-        self.assertTrue('apps.shipping' in apps)
38
-        self.assertTrue('oscar.apps.shipping' not in apps)

+ 1
- 1
pre-commit.sh 파일 보기

@@ -4,7 +4,7 @@ git stash --keep-index -q
4 4
 
5 5
 source ~/.virtualenvs/oscar/bin/activate
6 6
 
7
-./run_tests.py
7
+./runtests.py
8 8
 TEST_RESULT=$?
9 9
 
10 10
 jshint oscar/static/oscar/js/oscar

+ 6
- 4
runtests.py 파일 보기

@@ -4,17 +4,19 @@ import logging
4 4
 from optparse import OptionParser
5 5
 from coverage import coverage
6 6
 
7
-import tests.config
7
+# This configures the settings
8
+from tests.config import configure
9
+configure()
8 10
 
9
-from django.test.simple import DjangoTestSuiteRunner
11
+from django_nose import NoseTestSuiteRunner
10 12
 
11 13
 logging.disable(logging.CRITICAL)
12 14
 
13 15
 
14 16
 def run_tests(verbosity, *test_args):
15
-    test_runner = DjangoTestSuiteRunner(verbosity=verbosity)
17
+    test_runner = NoseTestSuiteRunner(verbosity=verbosity)
16 18
     if not test_args:
17
-        test_args = ['oscar']
19
+        test_args = ['tests']
18 20
     num_failures = test_runner.run_tests(test_args)
19 21
     if num_failures:
20 22
         sys.exit(num_failures)

+ 53
- 53
tests/config.py 파일 보기

@@ -3,58 +3,58 @@ import os
3 3
 from django.conf import settings, global_settings
4 4
 from oscar import OSCAR_CORE_APPS
5 5
 
6
-if not settings.configured:
7
-    # Extract Oscar's settings
8
-    from oscar.defaults import *
9
-    oscar_settings = dict([(k, v) for k, v in locals().items() if k.startswith('OSCAR_')])
6
+def configure():
7
+    if not settings.configured:
8
+        from oscar.defaults import OSCAR_SETTINGS
10 9
 
11
-    # Helper function to extract absolute path
12
-    location = lambda x: os.path.join(os.path.dirname(os.path.realpath(__file__)), x)
10
+        # Helper function to extract absolute path
11
+        location = lambda x: os.path.join(os.path.dirname(os.path.realpath(__file__)), x)
13 12
 
14
-    settings.configure(
15
-        DATABASES={
16
-            'default': {
17
-                'ENGINE': 'django.db.backends.sqlite3',
18
-                'NAME': ':memory:',
19
-                }
20
-            },
21
-        INSTALLED_APPS=[
22
-            'django.contrib.auth',
23
-            'django.contrib.admin',
24
-            'django.contrib.contenttypes',
25
-            'django.contrib.sessions',
26
-            'django.contrib.sites',
27
-            'django.contrib.flatpages',
28
-            'sorl.thumbnail',
29
-            ] + OSCAR_CORE_APPS,
30
-        TEMPLATE_CONTEXT_PROCESSORS=(
31
-            "django.contrib.auth.context_processors.auth",
32
-            "django.core.context_processors.request",
33
-            "django.core.context_processors.debug",
34
-            "django.core.context_processors.i18n",
35
-            "django.core.context_processors.media",
36
-            "django.core.context_processors.static",
37
-            "django.contrib.messages.context_processors.messages",
38
-            'oscar.apps.search.context_processors.search_form',
39
-            'oscar.apps.promotions.context_processors.promotions',
40
-            'oscar.apps.checkout.context_processors.checkout',
41
-            ),
42
-        TEMPLATE_DIRS=(
43
-            location('templates'),
44
-            ),
45
-        MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES + (
46
-            'oscar.apps.basket.middleware.BasketMiddleware',
47
-            ),
48
-        AUTHENTICATION_BACKENDS=(
49
-            'oscar.apps.customer.auth_backends.Emailbackend',
50
-            'django.contrib.auth.backends.ModelBackend',
51
-            ),
52
-        ROOT_URLCONF='tests.site.urls',
53
-        LOGIN_REDIRECT_URL='/accounts/',
54
-        DEBUG=False,
55
-        SITE_ID=1,
56
-        HAYSTACK_SEARCH_ENGINE='dummy',
57
-        HAYSTACK_SITECONF = 'oscar.search_sites',
58
-        APPEND_SLASH=True,
59
-        **oscar_settings
60
-    )
13
+        settings.configure(
14
+            DATABASES={
15
+                'default': {
16
+                    'ENGINE': 'django.db.backends.sqlite3',
17
+                    'NAME': ':memory:',
18
+                    }
19
+                },
20
+            INSTALLED_APPS=[
21
+                'django.contrib.auth',
22
+                'django.contrib.admin',
23
+                'django.contrib.contenttypes',
24
+                'django.contrib.sessions',
25
+                'django.contrib.sites',
26
+                'django.contrib.flatpages',
27
+                'sorl.thumbnail',
28
+                ] + OSCAR_CORE_APPS,
29
+            TEMPLATE_CONTEXT_PROCESSORS=(
30
+                "django.contrib.auth.context_processors.auth",
31
+                "django.core.context_processors.request",
32
+                "django.core.context_processors.debug",
33
+                "django.core.context_processors.i18n",
34
+                "django.core.context_processors.media",
35
+                "django.core.context_processors.static",
36
+                "django.contrib.messages.context_processors.messages",
37
+                'oscar.apps.search.context_processors.search_form',
38
+                'oscar.apps.promotions.context_processors.promotions',
39
+                'oscar.apps.checkout.context_processors.checkout',
40
+                ),
41
+            TEMPLATE_DIRS=(
42
+                location('templates'),
43
+                ),
44
+            MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES + (
45
+                'oscar.apps.basket.middleware.BasketMiddleware',
46
+                ),
47
+            AUTHENTICATION_BACKENDS=(
48
+                'oscar.apps.customer.auth_backends.Emailbackend',
49
+                'django.contrib.auth.backends.ModelBackend',
50
+                ),
51
+            ROOT_URLCONF='tests.site.urls',
52
+            LOGIN_REDIRECT_URL='/accounts/',
53
+            DEBUG=False,
54
+            SITE_ID=1,
55
+            HAYSTACK_SEARCH_ENGINE='dummy',
56
+            HAYSTACK_SITECONF = 'oscar.search_sites',
57
+            APPEND_SLASH=True,
58
+            NOSE_ARGS=['-s', '-x'],
59
+            **OSCAR_SETTINGS
60
+        )

+ 0
- 0
tests/functional/__init__.py 파일 보기


oscar/apps/basket/tests.py → tests/functional/basket_tests.py 파일 보기

@@ -1,42 +1,13 @@
1 1
 from decimal import Decimal as D
2 2
 import httplib
3
-import datetime
4 3
 
5
-from django.conf import settings
6 4
 from django.contrib.auth.models import User
7
-from django.core.urlresolvers import reverse
5
+from django.conf import settings
8 6
 from django.test import TestCase, Client
9
-from django.http import HttpResponse
7
+from django.core.urlresolvers import reverse
10 8
 
11
-from oscar.apps.basket.models import Basket, Line
12 9
 from oscar.test.helpers import create_product
13
-from oscar.apps.basket.reports import (
14
-    OpenBasketReportGenerator, SubmittedBasketReportGenerator)
15
-
16
-
17
-class BasketModelTest(TestCase):
18
-
19
-    def setUp(self):
20
-        self.basket = Basket.objects.create()
21
-        self.dummy_product = create_product()
22
-
23
-    def test_empty_baskets_have_zero_lines(self):
24
-        self.assertTrue(Basket().num_lines == 0)
25
-
26
-    def test_new_baskets_are_empty(self):
27
-        self.assertTrue(Basket().is_empty)
28
-
29
-    def test_basket_have_with_one_line(self):
30
-        Line.objects.create(basket=self.basket, product=self.dummy_product)
31
-        self.assertTrue(self.basket.num_lines == 1)
32
-
33
-    def test_add_product_creates_line(self):
34
-        self.basket.add_product(self.dummy_product)
35
-        self.assertTrue(self.basket.num_lines == 1)
36
-
37
-    def test_adding_multiproduct_line_returns_correct_number_of_items(self):
38
-        self.basket.add_product(self.dummy_product, 10)
39
-        self.assertEqual(self.basket.num_items, 10)
10
+from oscar.apps.basket.models import Basket
40 11
 
41 12
 
42 13
 class AnonAddToBasketViewTests(TestCase):
@@ -47,6 +18,7 @@ class AnonAddToBasketViewTests(TestCase):
47 18
         post_params = {'product_id': self.product.id,
48 19
                        'action': 'add',
49 20
                        'quantity': 1}
21
+        self.client = Client()
50 22
         self.response = self.client.post(url, post_params)
51 23
 
52 24
     def test_cookie_is_created(self):
@@ -109,28 +81,9 @@ class BasketThresholdTest(TestCase):
109 81
         self.assertTrue('Your basket currently has 2 items.' in
110 82
                         response.cookies['messages'].value)
111 83
 
112
-class BasketReportTests(TestCase):
113
-
114
-    def test_open_report_doesnt_error(self):
115
-        data = {
116
-            'start_date': datetime.date(2012, 5, 1),
117
-            'end_date': datetime.date(2012, 5, 17),
118
-            'formatter': 'CSV'
119
-        }
120
-        generator = OpenBasketReportGenerator(**data)
121
-        generator.generate()
122
-
123
-    def test_submitted_report_doesnt_error(self):
124
-        data = {
125
-            'start_date': datetime.date(2012, 5, 1),
126
-            'end_date': datetime.date(2012, 5, 17),
127
-            'formatter': 'CSV'
128
-        }
129
-        generator = SubmittedBasketReportGenerator(**data)
130
-        generator.generate()
131
-
132 84
 
133 85
 class SavedBasketTests(TestCase):
86
+
134 87
     def test_moving_from_saved_basket(self):
135 88
         user = User.objects.create_user(username='test', password='pass',
136 89
                                         email='test@example.com')

+ 21
- 0
tests/functional/catalogue_tests.py 파일 보기

@@ -0,0 +1,21 @@
1
+import httplib
2
+
3
+from django.test import TestCase
4
+from django.test.client import Client
5
+from django.core.urlresolvers import reverse
6
+
7
+from oscar.test.helpers import create_product
8
+
9
+
10
+class SingleProductViewTest(TestCase):
11
+    
12
+    def setUp(self):
13
+        self.client = Client()
14
+        
15
+    def test_canonical_urls_are_enforced(self):
16
+        p = create_product()
17
+        args = {'product_slug': 'wrong-slug',
18
+                'pk': p.id}
19
+        wrong_url = reverse('catalogue:detail', kwargs=args)
20
+        response = self.client.get(wrong_url)
21
+        self.assertEquals(httplib.MOVED_PERMANENTLY, response.status_code)

oscar/apps/checkout/tests.py → tests/functional/checkout_tests.py 파일 보기


oscar/apps/customer/tests.py → tests/functional/customer_tests.py 파일 보기

@@ -1,12 +1,11 @@
1 1
 import httplib
2 2
 
3 3
 from django.test.client import Client
4
+from django.contrib.auth.models import User
5
+from django.core.urlresolvers import reverse
4 6
 from django.test import TestCase
5 7
 from django.http import HttpRequest
6
-from django.core.urlresolvers import reverse
7
-from django.contrib.auth.models import User
8 8
 
9
-from oscar.apps.customer.models import CommunicationEventType
10 9
 from oscar.apps.customer.history_helpers import get_recently_viewed_product_ids
11 10
 from oscar.test.helpers import create_product, create_order
12 11
 
@@ -28,22 +27,6 @@ class HistoryHelpersTest(TestCase):
28 27
         self.assertTrue(self.product.id in get_recently_viewed_product_ids(request))
29 28
 
30 29
 
31
-class CommunicationTypeTest(TestCase):
32
-    keys = ('body', 'html', 'sms', 'subject')
33
-
34
-    def test_no_templates_returns_empty_string(self):
35
-        et = CommunicationEventType()
36
-        messages = et.get_messages()
37
-        for key in self.keys:
38
-            self.assertEqual('', messages[key])
39
-
40
-    def test_field_template_render(self):
41
-        et = CommunicationEventType(email_subject_template='Hello {{ name }}')
42
-        ctx = {'name': 'world'}
43
-        messages = et.get_messages(ctx)
44
-        self.assertEqual('Hello world', messages['subject'])
45
-
46
-
47 30
 class AnonOrderDetail(TestCase):
48 31
 
49 32
     def setUp(self):

+ 0
- 0
tests/functional/dashboard/__init__.py 파일 보기


oscar/apps/dashboard/catalogue/tests.py → tests/functional/dashboard/catalogue_tests.py 파일 보기


oscar/apps/dashboard/offers/tests.py → tests/functional/dashboard/offer_tests.py 파일 보기


oscar/apps/dashboard/orders/tests.py → tests/functional/dashboard/order_tests.py 파일 보기


oscar/apps/dashboard/pages/tests.py → tests/functional/dashboard/page_tests.py 파일 보기


oscar/apps/dashboard/promotions/tests.py → tests/functional/dashboard/promotion_tests.py 파일 보기


oscar/apps/dashboard/ranges/tests.py → tests/functional/dashboard/range_tests.py 파일 보기


oscar/apps/dashboard/reports/tests.py → tests/functional/dashboard/reports_tests.py 파일 보기


oscar/apps/dashboard/reviews/tests.py → tests/functional/dashboard/review_tests.py 파일 보기


oscar/apps/dashboard/users/tests.py → tests/functional/dashboard/user_tests.py 파일 보기


oscar/apps/dashboard/tests.py → tests/functional/dashboard_tests.py 파일 보기

@@ -2,16 +2,6 @@ from decimal import Decimal as D
2 2
 
3 3
 from django.core.urlresolvers import reverse
4 4
 
5
-from oscar.apps.dashboard.orders.tests import *
6
-from oscar.apps.dashboard.reports.tests import *
7
-from oscar.apps.dashboard.users.tests import *
8
-from oscar.apps.dashboard.promotions.tests import *
9
-from oscar.apps.dashboard.catalogue.tests import *
10
-from oscar.apps.dashboard.pages.tests import *
11
-from oscar.apps.dashboard.offers.tests import *
12
-from oscar.apps.dashboard.ranges.tests import *
13
-from oscar.apps.dashboard.reviews.tests import *
14
-
15 5
 from oscar.apps.dashboard.views import IndexView
16 6
 from oscar.test import ClientTestCase
17 7
 from oscar.test.helpers import create_order

+ 0
- 0
tests/unit/__init__.py 파일 보기


oscar/apps/address/tests.py → tests/unit/address_tests.py 파일 보기

@@ -8,17 +8,16 @@ from oscar.apps.order.models import ShippingAddress
8 8
 
9 9
 
10 10
 class UserAddressTest(TestCase):
11
-    fixtures = ['countries.json']
12 11
     
13 12
     def setUp(self):
14 13
         self.user = User.objects.create(username='dummy_user')
15
-        self.country = Country.objects.get(iso_3166_1_a2='GB')
14
+        self.country = Country(iso_3166_1_a2='GB', name="UNITED KINGDOM")
16 15
     
17 16
     def tearDown(self):
18 17
         self.user.delete()
19 18
     
20 19
     def test_titleless_salutation_is_stripped(self):
21
-        a = UserAddress.objects.create(last_name='Barrington', line1="75 Smith Road", postcode="N4 8TY", 
20
+        a = UserAddress(last_name='Barrington', line1="75 Smith Road", postcode="N4 8TY", 
22 21
                                        country=self.country, user=self.user)
23 22
         self.assertEquals("Barrington", a.salutation())
24 23
     
@@ -67,10 +66,9 @@ class UserAddressTest(TestCase):
67 66
     def test_hashing_with_utf8(self):
68 67
         a = UserAddress(first_name=u"\u0141ukasz Smith", last_name=u'Smith', line1=u"75 Smith Road", postcode=u"n4 8ty", 
69 68
                         country=self.country, user=self.user)
70
-        hash = a.active_address_fields()
69
+        a.active_address_fields()
71 70
         
72 71
     def test_city_is_alias_of_line4(self):
73
-        a = UserAddress.objects.create(last_name='Barrington', line1="75 Smith Road", line4="London", postcode="n4 8ty", 
72
+        a = UserAddress(last_name='Barrington', line1="75 Smith Road", line4="London", postcode="n4 8ty", 
74 73
                                        country=self.country, user=self.user)
75 74
         self.assertEqual('London', a.city)
76
-           

+ 54
- 0
tests/unit/basket_tests.py 파일 보기

@@ -0,0 +1,54 @@
1
+import datetime
2
+
3
+from django.test import TestCase
4
+
5
+from oscar.apps.basket.models import Basket, Line
6
+from oscar.test.helpers import create_product
7
+from oscar.apps.basket.reports import (
8
+    OpenBasketReportGenerator, SubmittedBasketReportGenerator)
9
+
10
+
11
+class BasketModelTest(TestCase):
12
+
13
+    def setUp(self):
14
+        self.basket = Basket.objects.create()
15
+        self.dummy_product = create_product()
16
+
17
+    def test_empty_baskets_have_zero_lines(self):
18
+        self.assertTrue(Basket().num_lines == 0)
19
+
20
+    def test_new_baskets_are_empty(self):
21
+        self.assertTrue(Basket().is_empty)
22
+
23
+    def test_basket_have_with_one_line(self):
24
+        Line.objects.create(basket=self.basket, product=self.dummy_product)
25
+        self.assertTrue(self.basket.num_lines == 1)
26
+
27
+    def test_add_product_creates_line(self):
28
+        self.basket.add_product(self.dummy_product)
29
+        self.assertTrue(self.basket.num_lines == 1)
30
+
31
+    def test_adding_multiproduct_line_returns_correct_number_of_items(self):
32
+        self.basket.add_product(self.dummy_product, 10)
33
+        self.assertEqual(self.basket.num_items, 10)
34
+
35
+
36
+class BasketReportTests(TestCase):
37
+
38
+    def test_open_report_doesnt_error(self):
39
+        data = {
40
+            'start_date': datetime.date(2012, 5, 1),
41
+            'end_date': datetime.date(2012, 5, 17),
42
+            'formatter': 'CSV'
43
+        }
44
+        generator = OpenBasketReportGenerator(**data)
45
+        generator.generate()
46
+
47
+    def test_submitted_report_doesnt_error(self):
48
+        data = {
49
+            'start_date': datetime.date(2012, 5, 1),
50
+            'end_date': datetime.date(2012, 5, 17),
51
+            'formatter': 'CSV'
52
+        }
53
+        generator = SubmittedBasketReportGenerator(**data)
54
+        generator.generate()

oscar/apps/catalogue/tests.py → tests/unit/catalogue_tests.py 파일 보기

@@ -1,7 +1,5 @@
1
-from django.test import TestCase, Client
1
+from django.test import TestCase
2 2
 from django.core.exceptions import ValidationError
3
-from django.core.urlresolvers import reverse
4
-from django.conf import settings
5 3
 
6 4
 from oscar.apps.catalogue.models import Product, ProductClass, Category, \
7 5
         ProductAttribute
@@ -90,11 +88,11 @@ class VariantProductTests(ProductTests):
90 88
         self.parent = Product.objects.create(title="Parent product", product_class=self.product_class)
91 89
     
92 90
     def test_variant_products_dont_need_titles(self):
93
-        p = Product.objects.create(parent=self.parent, product_class=self.product_class)
91
+        Product.objects.create(parent=self.parent, product_class=self.product_class)
94 92
         
95 93
     def test_variant_products_dont_need_a_product_class(self):
96
-        p = Product.objects.create(parent=self.parent)
97
-        
94
+        Product.objects.create(parent=self.parent)
95
+       
98 96
     def test_variant_products_inherit_parent_titles(self):
99 97
         p = Product.objects.create(parent=self.parent, product_class=self.product_class)
100 98
         self.assertEquals("Parent product", p.get_title())
@@ -102,18 +100,3 @@ class VariantProductTests(ProductTests):
102 100
     def test_variant_products_inherit_product_class(self):
103 101
         p = Product.objects.create(parent=self.parent)
104 102
         self.assertEquals("Clothing", p.get_product_class().name)
105
-
106
-
107
-class SingleProductViewTest(TestCase):
108
-    fixtures = ['sample-products']
109
-    
110
-    def setUp(self):
111
-        self.client = Client()
112
-        
113
-    def test_canonical_urls_are_enforced(self):
114
-        p = Product.objects.get(id=1)
115
-        args = {'product_slug': 'wrong-slug',
116
-                'pk': p.id}
117
-        wrong_url = reverse('catalogue:detail', kwargs=args)
118
-        response = self.client.get(wrong_url)
119
-        self.assertEquals(301, response.status_code)

oscar/core/tests.py → tests/unit/core_tests.py 파일 보기


+ 19
- 0
tests/unit/customer_tests.py 파일 보기

@@ -0,0 +1,19 @@
1
+from django.test import TestCase
2
+
3
+from oscar.apps.customer.models import CommunicationEventType
4
+
5
+
6
+class CommunicationTypeTest(TestCase):
7
+    keys = ('body', 'html', 'sms', 'subject')
8
+
9
+    def test_no_templates_returns_empty_string(self):
10
+        et = CommunicationEventType()
11
+        messages = et.get_messages()
12
+        for key in self.keys:
13
+            self.assertEqual('', messages[key])
14
+
15
+    def test_field_template_render(self):
16
+        et = CommunicationEventType(email_subject_template='Hello {{ name }}')
17
+        ctx = {'name': 'world'}
18
+        messages = et.get_messages(ctx)
19
+        self.assertEqual('Hello world', messages['subject'])

oscar/core/logging/tests.py → tests/unit/logging_tests.py 파일 보기


oscar/apps/offer/tests.py → tests/unit/offer_tests.py 파일 보기


oscar/apps/order/tests.py → tests/unit/order_tests.py 파일 보기

@@ -10,12 +10,11 @@ from oscar.apps.address.models import Country
10 10
 from oscar.apps.basket.models import Basket
11 11
 from oscar.apps.order.models import ShippingAddress, Order, Line, \
12 12
         ShippingEvent, ShippingEventType, ShippingEventQuantity, OrderNote, \
13
-        ShippingEventType, OrderDiscount
13
+        OrderDiscount
14 14
 from oscar.apps.order.exceptions import (InvalidOrderStatus, InvalidLineStatus,
15 15
                                          InvalidShippingEvent)
16 16
 from oscar.test.helpers import create_order, create_product, create_offer
17 17
 from oscar.apps.order.utils import OrderCreator
18
-from oscar.apps.shipping.methods import Free
19 18
 from oscar.apps.order.processing import EventHandler
20 19
 from oscar.test import patch_settings
21 20
 

+ 0
- 0
tests/unit/partner/__init__.py 파일 보기


oscar/apps/partner/tests/fixtures/books-small-semicolon.csv → tests/unit/partner/fixtures/books-small-semicolon.csv 파일 보기


oscar/apps/partner/tests/fixtures/books-small.csv → tests/unit/partner/fixtures/books-small.csv 파일 보기


oscar/apps/partner/tests/imports.py → tests/unit/partner/import_tests.py 파일 보기


oscar/apps/partner/tests/models.py → tests/unit/partner/model_tests.py 파일 보기


oscar/apps/partner/tests/checkout.py → tests/unit/partner/stock_tests.py 파일 보기


oscar/apps/partner/tests/wrappers.py → tests/unit/partner/wrapper_tests.py 파일 보기


oscar/apps/payment/tests/main.py → tests/unit/payment_tests.py 파일 보기


+ 11
- 0
tests/unit/promotion_tests.py 파일 보기

@@ -0,0 +1,11 @@
1
+from django.test import TestCase
2
+
3
+from oscar.apps.promotions import models
4
+
5
+
6
+class PromotionTest(TestCase):
7
+
8
+    def test_default_template_name(self):
9
+        promotion = models.Image.objects.create(name="dummy banner")
10
+        self.assertEqual('promotions/image.html', promotion.template_name())
11
+

oscar/apps/catalogue/reviews/tests.py → tests/unit/review_tests.py 파일 보기

@@ -6,16 +6,13 @@ from django.core.exceptions import ValidationError
6 6
 from django.contrib.auth.models import User, AnonymousUser
7 7
 from django.db import IntegrityError
8 8
 from django.core.urlresolvers import reverse
9
-from django.utils import unittest
10 9
 
11 10
 from oscar.apps.catalogue.reviews.models import ProductReview, Vote
12 11
 from oscar.test.helpers import create_product
13 12
 
14 13
 
15
-class ProductReviewTests(unittest.TestCase):
16
-    u"""
17
-    Basic setup
18
-    """
14
+class ProductReviewTests(TestCase):
15
+
19 16
     def setUp(self):
20 17
         username = str(randint(0, maxint))
21 18
         self.user = User.objects.create_user(username, '%s@users.com'%username, '%spass123'%username)
@@ -36,9 +33,6 @@ class ProductReviewTests(unittest.TestCase):
36 33
 
37 34
 
38 35
 class TopLevelProductReviewVoteTests(ProductReviewTests):
39
-    """
40
-    Basic tests for Vote model
41
-    """
42 36
 
43 37
     def test_try_vote_without_login(self):
44 38
         self.assertRaises(ValueError, Vote.objects.create, review=self.review, delta=-1, user=self.anon_user)
@@ -50,9 +44,7 @@ class TopLevelProductReviewVoteTests(ProductReviewTests):
50 44
 
51 45
 
52 46
 class SingleProductReviewViewTest(ProductReviewTests, TestCase):
53
-    u"""
54
-    Tests for each product review 
55
-    """
47
+
56 48
     def setUp(self):
57 49
         self.client = Client()
58 50
         super(SingleProductReviewViewTest, self).setUp()
@@ -73,9 +65,11 @@ class SingleProductReviewViewTest(ProductReviewTests, TestCase):
73 65
         self.client.login(username='testuser', password='secret')
74 66
         response = self.client.get(url)
75 67
         self.assertEquals(200, response.status_code)
68
+
76 69
         # check necessary review fields for logged in user
77 70
         self.assertContains(response, 'title')
78 71
         self.assertContains(response, 'score')
72
+
79 73
         # check additional fields for anonymous user
80 74
         self.client.login(username=None)
81 75
         response = self.client.get(url)

+ 19
- 0
tests/unit/settings_tests.py 파일 보기

@@ -0,0 +1,19 @@
1
+from django.test import TestCase
2
+
3
+import oscar
4
+
5
+
6
+class OscarTests(TestCase):
7
+
8
+    def test_app_list_exists(self):
9
+        core_apps = oscar.OSCAR_CORE_APPS
10
+        self.assertTrue('oscar' in core_apps)
11
+
12
+    def test_app_list_can_be_accessed_through_fn(self):
13
+        core_apps = oscar.get_core_apps()
14
+        self.assertTrue('oscar' in core_apps)
15
+
16
+    def test_app_list_can_be_accessed_with_overrides(self):
17
+        apps = oscar.get_core_apps(overrides=['apps.shipping'])
18
+        self.assertTrue('apps.shipping' in apps)
19
+        self.assertTrue('oscar.apps.shipping' not in apps)

oscar/apps/shipping/tests.py → tests/unit/shipping_tests.py 파일 보기

@@ -1,11 +1,10 @@
1 1
 from decimal import Decimal as D
2 2
 
3
-from django.utils import unittest
4
-from django.test.client import Client
3
+from django.test import TestCase
5 4
 from django.contrib.auth.models import User
6 5
 
7 6
 from oscar.apps.shipping.methods import Free, FixedPrice
8
-from oscar.apps.shipping.models import OrderAndItemCharges, WeightBand, WeightBased
7
+from oscar.apps.shipping.models import OrderAndItemCharges, WeightBased
9 8
 from oscar.apps.shipping.repository import Repository
10 9
 from oscar.apps.shipping import Scales
11 10
 from oscar.apps.basket.models import Basket
@@ -13,7 +12,7 @@ from oscar.test.helpers import create_product
13 12
 from oscar.test.decorators import dataProvider
14 13
 
15 14
 
16
-class FreeTest(unittest.TestCase):
15
+class FreeTest(TestCase):
17 16
 
18 17
     def setUp(self):
19 18
         self.method = Free()
@@ -32,7 +31,7 @@ class FreeTest(unittest.TestCase):
32 31
         self.assertEquals(D('0.00'), self.method.basket_charge_excl_tax())
33 32
         
34 33
         
35
-class FixedPriceTest(unittest.TestCase):        
34
+class FixedPriceTest(TestCase):        
36 35
     
37 36
     def test_fixed_price_shipping_charges_for_empty_basket(self):
38 37
         method = FixedPrice(D('10.00'), D('10.00'))
@@ -60,7 +59,7 @@ class FixedPriceTest(unittest.TestCase):
60 59
         self.assertEquals(D(value), method.basket_charge_excl_tax())
61 60
         
62 61
         
63
-class OrderAndItemChargesTests(unittest.TestCase):
62
+class OrderAndItemChargesTests(TestCase):
64 63
     
65 64
     def setUp(self):
66 65
         self.method = OrderAndItemCharges(price_per_order=D('5.00'), price_per_item=D('1.00'))
@@ -81,7 +80,7 @@ class OrderAndItemChargesTests(unittest.TestCase):
81 80
         self.assertEquals(D('5.00') + 7*D('1.00'), self.method.basket_charge_incl_tax())
82 81
 
83 82
 
84
-class ZeroFreeThresholdTest(unittest.TestCase):
83
+class ZeroFreeThresholdTest(TestCase):
85 84
     
86 85
     def setUp(self):
87 86
         self.method = OrderAndItemCharges(price_per_order=D('10.00'), free_shipping_threshold=D('0.00'))
@@ -97,7 +96,7 @@ class ZeroFreeThresholdTest(unittest.TestCase):
97 96
         self.assertEquals(D('0.00'), self.method.basket_charge_incl_tax())
98 97
 
99 98
 
100
-class NonZeroFreeThresholdTest(unittest.TestCase):
99
+class NonZeroFreeThresholdTest(TestCase):
101 100
     
102 101
     def setUp(self):
103 102
         self.method = OrderAndItemCharges(price_per_order=D('10.00'), free_shipping_threshold=D('20.00'))
@@ -120,7 +119,7 @@ class NonZeroFreeThresholdTest(unittest.TestCase):
120 119
         self.assertEquals(D('0.00'), self.method.basket_charge_incl_tax())
121 120
 
122 121
 
123
-class ScalesTests(unittest.TestCase):
122
+class ScalesTests(TestCase):
124 123
 
125 124
     def test_simple_weight_calculation(self):
126 125
         scales = Scales(attribute_code='weight')
@@ -153,7 +152,7 @@ class ScalesTests(unittest.TestCase):
153 152
         self.assertEquals(1+2, scales.weigh_basket(basket))
154 153
 
155 154
 
156
-class WeightBasedMethodTests(unittest.TestCase):
155
+class WeightBasedMethodTests(TestCase):
157 156
 
158 157
     def setUp(self):
159 158
         self.standard = WeightBased.objects.create(name='Standard')
@@ -217,7 +216,7 @@ class WeightBasedMethodTests(unittest.TestCase):
217 216
         self.assertEqual(D('0.00'), charge)
218 217
 
219 218
 
220
-class RepositoryTests(unittest.TestCase):
219
+class RepositoryTests(TestCase):
221 220
 
222 221
     def setUp(self):
223 222
         self.repo = Repository()

oscar/apps/voucher/tests.py → tests/unit/voucher_tests.py 파일 보기


Loading…
취소
저장