Skip to content

Commit

Permalink
Add test for overriding views without overriding app
Browse files Browse the repository at this point in the history
  • Loading branch information
maiksprenger committed Apr 28, 2014
1 parent 93fe9cf commit 275d008
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
Empty file.
1 change: 1 addition & 0 deletions tests/_site/apps/customer/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from oscar.apps.customer.models import *
6 changes: 6 additions & 0 deletions tests/_site/apps/customer/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from oscar.apps.customer.views import AccountSummaryView as OscarAccountSummaryView


class AccountSummaryView(OscarAccountSummaryView):
# just here to test import in loading_tests:ClassLoadingWithLocalOverrideTests
pass
2 changes: 1 addition & 1 deletion tests/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def configure():
# Use a custom partner app to test overriding models. I can't
# find a way of doing this on a per-test basis, so I'm using a
# global change.
] + oscar.get_core_apps(['tests._site.apps.partner']),
] + oscar.get_core_apps(['tests._site.apps.partner', 'tests._site.apps.customer']),
'TEMPLATE_CONTEXT_PROCESSORS': (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.request",
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/core/loading_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ def test_loading_classes_with_root_app(self):
(Free,) = get_classes('shipping.methods', ('Free',))
self.assertEqual('shipping.methods', Free.__module__)

def test_overriding_view_is_possible_without_overriding_app(self):
from oscar.apps.customer.app import application, CustomerApplication
# If test fails, it's helpful to know if it's caused by order of
# execution
self.assertEqual(CustomerApplication().summary_view.__module__,
'tests._site.apps.customer.views')
self.assertEqual(application.summary_view.__module__,
'tests._site.apps.customer.views')


class ClassLoadingWithLocalOverrideWithMultipleSegmentsTests(TestCase):

Expand Down

0 comments on commit 275d008

Please sign in to comment.