Projet

Général

Profil

0001-export-workflow-status-as-a-list-not-a-dict-10807.patch

Benjamin Dauvergne, 03 mai 2016 12:16

Télécharger (3,37 ko)

Voir les différences:

Subject: [PATCH] export workflow status as a list not a dict (#10807)

 help/fr/api-schema.page | 13 ++++++++-----
 tests/test_workflows.py | 17 ++++++++++-------
 wcs/workflows.py        |  7 ++++---
 3 files changed, 22 insertions(+), 15 deletions(-)
help/fr/api-schema.page
186 186
        "name": "Workflow Newsletter",
187 187
        "id": "1",
188 188
        "last_modification_time": "2015-12-12T10:20:45",
189
        "statuses": {
190
            "1": {
189
        "statuses": [
190
            {
191
                "id": "1",
191 192
                "name": "Nouveau",
192 193
                "forced_endpoint": false
193 194
            },
194
            "2": {
195
            {
196
                "id": "1",
195 197
                "name": "En cours",
196 198
                "forced_endpoint": false
197 199
            },
198
            "3": {
200
            {
201
                "id": "1",
199 202
                "name": "Terminé",
200 203
                "forced_endpoint": false
201 204
            }
202
        }
205
        ]
203 206
    }
204 207
}
205 208
</code>
tests/test_workflows.py
75 75
    assert set(root.keys()) >= set(['statuses', 'name', 'functions'])
76 76

  
77 77
    assert root['name'] == 'wf'
78
    assert set(root['statuses'].keys()) == set(['st1', 'st2'])
79
    assert all(set(status.keys()) >= set(['name', 'forced_endpoint']) for status in
80
               root['statuses'].values())
81
    assert root['statuses']['st1']['name'] == 'Status1'
82
    assert root['statuses']['st1']['forced_endpoint'] is False
83
    assert root['statuses']['st2']['name'] == 'Status2'
84
    assert root['statuses']['st2']['forced_endpoint'] is True
78
    assert len(root['statuses']) == 2
79
    assert set(st['id'] for st in root['statuses']) == set(['st1', 'st2'])
80
    assert all(set(status.keys()) >= set(['id', 'name', 'forced_endpoint']) for status in
81
               root['statuses'])
82
    assert root['statuses'][0]['id'] == 'st1'
83
    assert root['statuses'][0]['name'] == 'Status1'
84
    assert root['statuses'][0]['forced_endpoint'] is False
85
    assert root['statuses'][1]['id'] == 'st2'
86
    assert root['statuses'][1]['name'] == 'Status2'
87
    assert root['statuses'][1]['forced_endpoint'] is True
85 88

  
86 89
def test_jump_nothing(pub):
87 90
    FormDef.wipe()
wcs/workflows.py
572 572
        roles = root['functions'] = {}
573 573
        for role, label in self.roles.iteritems():
574 574
            roles[role] = unicode(label, charset)
575
        statuses = root['statuses'] = {}
575
        statuses = root['statuses'] = []
576 576
        for status in self.possible_status:
577
            statuses[status.id] = {
577
            statuses.append({
578
                'id': status.id,
578 579
                'name': unicode(status.name, charset),
579 580
                'forced_endpoint': status.forced_endpoint,
580
            }
581
            })
581 582
        return root
582 583

  
583 584
    @classmethod
584
-