0001-agent-add-generic-import_template-management-command.patch
hobo/agent/common/management/commands/import_template.py | ||
---|---|---|
1 |
# hobo - portal to configure and deploy applications |
|
2 |
# Copyright (C) 2015 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import os |
|
18 | ||
19 |
from django.conf import settings |
|
20 |
from django.core.management.base import BaseCommand, CommandError |
|
21 |
from django.core.management import call_command, get_commands |
|
22 | ||
23 | ||
24 |
class Command(BaseCommand): |
|
25 | ||
26 |
def add_arguments(self, parser): |
|
27 |
parser.add_argument('template_name', type=str) |
|
28 |
parser.add_argument('--basepath', type=str) |
|
29 | ||
30 |
def handle(self, *args, **kwargs): |
|
31 |
app_name = settings.PROJECT_NAME |
|
32 |
basepath = kwargs.get('basepath', '/var/lib/%s/skeletons') |
|
33 |
template = '%s/%s.json' % (basepath, kwargs.get('template_name')) |
|
34 | ||
35 |
if 'import_site' in get_commands(): |
|
36 | ||
37 |
if not os.path.isfile(template): |
|
38 |
raise(CommandError('Template not found')) |
|
39 | ||
40 |
call_command('import_site', template) |
tests/utils.py | ||
---|---|---|
1 |
def byteify(input): |
|
2 |
if isinstance(input, dict): |
|
3 |
return {byteify(key): byteify(value) |
|
4 |
for key, value in input.iteritems()} |
|
5 |
elif isinstance(input, list): |
|
6 |
return [byteify(element) for element in input] |
|
7 |
elif isinstance(input, unicode): |
|
8 |
return input.encode('utf-8') |
|
9 |
else: |
|
10 |
return input |
tests_authentic/data_authentic_export_site.json | ||
---|---|---|
1 |
{ |
|
2 |
"ous": [ |
|
3 |
{ |
|
4 |
"username_is_unique": false, |
|
5 |
"validate_emails": false, |
|
6 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
7 |
"default": true, |
|
8 |
"description": "", |
|
9 |
"email_is_unique": false, |
|
10 |
"slug": "default", |
|
11 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
12 |
} |
|
13 |
], |
|
14 |
"roles": [ |
|
15 |
{ |
|
16 |
"description": "", |
|
17 |
"service": { |
|
18 |
"ou": { |
|
19 |
"slug": "default", |
|
20 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
21 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
22 |
}, |
|
23 |
"slug": "hobo" |
|
24 |
}, |
|
25 |
"name": "Administrateur de Hobo", |
|
26 |
"attributes": [ |
|
27 |
{ |
|
28 |
"kind": "string", |
|
29 |
"name": "is_superuser", |
|
30 |
"value": "true" |
|
31 |
} |
|
32 |
], |
|
33 |
"ou": { |
|
34 |
"slug": "default", |
|
35 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
36 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
37 |
}, |
|
38 |
"external_id": "", |
|
39 |
"slug": "_a2-hobo-superuser", |
|
40 |
"uuid": "25f33158b7e2449b9a5b00dbc57bf416" |
|
41 |
}, |
|
42 |
{ |
|
43 |
"description": "", |
|
44 |
"service": { |
|
45 |
"ou": { |
|
46 |
"slug": "default", |
|
47 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
48 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
49 |
}, |
|
50 |
"slug": "portal" |
|
51 |
}, |
|
52 |
"name": "Administrateur de Compte citoyen", |
|
53 |
"attributes": [ |
|
54 |
{ |
|
55 |
"kind": "string", |
|
56 |
"name": "is_superuser", |
|
57 |
"value": "true" |
|
58 |
} |
|
59 |
], |
|
60 |
"ou": { |
|
61 |
"slug": "default", |
|
62 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
63 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
64 |
}, |
|
65 |
"external_id": "", |
|
66 |
"slug": "_a2-hobo-superuser", |
|
67 |
"uuid": "84b3b1ba76e44bcdb4fd4437c448a981" |
|
68 |
}, |
|
69 |
{ |
|
70 |
"description": "", |
|
71 |
"service": { |
|
72 |
"ou": { |
|
73 |
"slug": "default", |
|
74 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
75 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
76 |
}, |
|
77 |
"slug": "eservices" |
|
78 |
}, |
|
79 |
"name": "Administrateur de D\u00e9marches", |
|
80 |
"attributes": [ |
|
81 |
{ |
|
82 |
"kind": "string", |
|
83 |
"name": "is_superuser", |
|
84 |
"value": "true" |
|
85 |
} |
|
86 |
], |
|
87 |
"ou": { |
|
88 |
"slug": "default", |
|
89 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
90 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
91 |
}, |
|
92 |
"external_id": "", |
|
93 |
"slug": "_a2-hobo-superuser", |
|
94 |
"uuid": "9054a61ccf684396b38189f1ca1ec087" |
|
95 |
}, |
|
96 |
{ |
|
97 |
"description": "", |
|
98 |
"service": { |
|
99 |
"ou": { |
|
100 |
"slug": "default", |
|
101 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
102 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
103 |
}, |
|
104 |
"slug": "portal-agent" |
|
105 |
}, |
|
106 |
"name": "Administrateur de Portail agent", |
|
107 |
"attributes": [ |
|
108 |
{ |
|
109 |
"kind": "string", |
|
110 |
"name": "is_superuser", |
|
111 |
"value": "true" |
|
112 |
} |
|
113 |
], |
|
114 |
"ou": { |
|
115 |
"slug": "default", |
|
116 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
117 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
118 |
}, |
|
119 |
"external_id": "", |
|
120 |
"slug": "_a2-hobo-superuser", |
|
121 |
"uuid": "e6e22e5c0ca04ac0bf3b50d88eafe6d5" |
|
122 |
}, |
|
123 |
{ |
|
124 |
"description": "", |
|
125 |
"service": { |
|
126 |
"ou": { |
|
127 |
"slug": "default", |
|
128 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
129 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
130 |
}, |
|
131 |
"slug": "passerelle" |
|
132 |
}, |
|
133 |
"name": "Administrateur de Passerelle", |
|
134 |
"attributes": [ |
|
135 |
{ |
|
136 |
"kind": "string", |
|
137 |
"name": "is_superuser", |
|
138 |
"value": "true" |
|
139 |
} |
|
140 |
], |
|
141 |
"ou": { |
|
142 |
"slug": "default", |
|
143 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
144 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
145 |
}, |
|
146 |
"external_id": "", |
|
147 |
"slug": "_a2-hobo-superuser", |
|
148 |
"uuid": "243f58712aa248e9b27aae669341c156" |
|
149 |
}, |
|
150 |
{ |
|
151 |
"description": "", |
|
152 |
"service": null, |
|
153 |
"name": "Administrateur du r\u00f4le \u00ab\u00a0Debug eo\u00a0\u00bb", |
|
154 |
"ou": { |
|
155 |
"slug": "default", |
|
156 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
157 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
158 |
}, |
|
159 |
"permissions": [ |
|
160 |
{ |
|
161 |
"operation": { |
|
162 |
"slug": "view" |
|
163 |
}, |
|
164 |
"ou": null, |
|
165 |
"target_ct": { |
|
166 |
"model": "contenttype", |
|
167 |
"app_label": "contenttypes" |
|
168 |
}, |
|
169 |
"target": { |
|
170 |
"model": "user", |
|
171 |
"app_label": "custom_user" |
|
172 |
} |
|
173 |
}, |
|
174 |
{ |
|
175 |
"operation": { |
|
176 |
"slug": "admin" |
|
177 |
}, |
|
178 |
"ou": { |
|
179 |
"slug": "default", |
|
180 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
181 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
182 |
}, |
|
183 |
"target_ct": { |
|
184 |
"model": "role", |
|
185 |
"app_label": "a2_rbac" |
|
186 |
}, |
|
187 |
"target": { |
|
188 |
"name": "Debug eo", |
|
189 |
"ou": { |
|
190 |
"slug": "default", |
|
191 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
192 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
193 |
}, |
|
194 |
"uuid": "18e7bf78dc9a432396a99f32060052ec", |
|
195 |
"service": null, |
|
196 |
"slug": "debug-eo" |
|
197 |
} |
|
198 |
}, |
|
199 |
{ |
|
200 |
"operation": { |
|
201 |
"slug": "change" |
|
202 |
}, |
|
203 |
"ou": null, |
|
204 |
"target_ct": { |
|
205 |
"model": "role", |
|
206 |
"app_label": "a2_rbac" |
|
207 |
}, |
|
208 |
"target": { |
|
209 |
"name": "Administrateur du r\u00f4le \u00ab\u00a0Debug eo\u00a0\u00bb", |
|
210 |
"ou": { |
|
211 |
"slug": "default", |
|
212 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
213 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
214 |
}, |
|
215 |
"uuid": "3049444b35874b3b9a8377ad2f10b8b6", |
|
216 |
"service": null, |
|
217 |
"slug": "_a2-managers-of-role-debug-eo" |
|
218 |
} |
|
219 |
} |
|
220 |
], |
|
221 |
"external_id": "", |
|
222 |
"slug": "_a2-managers-of-role-debug-eo", |
|
223 |
"uuid": "3049444b35874b3b9a8377ad2f10b8b6" |
|
224 |
}, |
|
225 |
{ |
|
226 |
"description": "", |
|
227 |
"service": null, |
|
228 |
"name": "Debug eo", |
|
229 |
"attributes": [ |
|
230 |
{ |
|
231 |
"kind": "json", |
|
232 |
"name": "emails_to_members", |
|
233 |
"value": "false" |
|
234 |
}, |
|
235 |
{ |
|
236 |
"kind": "json", |
|
237 |
"name": "details", |
|
238 |
"value": "\"\"" |
|
239 |
}, |
|
240 |
{ |
|
241 |
"kind": "json", |
|
242 |
"name": "emails", |
|
243 |
"value": "[]" |
|
244 |
} |
|
245 |
], |
|
246 |
"ou": { |
|
247 |
"slug": "default", |
|
248 |
"uuid": "69b0a02cf58a4c71b1ae548f1375baff", |
|
249 |
"name": "Collectivit\u00e9 par d\u00e9faut" |
|
250 |
}, |
|
251 |
"external_id": "", |
|
252 |
"slug": "debug-eo", |
|
253 |
"uuid": "18e7bf78dc9a432396a99f32060052ec" |
|
254 |
}, |
|
255 |
{ |
|
256 |
"description": "", |
|
257 |
"service": null, |
|
258 |
"name": "Administrateur", |
|
259 |
"parents": [ |
|
260 |
{ |
|
261 |
"name": "Administrateur des entit\u00e9s", |
|
262 |
"ou": null, |
|
263 |
"uuid": "a1ff1b3da88f47cea91e344998dfdfbf", |
|
264 |
"service": null, |
|
265 |
"slug": "_a2-administrateur-des-entites" |
|
266 |
}, |
|
267 |
{ |
|
268 |
"name": "Administrateur des r\u00f4les", |
|
269 |
"ou": null, |
|
270 |
"uuid": "8dd625b74cff40aa8531d7d72616550e", |
|
271 |
"service": null, |
|
272 |
"slug": "_a2-administrateur-des-roles" |
|
273 |
}, |
|
274 |
{ |
|
275 |
"name": "Administrateur des utilisateurs", |
|
276 |
"ou": null, |
|
277 |
"uuid": "4ab5effedc404fb1bcba4d21ee89b719", |
|
278 |
"service": null, |
|
279 |
"slug": "_a2-administrateur-des-utilisateurs" |
|
280 |
} |
|
281 |
], |
|
282 |
"ou": null, |
|
283 |
"permissions": [ |
|
284 |
{ |
|
285 |
"operation": { |
|
286 |
"slug": "change" |
|
287 |
}, |
|
288 |
"ou": null, |
|
289 |
"target_ct": { |
|
290 |
"model": "role", |
|
291 |
"app_label": "a2_rbac" |
|
292 |
}, |
|
293 |
"target": { |
|
294 |
"name": "Administrateur", |
|
295 |
"ou": null, |
|
296 |
"uuid": "81a8708382bb4e8ea12ed0e172aa48b9", |
|
297 |
"service": null, |
|
298 |
"slug": "_a2-manager" |
|
299 |
} |
|
300 |
} |
|
301 |
], |
|
302 |
"external_id": "", |
|
303 |
"slug": "_a2-manager", |
|
304 |
"uuid": "81a8708382bb4e8ea12ed0e172aa48b9" |
|
305 |
}, |
|
306 |
{ |
|
307 |
"description": "", |
|
308 |
"service": null, |
|
309 |
"name": "Administrateur des entit\u00e9s", |
|
310 |
"ou": null, |
|
311 |
"permissions": [ |
|
312 |
{ |
|
313 |
"operation": { |
|
314 |
"slug": "view" |
|
315 |
}, |
|
316 |
"ou": null, |
|
317 |
"target_ct": { |
|
318 |
"model": "contenttype", |
|
319 |
"app_label": "contenttypes" |
|
320 |
}, |
|
321 |
"target": { |
|
322 |
"model": "organizationalunit", |
|
323 |
"app_label": "a2_rbac" |
|
324 |
} |
|
325 |
}, |
|
326 |
{ |
|
327 |
"operation": { |
|
328 |
"slug": "admin" |
|
329 |
}, |
|
330 |
"ou": null, |
|
331 |
"target_ct": { |
|
332 |
"model": "contenttype", |
|
333 |
"app_label": "contenttypes" |
|
334 |
}, |
|
335 |
"target": { |
|
336 |
"model": "organizationalunit", |
|
337 |
"app_label": "a2_rbac" |
|
338 |
} |
|
339 |
}, |
|
340 |
{ |
|
341 |
"operation": { |
|
342 |
"slug": "search" |
|
343 |
}, |
|
344 |
"ou": null, |
|
345 |
"target_ct": { |
|
346 |
"model": "contenttype", |
|
347 |
"app_label": "contenttypes" |
|
348 |
}, |
|
349 |
"target": { |
|
350 |
"model": "organizationalunit", |
|
351 |
"app_label": "a2_rbac" |
|
352 |
} |
|
353 |
} |
|
354 |
], |
|
355 |
"external_id": "", |
|
356 |
"slug": "_a2-administrateur-des-entites", |
|
357 |
"uuid": "a1ff1b3da88f47cea91e344998dfdfbf" |
|
358 |
}, |
|
359 |
{ |
|
360 |
"description": "", |
|
361 |
"service": null, |
|
362 |
"name": "Administrateur des r\u00f4les", |
|
363 |
"ou": null, |
|
364 |
"permissions": [ |
|
365 |
{ |
|
366 |
"operation": { |
|
367 |
"slug": "view" |
|
368 |
}, |
|
369 |
"ou": null, |
|
370 |
"target_ct": { |
|
371 |
"model": "contenttype", |
|
372 |
"app_label": "contenttypes" |
|
373 |
}, |
|
374 |
"target": { |
|
375 |
"model": "user", |
|
376 |
"app_label": "custom_user" |
|
377 |
} |
|
378 |
}, |
|
379 |
{ |
|
380 |
"operation": { |
|
381 |
"slug": "view" |
|
382 |
}, |
|
383 |
"ou": null, |
|
384 |
"target_ct": { |
|
385 |
"model": "contenttype", |
|
386 |
"app_label": "contenttypes" |
|
387 |
}, |
|
388 |
"target": { |
|
389 |
"model": "organizationalunit", |
|
390 |
"app_label": "a2_rbac" |
|
391 |
} |
|
392 |
}, |
|
393 |
{ |
|
394 |
"operation": { |
|
395 |
"slug": "admin" |
|
396 |
}, |
|
397 |
"ou": null, |
|
398 |
"target_ct": { |
|
399 |
"model": "contenttype", |
|
400 |
"app_label": "contenttypes" |
|
401 |
}, |
|
402 |
"target": { |
|
403 |
"model": "role", |
|
404 |
"app_label": "a2_rbac" |
|
405 |
} |
|
406 |
}, |
|
407 |
{ |
|
408 |
"operation": { |
|
409 |
"slug": "search" |
|
410 |
}, |
|
411 |
"ou": null, |
|
412 |
"target_ct": { |
|
413 |
"model": "contenttype", |
|
414 |
"app_label": "contenttypes" |
|
415 |
}, |
|
416 |
"target": { |
|
417 |
"model": "organizationalunit", |
|
418 |
"app_label": "a2_rbac" |
|
419 |
} |
|
420 |
} |
|
421 |
], |
|
422 |
"external_id": "", |
|
423 |
"slug": "_a2-administrateur-des-roles", |
|
424 |
"uuid": "8dd625b74cff40aa8531d7d72616550e" |
|
425 |
}, |
|
426 |
{ |
|
427 |
"description": "", |
|
428 |
"service": null, |
|
429 |
"name": "Administrateur des utilisateurs", |
|
430 |
"ou": null, |
|
431 |
"permissions": [ |
|
432 |
{ |
|
433 |
"operation": { |
|
434 |
"slug": "view" |
|
435 |
}, |
|
436 |
"ou": null, |
|
437 |
"target_ct": { |
|
438 |
"model": "contenttype", |
|
439 |
"app_label": "contenttypes" |
|
440 |
}, |
|
441 |
"target": { |
|
442 |
"model": "organizationalunit", |
|
443 |
"app_label": "a2_rbac" |
|
444 |
} |
|
445 |
}, |
|
446 |
{ |
|
447 |
"operation": { |
|
448 |
"slug": "admin" |
|
449 |
}, |
|
450 |
"ou": null, |
|
451 |
"target_ct": { |
|
452 |
"model": "contenttype", |
|
453 |
"app_label": "contenttypes" |
|
454 |
}, |
|
455 |
"target": { |
|
456 |
"model": "user", |
|
457 |
"app_label": "custom_user" |
|
458 |
} |
|
459 |
}, |
|
460 |
{ |
|
461 |
"operation": { |
|
462 |
"slug": "search" |
|
463 |
}, |
|
464 |
"ou": null, |
|
465 |
"target_ct": { |
|
466 |
"model": "contenttype", |
|
467 |
"app_label": "contenttypes" |
|
468 |
}, |
|
469 |
"target": { |
|
470 |
"model": "organizationalunit", |
|
471 |
"app_label": "a2_rbac" |
|
472 |
} |
|
473 |
} |
|
474 |
], |
|
475 |
"external_id": "", |
|
476 |
"slug": "_a2-administrateur-des-utilisateurs", |
|
477 |
"uuid": "4ab5effedc404fb1bcba4d21ee89b719" |
|
478 |
} |
|
479 |
] |
|
480 |
} |
tests_authentic/test_hobo_deploy.py | ||
---|---|---|
6 | 6 |
import json |
7 | 7 |
import mock |
8 | 8 | |
9 |
from django.core.management import call_command |
|
10 |
from django.db import connection |
|
11 |
from hobo.multitenant.middleware import TenantMiddleware |
|
12 |
from authentic2.data_transfer import export_site |
|
13 |
os.sys.path.append('%s/tests' % os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
|
14 |
from utils import byteify |
|
15 | ||
9 | 16 |
pytestmark = pytest.mark.django_db |
10 | 17 | |
11 | 18 | |
... | ... | |
436 | 443 |
assert Role.objects.filter( |
437 | 444 |
ou=provider.ou, service__isnull=True, |
438 | 445 |
name=u'Service état-civil').count() == 1 |
446 | ||
447 | ||
448 |
def test_import_template(db, tenant_base): |
|
449 |
call_command('create_tenant', 'authentic.example.net') |
|
450 |
tenant = TenantMiddleware.get_tenant_by_hostname('authentic.example.net') |
|
451 |
connection.set_tenant(tenant) |
|
452 |
call_command('import_template', '--basepath=%s' % os.path.dirname(__file__), 'data_authentic_export_site') |
|
453 |
content = open('%s/data_authentic_export_site.json' % os.path.dirname(__file__)).read() |
|
454 |
assert byteify(export_site()) == byteify(json.loads(content)) |
tests_passerelle/data_passerelle_export_site.json | ||
---|---|---|
1 |
{ |
|
2 |
"apiusers": [], |
|
3 |
"resources": [ |
|
4 |
{ |
|
5 |
"log_level": "INFO", |
|
6 |
"description": "", |
|
7 |
"title": "Foo", |
|
8 |
"access_rights": [], |
|
9 |
"@type": "passerelle-resource", |
|
10 |
"text_value_template": "", |
|
11 |
"slug": "foo", |
|
12 |
"resource_type": "jsondatastore.jsondatastore" |
|
13 |
}, |
|
14 |
{ |
|
15 |
"log_level": "INFO", |
|
16 |
"description": ".", |
|
17 |
"title": "Bar", |
|
18 |
"access_rights": [], |
|
19 |
"@type": "passerelle-resource", |
|
20 |
"text_value_template": "{{nom|safe}}", |
|
21 |
"slug": "bar", |
|
22 |
"resource_type": "jsondatastore.jsondatastore" |
|
23 |
}] |
|
24 |
} |
tests_passerelle/test_deploy.py | ||
---|---|---|
1 | 1 |
import json |
2 |
import os |
|
2 | 3 |
import sys |
3 | 4 | |
4 | 5 |
from hobo.multitenant.middleware import TenantMiddleware |
5 | 6 |
from django.core.management import call_command |
7 |
from django.db import connection |
|
6 | 8 |
import StringIO |
7 | 9 | |
10 |
from passerelle.utils import export_site |
|
11 |
os.sys.path.append('%s/tests' % os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
|
12 |
from utils import byteify |
|
13 | ||
8 | 14 | |
9 | 15 |
def test_deploy_specifics(db, tenant_base): |
10 | 16 |
hobo_json = { |
... | ... | |
42 | 48 |
sys.stdin = old_stdin |
43 | 49 | |
44 | 50 |
assert len(list(TenantMiddleware.get_tenants())) == 1 |
51 | ||
52 | ||
53 |
def test_import_template(db, tenant_base): |
|
54 |
call_command('create_tenant', 'passerelle.example.net') |
|
55 |
tenant = TenantMiddleware.get_tenant_by_hostname('passerelle.example.net') |
|
56 |
connection.set_tenant(tenant) |
|
57 |
call_command('import_template', '--basepath=%s' % os.path.dirname(__file__), 'data_passerelle_export_site') |
|
58 |
content = open('%s/data_passerelle_export_site.json' % os.path.dirname(__file__)).read() |
|
59 |
assert export_site() == byteify(json.loads(content)) |
|
45 |
- |