0002-cook-add-tests-using-tenants-for-cook.py-32886.patch
tests_schemas/template_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 | |
... | ... | |
10 | 12 |
monkeypatch.setattr(ServiceBase, 'is_resolvable', lambda x: True) |
11 | 13 |
monkeypatch.setattr(ServiceBase, 'has_valid_certificate', lambda x: True) |
12 | 14 |
call_command('cook', 'tests_schemas/recipe.json') |
13 |
assert(len(fake_notify) == 3) |
|
14 | ||
15 |
assert len(fake_notify) == 3 |
|
15 | 16 | |
16 | 17 |
def test_cook_unresolvable(db, fake_notify, monkeypatch): |
17 | 18 |
monkeypatch.setattr(ServiceBase, 'is_resolvable', lambda x: False) |
18 | 19 |
with pytest.raises(CommandError) as e_info: |
19 | 20 |
call_command('cook', 'tests_schemas/recipe.json') |
20 | 21 |
assert 'is not resolvable' in str(e_info.value) |
22 | ||
23 |
def test_cook_ozwillo(db, fake_notify, monkeypatch): |
|
24 |
"""hobo/cook (before rabbitmq) ozwillo scenario having templates. |
|
25 |
the resulting json will be helpfull to test hobo/deploy (after rabbitmq) |
|
26 |
""" |
|
27 |
monkeypatch.setattr(ServiceBase, 'is_resolvable', lambda x: True) |
|
28 |
monkeypatch.setattr(ServiceBase, 'has_valid_certificate', lambda x: True) |
|
29 |
call_command('cook', 'tests_schemas/template_recipe.json') |
|
30 |
assert(len(fake_notify) == 7) |
|
31 |
environment = get_hobo_json() |
|
32 |
assert environment['services'][4]['template_name'] == 'portal-user' |
|
33 | ||
34 |
def test_cook_function(db, fake_notify, monkeypatch): |
|
35 |
"""TODO: looks like dead code""" |
|
36 |
monkeypatch.setattr(ServiceBase, 'is_resolvable', lambda x: True) |
|
37 |
monkeypatch.setattr(ServiceBase, 'has_valid_certificate', lambda x: True) |
|
38 |
command = load_command_class('hobo.environment', 'cook') |
|
39 |
with pytest.raises(AttributeError) as e_info: |
|
40 |
command.cook('tests_schemas/template_recipe.json') |
|
41 |
assert len(fake_notify) == 0 |
|
42 | ||
21 |
- |