0002-export-workflow-in-formdef-json-exports-fixes-9849.patch
tests/test_api.py | ||
---|---|---|
8 | 8 |
import urlparse |
9 | 9 |
import datetime |
10 | 10 |
import time |
11 |
import json |
|
11 | 12 | |
12 | 13 |
from quixote import cleanup, get_publisher |
13 | 14 |
from wcs.qommon.http_request import HTTPRequest |
... | ... | |
820 | 821 |
formdata.store() # (will get back to wf-st1) |
821 | 822 |
resp = get_app(pub).post(sign_uri(formdata.get_url() + 'jump/trigger/XXX'), |
822 | 823 |
status=403) |
824 | ||
825 |
def test_formdefs_api(pub, local_user): |
|
826 |
workflow = Workflow(name='test') |
|
827 |
st1 = workflow.add_status('Status1', 'st1') |
|
828 |
st2 = workflow.add_status('Status2', 'st2') |
|
829 |
workflow.store() |
|
830 | ||
831 |
FormDef.wipe() |
|
832 |
formdef = FormDef() |
|
833 |
formdef.name = 'test' |
|
834 |
formdef.fields = [] |
|
835 |
formdef.workflow_id = workflow.id |
|
836 |
formdef.store() |
|
837 | ||
838 |
resp = get_app(pub).get(sign_uri('/api/formdefs/test/schema', user=local_user)) |
|
839 |
assert set(resp.json.keys()) == set(['enable_tracking_codes', 'url_name', 'workflow_schema', |
|
840 |
'description', 'workflow', 'expiration_date', 'discussion', |
|
841 |
'last_modification_time', 'has_captcha', 'always_advertise', |
|
842 |
'name', 'disabled', 'workflow_id', 'only_allow_one', |
|
843 |
'private_status_and_history', 'fields', 'keywords', |
|
844 |
'publication_date', 'detailed_emails', |
|
845 |
'disabled_redirection']) |
|
846 |
assert len(resp.json['workflow_schema']['statuses']) == 2 |
wcs/formdef.py | ||
---|---|---|
525 | 525 |
if self.workflow: |
526 | 526 |
root['workflow'] = unicode(self.workflow.name, charset) |
527 | 527 |
root['workflow_id'] = str(self.workflow.id) |
528 |
root['workflow_schema'] = self.workflow.to_dict(include_id=include_id) |
|
528 | 529 | |
529 | 530 |
if self.max_field_id is None and self.fields: |
530 | 531 |
self.max_field_id = max([lax_int(x.id) for x in self.fields]) |
531 |
- |