Projet

Général

Profil

0002-hobo_deploy-write-hobo.json-even-if-import_template-.patch

Nicolas Roche, 12 juin 2019 20:22

Télécharger (3,09 ko)

Voir les différences:

Subject: [PATCH 2/2] hobo_deploy: write hobo.json even if import_template
 fails

 hobo/agent/common/management/commands/hobo_deploy.py | 3 ++-
 tests/test_hobo_deploy.py                            | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)
hobo/agent/common/management/commands/hobo_deploy.py
92 92
        if not self.me.get('secondary'):
93 93
            replace_file(tenant_hobo_json, json.dumps(hobo_environment, indent=2))
94 94

  
95
        self.configure_template(hobo_environment, tenant)
96

  
95 97
    def deploy_specifics(self, hobo_environment, tenant):
96 98
        # configure things that are quite common but may actually not be
97 99
        # common to *all* tenants.
98 100
        self.generate_saml_keys(tenant, prefix='sp-')
99 101
        self.configure_service_provider(hobo_environment, tenant)
100 102
        self.configure_theme(hobo_environment, tenant)
101
        self.configure_template(hobo_environment, tenant)
102 103

  
103 104
    def generate_saml_keys(self, tenant, prefix=''):
104 105

  
tests/test_hobo_deploy.py
163 163
    command.deploy_specifics = Mock()
164 164
    tenant = Mock()
165 165
    tenant.get_directory = Mock(return_value=str(tmpdir))
166
    command.configure_template = Mock()
166 167
    base_url = 'https://combo.dev.publik.love/'
167 168
    tenant_hobo_json = os.path.join(str(tmpdir), 'hobo.json')
168 169
    ENVIRONMENT = {'services': [{'service-id': 'combo', 'base_url': base_url}],
......
180 181
            content = json.load(handler)
181 182
        assert ENVIRONMENT['services'][0]['this'] is True  # new entry added
182 183
        assert json.dumps(content, sort_keys=True), json.dumps(ENVIRONMENT, sort_keys=True)
184
        assert command.configure_template.mock_calls == [call(ENVIRONMENT, tenant)]
185
        command.configure_template.reset_mock()
183 186

  
184 187
    # create tenant first
185 188
    command.deploy_specifics.reset_mock()
......
219 222
    command.generate_saml_keys = Mock()
220 223
    command.configure_service_provider = Mock()
221 224
    command.configure_theme = Mock()
222
    command.configure_template = Mock()
223 225

  
224 226
    command.deploy_specifics('my_hobo_env', 'my_tenant')
225 227
    assert command.generate_saml_keys.mock_calls == [call('my_tenant', prefix='sp-')]
226 228
    assert command.configure_service_provider.mock_calls == [call('my_hobo_env', 'my_tenant')]
227 229
    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')]
229 230

  
230 231

  
231 232
def test_generate_saml_keys(tmpdir):
232
-