From c2ed516be31a5354f0a25b9aa7ba9860ed247f5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20Boixader=20G=C3=BCell?= Date: Fri, 19 Jan 2024 17:23:14 +0100 Subject: [PATCH] test: use custom workflow for tests --- .../workflows/base/guillotina_basic.yaml | 8 -- .../tests/workflows/test_workflow_basic.py | 96 ++++++++++++++++++- 2 files changed, 94 insertions(+), 10 deletions(-) diff --git a/guillotina/contrib/workflows/base/guillotina_basic.yaml b/guillotina/contrib/workflows/base/guillotina_basic.yaml index 044c4f772..fa0ce3a7b 100644 --- a/guillotina/contrib/workflows/base/guillotina_basic.yaml +++ b/guillotina/contrib/workflows/base/guillotina_basic.yaml @@ -3,10 +3,6 @@ states: private: metadata: title: Private - translated_title: - en: Private - ca: Privat - es: Privado actions: publish: title: Publish @@ -26,10 +22,6 @@ states: public: metadata: title: Public - translated_title: - en: Public - ca: Públic - es: Público actions: retire: title: Retire diff --git a/guillotina/tests/workflows/test_workflow_basic.py b/guillotina/tests/workflows/test_workflow_basic.py index cc8b07271..efbb6da0b 100644 --- a/guillotina/tests/workflows/test_workflow_basic.py +++ b/guillotina/tests/workflows/test_workflow_basic.py @@ -3,18 +3,110 @@ pytestmark = pytest.mark.asyncio +guillotina_basic_with_translations = { + "initial_state": "private", + "states": { + "private": { + "metadata": { + "title": "Private", + "translated_title": { + "en": "Private", + "ca": "Privat", + "es": "Privado", + }, + }, + "actions": { + "publish": { + "title": "Publish", + "metadata": { + "translated_title": { + "en": "Publish", + "ca": "Publicar", + "es": "Publicar", + }, + }, + "to": "public", + "check_permission": "guillotina.ReviewContent", + } + }, + "set_permission": { + "roleperm": [ + { + "setting": "Deny", + "role": "guillotina.Anonymous", + "permission": "guillotina.ViewContent", + }, + { + "setting": "Deny", + "role": "guillotina.Anonymous", + "permission": "guillotina.AccessContent", + }, + { + "setting": "Deny", + "role": "guillotina.Anonymous", + "permission": "guillotina.SearchContent", + }, + ] + }, + }, + "public": { + "metadata": { + "title": "Public", + "translated_title": { + "en": "Public", + "ca": "Públic", + "es": "Público", + }, + }, + "actions": { + "retire": { + "title": "Retire", + "to": "private", + "check_permission": "guillotina.ReviewContent", + }, + }, + "set_permission": { + "roleperm": [ + { + "setting": "AllowSingle", + "role": "guillotina.Anonymous", + "permission": "guillotina.ViewContent", + }, + { + "setting": "AllowSingle", + "role": "guillotina.Anonymous", + "permission": "guillotina.AccessContent", + }, + { + "setting": "AllowSingle", + "role": "guillotina.Anonymous", + "permission": "guillotina.SearchContent", + }, + ] + }, + }, + }, +} + @pytest.mark.app_settings( { "applications": ["guillotina", "guillotina.contrib.workflows"], - "workflows_content": {"guillotina.interfaces.IContainer": "guillotina_basic"}, + "workflows_content": {"guillotina.interfaces.IContainer": "guillotina_basic_with_translations"}, + "workflows": {"guillotina_basic_with_translations": guillotina_basic_with_translations}, } ) async def test_workflow_basic(container_requester): async with container_requester as requester: response, _ = await requester("GET", "/db/guillotina/@workflow") assert response["transitions"][0]["title"] == "Publish" - assert response["transitions"][0]["metadata"] == {} + assert response["transitions"][0]["metadata"] == { + "translated_title": { + "en": "Publish", + "ca": "Publicar", + "es": "Publicar", + } + } response, _ = await requester("GET", "/db/guillotina") assert response["review_state"] == "private"