0002-cook-add-tests-using-tenants-for-cook.py-32886.patch
tests_schemas/conftest.py | ||
---|---|---|
1 |
import os |
|
2 |
import shutil |
|
3 | ||
1 | 4 |
import pytest |
2 | 5 | |
3 | 6 |
from django.core.management import call_command |
... | ... | |
47 | 50 |
monkeypatch.setattr(Command, 'wait_operationals', fake_wait) |
48 | 51 | |
49 | 52 |
return services |
53 | ||
54 | ||
55 |
@pytest.fixture |
|
56 |
def fake_themes(request, settings, tmpdir): |
|
57 |
THEMES=""" |
|
58 |
[ |
|
59 |
{ |
|
60 |
"id": "publik", |
|
61 |
"label": "Publik", |
|
62 |
"variables": { |
|
63 |
"css_variant": "publik", |
|
64 |
"no_extra_js": false, |
|
65 |
"theme_color": "#E80E89" |
|
66 |
} |
|
67 |
} |
|
68 |
] |
|
69 |
""" |
|
70 |
base_dir = str(tmpdir.mkdir('themes')) |
|
71 |
settings.THEMES_DIRECTORY = base_dir |
|
72 | ||
73 |
themes_dir = os.path.join(base_dir, 'publik-base') |
|
74 |
os.mkdir(themes_dir) |
|
75 |
with open(os.path.join(themes_dir, 'themes.json'), 'w') as handler: |
|
76 |
handler.write(THEMES) |
tests_schemas/ozwillo_recipe.json | ||
---|---|---|
1 |
{ |
|
2 |
"steps": [ |
|
3 |
{ |
|
4 |
"create-hobo": { |
|
5 |
"url": "https://${hobo}/", |
|
6 |
"primary": true |
|
7 |
} |
|
8 |
}, |
|
9 |
{ |
|
10 |
"create-authentic": { |
|
11 |
"title": "Connexion", |
|
12 |
"url": "https://${authentic}/" |
|
13 |
} |
|
14 |
}, |
|
15 |
{ |
|
16 |
"set-idp": {} |
|
17 |
}, |
|
18 |
{ |
|
19 |
"create-combo": { |
|
20 |
"template_name": "portal-user", |
|
21 |
"title": "Compte citoyen", |
|
22 |
"url": "https://${combo}/" |
|
23 |
} |
|
24 |
}, |
|
25 |
{ |
|
26 |
"create-combo": { |
|
27 |
"slug": "portal-agent", |
|
28 |
"template_name": "portal-agent", |
|
29 |
"title": "Portail agent", |
|
30 |
"url": "https://${combo_agent}/" |
|
31 |
} |
|
32 |
}, |
|
33 |
{ |
|
34 |
"create-wcs": { |
|
35 |
"template_name": "export.zip", |
|
36 |
"title": "D\u00e9marches", |
|
37 |
"url": "https://${wcs}/" |
|
38 |
} |
|
39 |
}, |
|
40 |
{ |
|
41 |
"create-fargo": { |
|
42 |
"title": "Porte documents", |
|
43 |
"url": "https://${fargo}/" |
|
44 |
} |
|
45 |
}, |
|
46 |
{ |
|
47 |
"create-passerelle": { |
|
48 |
"title": "Passerelle", |
|
49 |
"url": "https://${passerelle}/" |
|
50 |
} |
|
51 |
}, |
|
52 |
{ |
|
53 |
"set-theme": { |
|
54 |
"theme": "publik" |
|
55 |
} |
|
56 |
} |
|
57 |
], |
|
58 |
"variables": { |
|
59 |
"authentic": "connexion-instance-name.sictiam.dev.entrouvert.org", |
|
60 |
"combo": "instance-name.sictiam.dev.entrouvert.org", |
|
61 |
"combo_agent": "agents-instance-name.sictiam.dev.entrouvert.org", |
|
62 |
"fargo": "porte-documents-instance-name.sictiam.dev.entrouvert.org", |
|
63 |
"hobo": "hobo-instance-name.sictiam.dev.entrouvert.org", |
|
64 |
"passerelle": "passerelle-instance-name.sictiam.dev.entrouvert.org", |
|
65 |
"wcs": "demarches-instance-name.sictiam.dev.entrouvert.org" |
|
66 |
} |
|
67 |
} |
tests_schemas/test_cook.py | ||
---|---|---|
1 | 1 |
import pytest |
2 |
import mock |
|
2 | 3 | |
3 |
from django.core.management import call_command |
|
4 |
from django.core.management import call_command, load_command_class
|
|
4 | 5 |
from django.core.management.base import CommandError |
5 | 6 | |
7 |
from hobo.deploy.utils import get_hobo_json |
|
6 | 8 |
from hobo.environment.models import ServiceBase |
7 | 9 | |
8 | 10 | |
... | ... | |
18 | 20 |
with pytest.raises(CommandError) as e_info: |
19 | 21 |
call_command('cook', 'tests_schemas/recipe.json') |
20 | 22 |
assert 'is not resolvable' in str(e_info.value) |
23 | ||
24 | ||
25 |
def test_cook_ozwillo(db, fake_notify, monkeypatch, fake_themes): |
|
26 |
"""hobo/cook (before rabbitmq) scenario having templates. |
|
27 |
(cf hobo/contrib/ozwillo/examples) |
|
28 |
the resulting JSON may be helpfull to test hobo/deploy (after rabbitmq) |
|
29 |
ex: import json; json.dump(environment, open('/tmp/ozwillo_env.json', 'w')) |
|
30 |
""" |
|
31 |
monkeypatch.setattr(ServiceBase, 'is_resolvable', lambda x: True) |
|
32 |
monkeypatch.setattr(ServiceBase, 'has_valid_certificate', lambda x: True) |
|
33 |
call_command('cook', 'tests_schemas/ozwillo_recipe.json') |
|
34 |
assert len(fake_notify) == 7 |
|
35 |
environment = get_hobo_json() |
|
36 |
assert environment['services'][4]['template_name'] == 'portal-user' |
|
21 |
- |