0001-hobo_deploy-get-current-service-from-attribute-on-co.patch
hobo/agent/common/management/commands/hobo_deploy.py | ||
---|---|---|
99 | 99 |
self.generate_saml_keys(tenant, prefix='sp-') |
100 | 100 |
self.configure_service_provider(hobo_environment, tenant) |
101 | 101 |
self.configure_theme(hobo_environment, tenant) |
102 |
self.configure_template(hobo_environment, tenant)
|
|
102 |
self.configure_template(tenant) |
|
103 | 103 | |
104 | 104 |
def generate_saml_keys(self, tenant, prefix=''): |
105 | 105 | |
... | ... | |
189 | 189 |
theme.get('overlay'), part) |
190 | 190 |
atomic_symlink(target_dir, os.path.join(tenant_dir, part)) |
191 | 191 | |
192 |
def configure_template(self, hobo_environment, tenant): |
|
193 |
me = [x for x in hobo_environment.get('services') if x.get('this') is True][0] |
|
194 | ||
195 |
if 'import_template' in get_commands() and me.get('template_name'): |
|
192 |
def configure_template(self, tenant): |
|
193 |
if self.me.get('template_name'): |
|
196 | 194 |
with tenant_context(tenant): |
197 |
call_command('import_template', me['template_name']) |
|
195 |
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): |
... | ... | |
388 | 388 |
mocked_get_commands): |
389 | 389 |
command = Command() |
390 | 390 |
tenant = Mock() |
391 |
ENVIRONMENT = {'services': [{'service-id': 'combo', |
|
392 |
'template_name': 'my_template', |
|
393 |
'this': True}]} |
|
394 | ||
395 |
# import_template.py located into hobo/agent/common: always belongs to command object |
|
396 |
# TODO: dead condition |
|
391 |
command.me = {'service-id': 'combo', |
|
392 |
'template_name': 'my_template', |
|
393 |
'this': True} |
|
397 | 394 |
mocked_get_commands.return_value = ['import_template', '...'] |
398 | 395 | |
399 | 396 |
# main case |
400 |
command.configure_template(ENVIRONMENT, tenant)
|
|
397 |
command.configure_template(tenant) |
|
401 | 398 |
assert mocked_call_command.mock_calls == [call('import_template', 'my_template')] |
402 | 399 | |
403 | 400 |
# no template_name entry provided |
404 | 401 |
mocked_call_command.reset_mock() |
405 |
del ENVIRONMENT['services'][0]['template_name']
|
|
406 |
command.configure_template(ENVIRONMENT, tenant)
|
|
402 |
del command.me['template_name']
|
|
403 |
command.configure_template(tenant) |
|
407 | 404 |
assert mocked_call_command.mock_calls == [] |
408 | 405 | |
409 | 406 | |
410 |
- |