Compare commits
2 Commits
main
...
wip/33875-
Author | SHA1 | Date |
---|---|---|
Nicolas Roche | 88d57780bc | |
Nicolas Roche | e1c34b3b63 |
|
@ -93,13 +93,14 @@ class Command(BaseCommand):
|
|||
if not self.me.get('secondary'):
|
||||
replace_file(tenant_hobo_json, json.dumps(hobo_environment, indent=2))
|
||||
|
||||
self.configure_template(hobo_environment, tenant)
|
||||
|
||||
def deploy_specifics(self, hobo_environment, tenant):
|
||||
# configure things that are quite common but may actually not be
|
||||
# common to *all* tenants.
|
||||
self.generate_saml_keys(tenant, prefix='sp-')
|
||||
self.configure_service_provider(hobo_environment, tenant)
|
||||
self.configure_theme(hobo_environment, tenant)
|
||||
self.configure_template(hobo_environment, tenant)
|
||||
|
||||
def generate_saml_keys(self, tenant, prefix=''):
|
||||
|
||||
|
|
|
@ -40,4 +40,4 @@ class Command(BaseCommand):
|
|||
if not os.path.exists(template):
|
||||
raise UnknownTemplateError('unknown template (%r)' % template)
|
||||
else:
|
||||
call_command('import_site', template)
|
||||
call_command('import_site', template, if_empty=True)
|
||||
|
|
|
@ -162,6 +162,7 @@ def test_deploy(mocked_get_tenant_by_hostname, tmpdir):
|
|||
command.deploy_specifics = Mock()
|
||||
tenant = Mock()
|
||||
tenant.get_directory = Mock(return_value=str(tmpdir))
|
||||
command.configure_template = Mock()
|
||||
base_url = 'https://combo.dev.publik.love/'
|
||||
tenant_hobo_json = os.path.join(str(tmpdir), 'hobo.json')
|
||||
ENVIRONMENT = {'services': [{'service-id': 'combo', 'base_url': base_url}],
|
||||
|
@ -179,6 +180,8 @@ def test_deploy(mocked_get_tenant_by_hostname, tmpdir):
|
|||
content = json.load(handler)
|
||||
assert ENVIRONMENT['services'][0]['this'] is True # new entry added
|
||||
assert json.dumps(content, sort_keys=True), json.dumps(ENVIRONMENT, sort_keys=True)
|
||||
assert command.configure_template.mock_calls == [call(ENVIRONMENT, tenant)]
|
||||
command.configure_template.reset_mock()
|
||||
|
||||
# create tenant first
|
||||
command.deploy_specifics.reset_mock()
|
||||
|
@ -218,13 +221,11 @@ def test_deploy_specific():
|
|||
command.generate_saml_keys = Mock()
|
||||
command.configure_service_provider = Mock()
|
||||
command.configure_theme = Mock()
|
||||
command.configure_template = Mock()
|
||||
|
||||
command.deploy_specifics('my_hobo_env', 'my_tenant')
|
||||
assert command.generate_saml_keys.mock_calls == [call('my_tenant', prefix='sp-')]
|
||||
assert command.configure_service_provider.mock_calls == [call('my_hobo_env', 'my_tenant')]
|
||||
assert command.configure_theme.mock_calls == [call('my_hobo_env', 'my_tenant')]
|
||||
assert command.configure_template.mock_calls == [call('my_hobo_env', 'my_tenant')]
|
||||
|
||||
|
||||
def test_generate_saml_keys(tmpdir):
|
||||
|
|
|
@ -21,12 +21,14 @@ def test_import_template_default(mocked_get_commands, mocked_call_command, mocke
|
|||
# simulate:
|
||||
# $ XXX-manage import-template import_me
|
||||
command = Command()
|
||||
with override_settings(PROJECT_NAME='bobo'):
|
||||
with override_settings(PROJECT_NAME='hobo'):
|
||||
command.handle(template_name='import_me')
|
||||
|
||||
# assert 'import_site' command is run
|
||||
assert mocked_call_command.mock_calls == [
|
||||
mock.call('import_site', '/var/lib/bobo/skeletons/import_me.json')]
|
||||
mock.call('import_site', '/var/lib/hobo/skeletons/import_me.json',
|
||||
if_empty=True)]
|
||||
|
||||
|
||||
@mock.patch('hobo.agent.common.management.commands.import_template.os.path.exists')
|
||||
@mock.patch('hobo.agent.common.management.commands.import_template.call_command')
|
||||
|
@ -40,12 +42,12 @@ def test_import_template_basepath(mocked_get_commands, mocked_call_command, mock
|
|||
# simulate:
|
||||
# $ XXX-manage import-template import_me --basepath /tmp
|
||||
command = Command()
|
||||
with override_settings(PROJECT_NAME='bobo'):
|
||||
with override_settings(PROJECT_NAME='hobo'):
|
||||
command.handle(template_name='import_me', basepath='/tmp')
|
||||
|
||||
# assert 'import_site' command is run
|
||||
assert mocked_call_command.mock_calls == [
|
||||
mock.call('import_site', '/tmp/import_me.json')]
|
||||
mock.call('import_site', '/tmp/import_me.json', if_empty=True)]
|
||||
|
||||
|
||||
@mock.patch('hobo.agent.common.management.commands.import_template.os.path.exists')
|
||||
|
|
|
@ -21,7 +21,8 @@ def test_import_template_on_common_agent(mocked_get_commands, mocked_call_comman
|
|||
handler.write('...')
|
||||
|
||||
command.handle(basepath=str(tmpdir), template_name='my-template')
|
||||
assert mocked_call_command.mock_calls == [mock.call('import_site', template_path)]
|
||||
assert mocked_call_command.mock_calls == [
|
||||
mock.call('import_site', template_path, if_empty=True)]
|
||||
|
||||
|
||||
@mock.patch('hobo.agent.common.management.commands.import_template.call_command')
|
||||
|
@ -39,4 +40,5 @@ def test_import_template_on_combo_agent(mocked_get_commands, mocked_call_command
|
|||
handler.write('...')
|
||||
|
||||
command.handle(basepath=str(tmpdir), template_name='my-template')
|
||||
assert mocked_call_command.mock_calls == [mock.call('import_site', template_path)]
|
||||
assert mocked_call_command.mock_calls == [
|
||||
mock.call('import_site', template_path, if_empty=True)]
|
||||
|
|
Loading…
Reference in New Issue