forked from django-cms/django-cms
-
Notifications
You must be signed in to change notification settings - Fork 1
/
testserver.py
160 lines (138 loc) · 4.03 KB
/
testserver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import sys
from cms.utils.compat import DJANGO_1_9
def noop_gettext(s):
return s
permission = True
cms_toolbar_edit_on = 'edit'
port = 8000
for arg in sys.argv:
if arg == '--CMS_PERMISSION=False':
permission = False
if arg == '--CMS_TOOLBAR_URL__EDIT_ON=test-edit':
cms_toolbar_edit_on = 'test-edit'
if arg.startswith('--port='):
port = arg.split('=')[1]
gettext = noop_gettext
class DisableMigrations(object):
def __contains__(self, item):
return True
def __getitem__(self, item):
return 'notmigrations'
def update(self, whatever):
return True
HELPER_SETTINGS = dict(
CMS_PERMISSION=permission,
LANGUAGES=(
('en', u'English'),
('de', u'Deutsch'),
('it', u'Italiano'),
('zh-cn', u'Chinese (Simplified)'),
),
LANGUAGE_CODE='en',
PARLER_LANGUAGES={
1: (
{'code': 'en', 'fallbacks': ['de',]},
{'code': 'de', 'fallbacks': ['en',]},
{'code': 'it', 'fallbacks': ['en',]},
{'code': 'zh-cn', 'fallbacks': ['en',]},
),
'default': {
'fallback': 'en',
'hide_untranslated': False,
},
},
PARLER_ENABLE_CACHING=False,
CMS_CACHE_DURATIONS={
'menus': 0,
'content': 0,
'permissions': 0,
},
CMS_PAGE_CACHE=False,
CMS_TOOLBAR_URL__EDIT_ON=cms_toolbar_edit_on,
# required for integration tests
LOGIN_URL='/admin/login/?user-login=test',
CMS_LANGUAGES={
1: [
{
'code': 'en',
'name': gettext('English'),
'fallbacks': ['de',],
},
{
'code': 'de',
'name': gettext('German'),
'fallbacks': ['en',],
},
{
'code': 'it',
'name': gettext('Italian'),
'fallbacks': ['en',],
},
{
'code': 'zh-cn',
'name': gettext('Chinese Simplified'),
'fallbacks': ['en',]
},
],
'default': {
'fallbacks': ['en', 'de',],
'redirect_on_fallback': False,
'public': True,
'hide_untranslated': False,
}
},
CMS_PLACEHOLDER_CONF={
'placeholder_content_2': {
'plugin_modules': {
'Bootstrap3ButtonCMSPlugin': 'Different Grouper'
},
'plugin_labels': {
'Bootstrap3ButtonCMSPlugin': gettext('Add a link')
},
}
},
INSTALLED_APPS=[
'djangocms_text_ckeditor',
'cms.test_utils.project.pluginapp.plugins.link',
'cms.test_utils.project.pluginapp.plugins.multicolumn',
'cms.test_utils.project.pluginapp.plugins.style',
'cms.test_utils.project.placeholderapp',
],
MIDDLEWARE_CLASSES=[
'cms.middleware.utils.ApphookReloadMiddleware',
],
TEMPLATE_DIRS=(
os.path.join(
os.path.dirname(__file__),
'cms', 'test_utils', 'project', 'templates', 'integration'),
),
CMS_TEMPLATES=(
('fullwidth.html', 'Fullwidth'),
('page.html', 'Standard page'),
('simple.html', 'Simple page'),
),
)
if DJANGO_1_9:
HELPER_SETTINGS['MIGRATION_MODULES'] = DisableMigrations()
else:
HELPER_SETTINGS['MIGRATION_MODULES'] = {
'auth': None,
'contenttypes': None,
'sessions': None,
'sites': None,
'cms': None,
'menus': None,
'djangocms_text_ckeditor': None,
}
def run():
from djangocms_helper import runner
os.environ.setdefault('DATABASE_URL', 'sqlite://localhost/testdb.sqlite')
# we use '.runner()', not '.cms()' nor '.run()' because it does not
# add 'test' argument implicitly
runner.runner([sys.argv[0], 'cms', '--cms', 'server', '--bind', '0.0.0.0', '--port', str(port)])
if __name__ == "__main__":
run()