cook: set publik as theme if none are defined (#73111) #53
|
@ -51,7 +51,7 @@ from hobo.environment.utils import wait_operationals
|
|||
from hobo.environment.validators import validate_service_url
|
||||
from hobo.multitenant.middleware import TenantMiddleware
|
||||
from hobo.profile.models import AttributeDefinition
|
||||
from hobo.theme.utils import set_theme
|
||||
from hobo.theme.utils import get_theme, set_theme
|
||||
|
||||
|
||||
def get_domain(url):
|
||||
|
@ -113,6 +113,12 @@ class Command(BaseCommand):
|
|||
notify_agents(None)
|
||||
self.wait_operationals(timeout=self.timeout)
|
||||
self.must_notify = False
|
||||
|
||||
if not Variable.objects.filter(name='theme', service_pk__isnull=True).exists() and get_theme(
|
||||
'publik'
|
||||
):
|
||||
self.set_theme('publik')
|
||||
|
||||
notify_agents(None)
|
||||
|
||||
def wait_operationals(self, timeout):
|
||||
|
|
|
@ -100,7 +100,7 @@ def test_check_action_invalid_certificat(command, monkeypatch):
|
|||
assert 'no valid certificate for https://test.org/' in str(e_info.value)
|
||||
|
||||
|
||||
def test_check_action_disabled_service(command, cook):
|
||||
def test_check_action_disabled_service(command, cook, db):
|
||||
recipe = {'steps': [{'create-bijoe': {'url': 'https://entrouvert.org/', 'title': 'Statistiques'}}]}
|
||||
with pytest.raises(CommandError, match='service class "BiJoe" is disabled'):
|
||||
cook(recipe)
|
||||
|
@ -119,7 +119,7 @@ def test_handle(command):
|
|||
assert command.run_cook.mock_calls == [call('recipe.json')]
|
||||
|
||||
|
||||
def test_run_cook(command, cook, mocked_notify_agents):
|
||||
def test_run_cook(command, cook, mocked_notify_agents, db):
|
||||
command.must_notify = True
|
||||
command.check_action = Mock()
|
||||
command.create_hobo = Mock()
|
||||
|
@ -134,14 +134,14 @@ def test_run_cook(command, cook, mocked_notify_agents):
|
|||
assert command.wait_operationals.mock_calls == [call(timeout=42)]
|
||||
|
||||
|
||||
def test_having_several_action_args(command, cook):
|
||||
def test_having_several_action_args(command, cook, db):
|
||||
command.create_authentic = Mock()
|
||||
recipe = {'steps': [{'create-authentic': {'url': 'https://entrouvert.org/', 'title': 'Connexion'}}]}
|
||||
cook(recipe, permissive=True)
|
||||
assert command.create_authentic.mock_calls == [call(title='Connexion', url='https://entrouvert.org/')]
|
||||
|
||||
|
||||
def test_load_variables_from(command, cook, tmpdir):
|
||||
def test_load_variables_from(command, cook, tmpdir, db):
|
||||
"""load variables from a file"""
|
||||
command.create_hobo = Mock()
|
||||
command.create_authentic = Mock()
|
||||
|
|
|
@ -8,11 +8,12 @@ from hobo.deploy.utils import get_hobo_json
|
|||
from hobo.environment import models as environment_models
|
||||
|
||||
|
||||
def test_cook(db, fake_notify, monkeypatch):
|
||||
def test_cook(db, fake_notify, monkeypatch, fake_themes):
|
||||
monkeypatch.setattr(environment_models, 'is_resolvable', lambda x: True)
|
||||
monkeypatch.setattr(environment_models, 'has_valid_certificate', lambda x: True)
|
||||
call_command('cook', 'tests_schemas/recipe.json')
|
||||
assert len(fake_notify) == 3
|
||||
assert get_hobo_json().get('variables').get('theme') == 'publik'
|
||||
|
||||
|
||||
def test_cook_unresolvable(db, fake_notify, monkeypatch):
|
||||
|
|
Loading…
Reference in New Issue