Projet

Général

Profil

0001-cook-correct-reression-on-cook-action-using-several-.patch

Nicolas Roche, 29 avril 2019 19:33

Télécharger (2,37 ko)

Voir les différences:

Subject: [PATCH] cook: correct reression on cook action using several args
 (#32687)

 hobo/environment/management/commands/cook.py |  6 ++---
 tests/test_cook.py                           | 23 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)
hobo/environment/management/commands/cook.py
78 78
                    continue
79 79
                action_args[arg] = string.Template(
80 80
                        action_args[arg]).substitute(variables)
81
                if not self.permissive:
82
                    self.check_action(action, action_args)
83
                steps.append((action, action_args))
81
            if not self.permissive:
82
                self.check_action(action, action_args)
83
            steps.append((action, action_args))
84 84

  
85 85
        for action, action_args in steps:
86 86
            getattr(self, action.replace('-', '_'))(**action_args)
tests/test_cook.py
1 1
import pytest
2
import mock
3
import StringIO
2 4

  
3 5
from django.core.management.base import CommandError
4 6

  
......
52 54
    with pytest.raises(CommandError) as e_info:
53 55
        command.check_action(action, action_args)
54 56
    assert 'has no valid certificate' in str(e_info.value)
57

  
58
@mock.patch('hobo.environment.management.commands.cook.open')
59
def test_having_several_action_args(mocked_open):
60
    """load variables from a file"""
61
    receipe = """{
62
  "steps": [
63
    {"create-authentic": {
64
      "url": "https://entrouvert.org/",
65
      "title": "Connexion"
66
    }}
67
  ]
68
}"""
69
    expected_a2 = "[call(title=u'Connexion', url=u'https://entrouvert.org/')]"
70

  
71
    command = Command()
72
    command.permissive = True
73
    command.create_authentic = mock.MagicMock()
74

  
75
    mocked_open.side_effect = [StringIO.StringIO(receipe)]
76
    command.run_cook('recipe_me.json')
77
    assert str(command.create_authentic.mock_calls) == expected_a2
55
-