Projet

Général

Profil

0001-api-export-if-a-status-is-an-endpoint-10904.patch

Benjamin Dauvergne, 12 mai 2016 16:43

Télécharger (2,26 ko)

Voir les différences:

Subject: [PATCH] api: export if a status is an endpoint (#10904)

 tests/test_workflows.py | 11 +++++++++++
 wcs/workflows.py        |  2 ++
 2 files changed, 13 insertions(+)
tests/test_workflows.py
75 75
    st1 = workflow.add_status('Status1', 'st1')
76 76
    st2 = workflow.add_status('Status2', 'st2')
77 77
    st2.forced_endpoint = True
78

  
79
    jump = JumpWorkflowStatusItem()
80
    jump.id = '_jump'
81
    jump.by = ['_submitter', '_receiver']
82
    jump.timeout = 0.1
83
    jump.status = 'st2'
84
    st1.items.append(jump)
85
    jump.parent = st1
86

  
78 87
    workflow.roles['_other'] = 'Other Function'
79 88
    root = workflow.get_json_export_dict()
80 89
    assert set(root.keys()) >= set(['statuses', 'name', 'functions'])
......
87 96
    assert root['statuses'][0]['id'] == 'st1'
88 97
    assert root['statuses'][0]['name'] == 'Status1'
89 98
    assert root['statuses'][0]['forced_endpoint'] is False
99
    assert root['statuses'][0]['endpoint'] is False
90 100
    assert root['statuses'][1]['id'] == 'st2'
91 101
    assert root['statuses'][1]['name'] == 'Status2'
92 102
    assert root['statuses'][1]['forced_endpoint'] is True
103
    assert root['statuses'][1]['endpoint'] is True
93 104

  
94 105
def test_jump_nothing(pub):
95 106
    FormDef.wipe()
wcs/workflows.py
573 573
        for role, label in self.roles.iteritems():
574 574
            roles[role] = unicode(label, charset)
575 575
        statuses = root['statuses'] = []
576
        endpoint_status_ids = [s.id for s in self.get_endpoint_status()]
576 577
        for status in self.possible_status:
577 578
            statuses.append({
578 579
                'id': status.id,
579 580
                'name': unicode(status.name, charset),
580 581
                'forced_endpoint': status.forced_endpoint,
582
                'endpoint': status.id in endpoint_status_ids,
581 583
            })
582 584
        return root
583 585

  
584
-