diff --git a/oscar/core/customisation.py b/oscar/core/customisation.py index 6a70e7b1648..19801acf4ea 100644 --- a/oscar/core/customisation.py +++ b/oscar/core/customisation.py @@ -35,11 +35,13 @@ def fork_app(app_label, folder_path, logger=None): os.mkdir(app_folder_path) # Create minimum app files - logger.info("Creating __init__.py and models.py modules") + logger.info("Creating __init__.py, admin.py and models.py modules") create_file(os.path.join(app_folder_path, '__init__.py')) + create_file(os.path.join(app_folder_path, 'admin.py'), + "from oscar.apps.%s.admin import * # noqa" % app_label) create_file( os.path.join(app_folder_path, 'models.py'), - "from oscar.apps.%s.models import *" % app_label) + "from oscar.apps.%s.models import * # noqa" % app_label) # Migrations source = os.path.join( diff --git a/tests/unit/core/customisation_tests.py b/tests/unit/core/customisation_tests.py index f2bea657375..438de39f9ae 100644 --- a/tests/unit/core/customisation_tests.py +++ b/tests/unit/core/customisation_tests.py @@ -41,13 +41,15 @@ def test_creates_init_file(self): filepath = os.path.join(self.tmp_folder, 'order', '__init__.py') self.assertTrue(os.path.exists(filepath)) - def test_creates_models_file(self): + def test_creates_models_and_admin_file(self): customisation.fork_app('order', self.tmp_folder) - filepath = os.path.join(self.tmp_folder, 'order', 'models.py') - self.assertTrue(os.path.exists(filepath)) + for module in ['models', 'admin']: + filepath = os.path.join(self.tmp_folder, 'order', '%s.py' % module) + self.assertTrue(os.path.exists(filepath)) - contents = open(filepath).read() - self.assertTrue('from oscar.apps.order.models import *' in contents) + contents = open(filepath).read() + expected_string = 'from oscar.apps.order.%s import *' % module + self.assertTrue(expected_string in contents) def test_copies_in_migrations(self): customisation.fork_app('order', self.tmp_folder)