Projet

Général

Profil

0003-hobo_deploy-do-not-recall-import_template-when-it-pr.patch

Nicolas Roche, 21 juin 2019 18:22

Télécharger (3,79 ko)

Voir les différences:

Subject: [PATCH 3/3] hobo_deploy: do not recall import_template when it
 previously success (#33875)

 .../common/management/commands/import_template.py      |  2 +-
 tests/test_import_template.py                          | 10 ++++++----
 tests_schemas/test_import_template.py                  |  6 ++++--
 3 files changed, 11 insertions(+), 7 deletions(-)
hobo/agent/common/management/commands/import_template.py
40 40
            if not os.path.exists(template):
41 41
                raise UnknownTemplateError('unknown template (%r)' % template)
42 42
            else:
43
                call_command('import_site', template)
43
                call_command('import_site', template, if_empty=True)
tests/test_import_template.py
21 21
    # simulate:
22 22
    # $ XXX-manage import-template import_me
23 23
    command = Command()
24
    with override_settings(PROJECT_NAME='bobo'):
24
    with override_settings(PROJECT_NAME='hobo'):
25 25
        command.handle(template_name='import_me')
26 26

  
27 27
    # assert 'import_site' command is run
28 28
    assert mocked_call_command.mock_calls == [
29
        mock.call('import_site', '/var/lib/bobo/skeletons/import_me.json')]
29
        mock.call('import_site', '/var/lib/hobo/skeletons/import_me.json',
30
                  if_empty=True)]
31

  
30 32

  
31 33
@mock.patch('hobo.agent.common.management.commands.import_template.os.path.exists')
32 34
@mock.patch('hobo.agent.common.management.commands.import_template.call_command')
......
40 42
    # simulate:
41 43
    # $ XXX-manage import-template import_me --basepath /tmp
42 44
    command = Command()
43
    with override_settings(PROJECT_NAME='bobo'):
45
    with override_settings(PROJECT_NAME='hobo'):
44 46
        command.handle(template_name='import_me', basepath='/tmp')
45 47

  
46 48
    # assert 'import_site' command is run
47 49
    assert mocked_call_command.mock_calls == [
48
        mock.call('import_site', '/tmp/import_me.json')]
50
        mock.call('import_site', '/tmp/import_me.json', if_empty=True)]
49 51

  
50 52

  
51 53
@mock.patch('hobo.agent.common.management.commands.import_template.os.path.exists')
tests_schemas/test_import_template.py
21 21
        handler.write('...')
22 22

  
23 23
    command.handle(basepath=str(tmpdir), template_name='my-template')
24
    assert mocked_call_command.mock_calls == [mock.call('import_site', template_path)]
24
    assert mocked_call_command.mock_calls == [
25
        mock.call('import_site', template_path, if_empty=True)]
25 26

  
26 27

  
27 28
@mock.patch('hobo.agent.common.management.commands.import_template.call_command')
......
39 40
        handler.write('...')
40 41

  
41 42
    command.handle(basepath=str(tmpdir), template_name='my-template')
42
    assert mocked_call_command.mock_calls == [mock.call('import_site', template_path)]
43
    assert mocked_call_command.mock_calls == [
44
        mock.call('import_site', template_path, if_empty=True)]
43
-