diff --git a/hobo/agent/common/management/commands/import_template.py b/hobo/agent/common/management/commands/import_template.py index c30f9f3..a39fedb 100644 --- a/hobo/agent/common/management/commands/import_template.py +++ b/hobo/agent/common/management/commands/import_template.py @@ -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) diff --git a/tests/test_import_template.py b/tests/test_import_template.py index 425246c..4ccdd13 100644 --- a/tests/test_import_template.py +++ b/tests/test_import_template.py @@ -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') diff --git a/tests_schemas/test_import_template.py b/tests_schemas/test_import_template.py index 7fdc8fa..a577d66 100644 --- a/tests_schemas/test_import_template.py +++ b/tests_schemas/test_import_template.py @@ -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)]