|
6 | 6 |
|
7 | 7 | import pytest |
8 | 8 |
|
| 9 | +from data import content_types as ct_data |
| 10 | +from data import entries as entry_data |
9 | 11 | from framework import helpers as h |
10 | 12 |
|
11 | 13 | pytestmark = pytest.mark.order(26) |
12 | 14 |
|
13 | 15 |
|
| 16 | +def _workflow_payload(name, ct_uid): |
| 17 | + return {"workflow": { |
| 18 | + "name": name, "content_types": [ct_uid], "branches": ["main"], |
| 19 | + "workflow_stages": [ |
| 20 | + {"color": "#2196f3", "name": "Draft", "SYS_ACL": {"roles": {"uids": []}, "users": {"uids": ["$all"]}, "others": {}}, "next_available_stages": ["$all"], "entry_lock": "$none"}, |
| 21 | + {"color": "#74ba76", "name": "Review", "SYS_ACL": {"roles": {"uids": []}, "users": {"uids": ["$all"]}, "others": {}}, "next_available_stages": ["$all"], "entry_lock": "$none"}, |
| 22 | + ], |
| 23 | + }} |
| 24 | + |
| 25 | + |
14 | 26 | class TestBulkOperation: |
15 | 27 | def test_publish(self, stack, store): |
16 | 28 | entry_uid = store.get("entries", {}).get("main") |
@@ -54,15 +66,24 @@ def test_delete(self, stack, store): |
54 | 66 | resp = stack.bulk_operation().delete(data) |
55 | 67 | h.assert_status(resp, 200, 201) |
56 | 68 |
|
57 | | - @pytest.mark.xfail(reason="bulk update (workflow stage) returns 412 without a valid " |
58 | | - "target workflow_stage uid; needs a configured workflow stage", strict=False) |
59 | | - def test_update_workflow(self, stack, store): |
60 | | - entry_uid = store.get("entries", {}).get("main") |
61 | | - ct_uid = store.get("content_types", {}).get("medium") |
62 | | - if not (entry_uid and ct_uid): |
63 | | - pytest.skip("missing entry/content type for bulk workflow update") |
64 | | - data = {"entries": [{"uid": entry_uid, "content_type": ct_uid, "locale": "en-us"}], |
65 | | - "workflow": {"workflow_stage": {"uid": ""}}} |
| 69 | + def test_update_workflow(self, stack): |
| 70 | + # Bulk workflow-stage update needs a real target stage uid plus the |
| 71 | + # 'notify' field. Set up a dedicated content type + entry + enabled |
| 72 | + # workflow, then bulk-move the entry to the Review stage. |
| 73 | + ct_uid = h.generate_valid_uid("ct_bulkwf") |
| 74 | + stack.content_types().create(ct_data.simple_content_type(uid=ct_uid)) |
| 75 | + h.wait(h.SHORT_DELAY) |
| 76 | + entry_uid = h.body(stack.content_types(ct_uid).entry().create( |
| 77 | + entry_data.simple_entry(h.generate_unique_title("BulkWF")))).get("entry", {}).get("uid") |
| 78 | + h.wait(h.SHORT_DELAY) |
| 79 | + wf = h.body(stack.workflows().create(_workflow_payload(h.generate_unique_title("BulkWF"), ct_uid))) |
| 80 | + stage_uid = wf.get("workflow", {}).get("workflow_stages", [{}, {}])[1].get("uid") |
| 81 | + stack.workflows(wf.get("workflow", {}).get("uid")).enable() |
| 82 | + h.wait(h.SHORT_DELAY) |
| 83 | + data = { |
| 84 | + "entries": [{"uid": entry_uid, "content_type": ct_uid, "locale": "en-us"}], |
| 85 | + "workflow": {"workflow_stage": {"uid": stage_uid, "notify": False, "comment": "bulk move"}}, |
| 86 | + } |
66 | 87 | resp = stack.bulk_operation().update(data) |
67 | 88 | h.assert_status(resp, 200, 201) |
68 | 89 |
|
|
0 commit comments