cook: correct reression on cook action using several args (#32687)
This commit is contained in:
parent
362af52cdd
commit
f3feefca2b
|
@ -78,9 +78,9 @@ class Command(BaseCommand):
|
||||||
continue
|
continue
|
||||||
action_args[arg] = string.Template(
|
action_args[arg] = string.Template(
|
||||||
action_args[arg]).substitute(variables)
|
action_args[arg]).substitute(variables)
|
||||||
if not self.permissive:
|
if not self.permissive:
|
||||||
self.check_action(action, action_args)
|
self.check_action(action, action_args)
|
||||||
steps.append((action, action_args))
|
steps.append((action, action_args))
|
||||||
|
|
||||||
for action, action_args in steps:
|
for action, action_args in steps:
|
||||||
getattr(self, action.replace('-', '_'))(**action_args)
|
getattr(self, action.replace('-', '_'))(**action_args)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
import mock
|
||||||
|
import StringIO
|
||||||
|
|
||||||
from django.core.management.base import CommandError
|
from django.core.management.base import CommandError
|
||||||
|
|
||||||
|
@ -52,3 +54,24 @@ def test_check_action_invalid_certificat(monkeypatch):
|
||||||
with pytest.raises(CommandError) as e_info:
|
with pytest.raises(CommandError) as e_info:
|
||||||
command.check_action(action, action_args)
|
command.check_action(action, action_args)
|
||||||
assert 'has no valid certificate' in str(e_info.value)
|
assert 'has no valid certificate' in str(e_info.value)
|
||||||
|
|
||||||
|
@mock.patch('hobo.environment.management.commands.cook.open')
|
||||||
|
def test_having_several_action_args(mocked_open):
|
||||||
|
"""load variables from a file"""
|
||||||
|
receipe = """{
|
||||||
|
"steps": [
|
||||||
|
{"create-authentic": {
|
||||||
|
"url": "https://entrouvert.org/",
|
||||||
|
"title": "Connexion"
|
||||||
|
}}
|
||||||
|
]
|
||||||
|
}"""
|
||||||
|
expected_a2 = "[call(title=u'Connexion', url=u'https://entrouvert.org/')]"
|
||||||
|
|
||||||
|
command = Command()
|
||||||
|
command.permissive = True
|
||||||
|
command.create_authentic = mock.MagicMock()
|
||||||
|
|
||||||
|
mocked_open.side_effect = [StringIO.StringIO(receipe)]
|
||||||
|
command.run_cook('recipe_me.json')
|
||||||
|
assert str(command.create_authentic.mock_calls) == expected_a2
|
||||||
|
|
Loading…
Reference in New Issue