hobo_deploy: do not recall import_template when it previously success (#33875)
gitea-wip/hobo/pipeline/head There was a failure building this commit Details
gitea/hobo/pipeline/head Build started... Details

This commit is contained in:
Nicolas Roche 2019-06-13 12:43:19 +02:00
parent e1c34b3b63
commit 88d57780bc
3 changed files with 11 additions and 7 deletions

View File

@ -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)

View File

@ -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')

View File

@ -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)]