0001-hobo_deploy-code-revue-on-import_template-function-f.patch
hobo/agent/common/management/commands/hobo_deploy.py | ||
---|---|---|
98 | 98 |
self.generate_saml_keys(tenant, prefix='sp-') |
99 | 99 |
self.configure_service_provider(hobo_environment, tenant) |
100 | 100 |
self.configure_theme(hobo_environment, tenant) |
101 |
self.configure_template(hobo_environment, tenant)
|
|
101 |
self.configure_template() |
|
102 | 102 | |
103 | 103 |
def generate_saml_keys(self, tenant, prefix=''): |
104 | 104 | |
... | ... | |
188 | 188 |
theme.get('overlay'), part) |
189 | 189 |
atomic_symlink(target_dir, os.path.join(tenant_dir, part)) |
190 | 190 | |
191 |
def configure_template(self, hobo_environment, tenant): |
|
192 |
me = [x for x in hobo_environment.get('services') if x.get('this') is True][0] |
|
193 | ||
194 |
if 'import_template' in get_commands() and me.get('template_name'): |
|
195 |
call_command('import_template', me['template_name']) |
|
191 |
def configure_template(self): |
|
192 |
if self.me.get('template_name'): |
|
193 |
call_command('import_template', self.me['template_name']) |
tests/test_hobo_deploy.py | ||
---|---|---|
225 | 225 |
assert command.generate_saml_keys.mock_calls == [call('my_tenant', prefix='sp-')] |
226 | 226 |
assert command.configure_service_provider.mock_calls == [call('my_hobo_env', 'my_tenant')] |
227 | 227 |
assert command.configure_theme.mock_calls == [call('my_hobo_env', 'my_tenant')] |
228 |
assert command.configure_template.mock_calls == [call('my_hobo_env', 'my_tenant')]
|
|
228 |
assert command.configure_template.mock_calls == [call()] |
|
229 | 229 | |
230 | 230 | |
231 | 231 |
def test_generate_saml_keys(tmpdir): |
... | ... | |
385 | 385 |
@patch('hobo.agent.common.management.commands.hobo_deploy.call_command') |
386 | 386 |
def test_configure_template(mocked_call_command, mocked_get_commands): |
387 | 387 |
command = Command() |
388 |
ENVIRONMENT = {'services': [{'service-id': 'combo',
|
|
389 |
'template_name': 'my_template',
|
|
390 |
'this': True}]}
|
|
388 |
command.me = {'service-id': 'combo',
|
|
389 |
'template_name': 'my_template', |
|
390 |
'this': True}
|
|
391 | 391 | |
392 |
# import_template.py located into hobo/agent/common: always belongs to command object |
|
393 |
# TODO: dead condition |
|
394 | 392 |
mocked_get_commands.return_value = ['import_template', '...'] |
395 | 393 | |
396 | 394 |
# main case |
397 |
command.configure_template(ENVIRONMENT, 'unused') # TODO: dead tenant parameter
|
|
395 |
command.configure_template()
|
|
398 | 396 |
assert mocked_call_command.mock_calls == [call('import_template', 'my_template')] |
399 | 397 | |
400 | 398 |
# no template_name entry provided |
401 | 399 |
mocked_call_command.reset_mock() |
402 |
del ENVIRONMENT['services'][0]['template_name']
|
|
403 |
command.configure_template(ENVIRONMENT, 'unused')
|
|
400 |
del command.me['template_name']
|
|
401 |
command.configure_template() |
|
404 | 402 |
assert mocked_call_command.mock_calls == [] |
405 | 403 | |
406 | 404 |
tests_schemas/test_hobo_deploy.py | ||
---|---|---|
79 | 79 |
# here, because this code is not implemented here |
80 | 80 | |
81 | 81 | |
82 |
def test_get_theme_on_combo_agent(db): |
|
82 |
@mock.patch('hobo.agent.common.management.commands.hobo_deploy.call_command') |
|
83 |
def test_get_theme_on_combo_agent(mocked_call_command, db): |
|
83 | 84 |
"""overloaded case for combo: |
84 | 85 |
$ combo-manage hobo-deploy env.json # simulate this bash query |
85 | 86 |
""" |
86 | 87 |
command = load_command_class('hobo.agent.combo', 'hobo_deploy') |
87 | 88 |
domain = 'combo.dev.publik.love' |
89 | ||
90 |
def my_call_command(command, parameter): |
|
91 |
if command == 'import_template': |
|
92 |
my_call_command.import_template_was_called = True |
|
93 |
return |
|
94 |
call_command(command, parameter) |
|
95 | ||
96 |
mocked_call_command.side_effect = my_call_command |
|
88 | 97 |
command.handle('https://%s/' % domain, 'tests_schemas/env.json') |
89 | 98 |
assert_deployed(domain) |
90 | 99 |
# lack an assert statement proving we do reach |
91 |
- |