0001-fix-non-determinism-when-importing-wscall-workflow-a.patch
tests/test_workflow_import.py | ||
---|---|---|
2 | 2 |
import shutil |
3 | 3 |
import StringIO |
4 | 4 |
import xml.etree.ElementTree as ET |
5 |
from collections import OrderedDict |
|
5 | 6 | |
6 | 7 |
from quixote import cleanup |
7 | 8 |
from wcs import publisher |
... | ... | |
306 | 307 |
wscall.varname = 'varname' |
307 | 308 |
wscall.post = False |
308 | 309 |
wscall.request_signature_key = 'key' |
309 |
wscall.post_data = {'one': '1', 'two': '=2', 'good:name': 'ok'}
|
|
310 |
wscall.post_data = OrderedDict((('one', '1'), ('two', '=2'), ('good:name', 'ok')))
|
|
310 | 311 |
st1.items.append(wscall) |
311 | 312 |
wscall.parent = st1 |
312 | 313 |
tests/test_workflows.py | ||
---|---|---|
1216 | 1216 |
pub.apply_global_action_timeouts() |
1217 | 1217 |
assert formdef.data_class().get(formdata1.id).get_criticality_level_object().name == 'green' |
1218 | 1218 |
formdata1.store() |
1219 | ||
1220 | ||
1221 |
def test_workflow_get_json_export_dict(pub): |
|
1222 |
workflow = Workflow(name='wf roles') |
|
1223 |
st2 = workflow.add_status('Status2', 'st2') |
|
1224 |
st2.forced_endpoint = True |
|
1225 |
workflow.roles['_other'] = 'Other Function' |
|
1226 |
root = workflow.get_json_export_dict() |
|
1227 |
assert set(root.keys()) >= set(['statuses', 'name', 'functions']) |
|
1228 | ||
1229 |
assert root['name'] == 'wf roles' |
|
1230 |
assert set(root['statuses'].keys()) == set(['st1', 'st2']) |
|
1231 |
assert all(set(status.keys()) >= set(['name', 'forced_endpoint']) for status in |
|
1232 |
root['statuses'].values()) |
|
1233 |
assert root['statuses']['st1']['name'] == 'Status1' |
|
1234 |
assert root['statuses']['st1']['forced_endpoint'] is False |
|
1235 |
assert root['statuses']['st2']['name'] == 'Status2' |
|
1236 |
assert root['statuses']['st2']['forced_endpoint'] is True |
wcs/wf/wscall.py | ||
---|---|---|
23 | 23 |
import mimetypes |
24 | 24 |
from StringIO import StringIO |
25 | 25 | |
26 |
from collections import OrderedDict |
|
26 | 27 |
from quixote.html import TemplateIO, htmltext |
27 | 28 |
from qommon.errors import ConnectionError |
28 | 29 |
from qommon.form import * |
... | ... | |
157 | 158 |
if 'post_data' in parameters: |
158 | 159 |
form.add(WidgetDict, '%spost_data' % prefix, |
159 | 160 |
title=_('Post data'), |
160 |
value=self.post_data or {},
|
|
161 |
value=dict(self.post_data or {}),
|
|
161 | 162 |
attrs={ |
162 | 163 |
'data-dynamic-display-child-of': '%smethod' % prefix, |
163 | 164 |
'data-dynamic-display-value': methods.get('POST'), |
... | ... | |
232 | 233 | |
233 | 234 |
# if self.post_data exists, post_data is a dict built from it |
234 | 235 |
if self.method == 'POST' and self.post_data: |
235 |
post_data = {}
|
|
236 |
post_data = OrderedDict()
|
|
236 | 237 |
for (key, value) in self.post_data.items(): |
237 | 238 |
try: |
238 | 239 |
post_data[key] = self.compute(value, raises=True) |
... | ... | |
382 | 383 |
def post_data_init_with_xml(self, elem, charset, include_id=False): |
383 | 384 |
if elem is None: |
384 | 385 |
return |
385 |
self.post_data = {}
|
|
386 |
self.post_data = OrderedDict()
|
|
386 | 387 |
for item in elem.findall('item'): |
387 | 388 |
key = item.find('name').text.encode(charset) |
388 | 389 |
value = item.find('value').text.encode(charset) |
wcs/workflows.py | ||
---|---|---|
692 | 692 | |
693 | 693 |
return workflow |
694 | 694 | |
695 |
def get_json_export_dict(self, include_id=False): |
|
696 |
charset = get_publisher().site_charset |
|
697 |
root = {} |
|
698 |
root['name'] = unicode(self.name, charset) |
|
699 |
if include_id and self.id: |
|
700 |
root['id'] = str(self.id) |
|
701 |
if self.last_modification_time: |
|
702 |
root['last_modification_time'] = time.strftime('%Y-%m-%dT%H:%M:%S', |
|
703 |
self.last_modification_time) |
|
704 |
roles = root['functions'] = {} |
|
705 |
for role, label in self.roles.iteritems(): |
|
706 |
roles[role] = unicode(label, charset) |
|
707 |
statuses = root['statuses'] = {} |
|
708 |
for status in self.possible_status: |
|
709 |
statuses[status.id] = { |
|
710 |
'name': unicode(status.name, charset), |
|
711 |
'forced_endpoint': status.forced_endpoint, |
|
712 |
} |
|
713 |
return root |
|
714 | ||
695 | 715 | |
696 | 716 |
class XmlSerialisable(object): |
697 | 717 |
node_name = None |
698 |
- |