Merge branch 'heinzel' of python/django-deploy into master
All checks were successful
buildbot/tox Build done.
All checks were successful
buildbot/tox Build done.
This commit was merged in pull request #6.
This commit is contained in:
@@ -156,6 +156,12 @@ class DjangoProject(object):
|
|||||||
raise DjangoDeployError('django deploy hooks from {} has no ROOT_URLCONF'.format(module_path),
|
raise DjangoDeployError('django deploy hooks from {} has no ROOT_URLCONF'.format(module_path),
|
||||||
code=errno.ENOLINK)
|
code=errno.ENOLINK)
|
||||||
|
|
||||||
|
if urlconf.startswith('.'):
|
||||||
|
urlconf = '{}{}'.format(module_path, urlconf)
|
||||||
|
|
||||||
|
if not route.endswith('/'):
|
||||||
|
route += '/'
|
||||||
|
|
||||||
config = DjangoProjectHooksConfig(project_dir=self._project_dir)
|
config = DjangoProjectHooksConfig(project_dir=self._project_dir)
|
||||||
if module_path not in config: # pragma: no cover
|
if module_path not in config: # pragma: no cover
|
||||||
config[module_path] = {}
|
config[module_path] = {}
|
||||||
|
|||||||
@@ -23,9 +23,10 @@ def get_urlpatterns(file_path, urlpatterns):
|
|||||||
for app in config:
|
for app in config:
|
||||||
if 'MOUNT' in config[app]:
|
if 'MOUNT' in config[app]:
|
||||||
route, urlconf_module = config[app]['MOUNT']
|
route, urlconf_module = config[app]['MOUNT']
|
||||||
pattern = '^{}/'.format(route)
|
if route == '/':
|
||||||
if urlconf_module.startswith('.'):
|
pattern = '^$'
|
||||||
urlconf_module = '{}{}'.format(app, urlconf_module)
|
else:
|
||||||
|
pattern = '^{}'.format(route)
|
||||||
url_obj = url(pattern, include(urlconf_module))
|
url_obj = url(pattern, include(urlconf_module))
|
||||||
urls_list.append(url_obj)
|
urls_list.append(url_obj)
|
||||||
return urls_list
|
return urls_list
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ class DjangoProjectTestCase(DjangoDeployTestCase):
|
|||||||
project.mount_app('django_deploy.tests.fake_app1', '')
|
project.mount_app('django_deploy.tests.fake_app1', '')
|
||||||
|
|
||||||
expected_urlpatterns = [
|
expected_urlpatterns = [
|
||||||
('URLResolver', '^/', 'django_deploy.tests.fake_app1.urls'),
|
('URLResolver', '^$', 'django_deploy.tests.fake_app1.urls'),
|
||||||
]
|
]
|
||||||
self.assert_urlpatterns(project_dir, expected_urlpatterns)
|
self.assert_urlpatterns(project_dir, expected_urlpatterns)
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ class DjangoProjectTestCase(DjangoDeployTestCase):
|
|||||||
project.create()
|
project.create()
|
||||||
project.mount_app('django_deploy.tests.fake_app1', 'app1')
|
project.mount_app('django_deploy.tests.fake_app1', 'app1')
|
||||||
project.mount_app('django_deploy.tests.fake_app1', 'app1')
|
project.mount_app('django_deploy.tests.fake_app1', 'app1')
|
||||||
project.mount_app('django_deploy.tests.fake_app2', 'app2')
|
project.mount_app('django_deploy.tests.fake_app2', 'app2/')
|
||||||
|
|
||||||
expected_urlpatterns = [
|
expected_urlpatterns = [
|
||||||
('URLResolver', '^app1/', 'django_deploy.tests.fake_app1.urls'),
|
('URLResolver', '^app1/', 'django_deploy.tests.fake_app1.urls'),
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class ProgramTestCase(DjangoDeployTestCase):
|
|||||||
'-c',
|
'-c',
|
||||||
'--mount-app', 'django_deploy.tests.fake_app1', 'app1',
|
'--mount-app', 'django_deploy.tests.fake_app1', 'app1',
|
||||||
'--mount-app', 'django_deploy.tests.fake_app1', 'app1',
|
'--mount-app', 'django_deploy.tests.fake_app1', 'app1',
|
||||||
'-m', 'django_deploy.tests.fake_app2', 'app2',
|
'-m', 'django_deploy.tests.fake_app2', 'app2/',
|
||||||
project_dir
|
project_dir
|
||||||
]
|
]
|
||||||
exitval = self._program(argv=argv)
|
exitval = self._program(argv=argv)
|
||||||
@@ -138,7 +138,7 @@ class ProgramTestCase(DjangoDeployTestCase):
|
|||||||
project_dir = self._tmp_dir
|
project_dir = self._tmp_dir
|
||||||
self._program(argv=['-c', project_dir])
|
self._program(argv=['-c', project_dir])
|
||||||
argv = [
|
argv = [
|
||||||
'-m', 'django_deploy.tests.fake_app1', 'app1',
|
'-m', 'django_deploy.tests.fake_app1', '/',
|
||||||
'-m', 'django_deploy.tests.fake_app0', 'app0',
|
'-m', 'django_deploy.tests.fake_app0', 'app0',
|
||||||
'-m', 'django_deploy.tests.fake_app2', 'app2',
|
'-m', 'django_deploy.tests.fake_app2', 'app2',
|
||||||
project_dir
|
project_dir
|
||||||
@@ -148,7 +148,7 @@ class ProgramTestCase(DjangoDeployTestCase):
|
|||||||
|
|
||||||
# Similar code from test_api.test_mount_apps
|
# Similar code from test_api.test_mount_apps
|
||||||
expected_urlpatterns = [
|
expected_urlpatterns = [
|
||||||
('URLResolver', '^app1/', 'django_deploy.tests.fake_app1.urls'),
|
('URLResolver', '^$', 'django_deploy.tests.fake_app1.urls'),
|
||||||
('URLResolver', '^app2/', 'django_deploy.tests.fake_app2.urls'),
|
('URLResolver', '^app2/', 'django_deploy.tests.fake_app2.urls'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user