wbcore 1.46.0__py2.py3-none-any.whl → 1.58.2__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wbcore/cache/decorators.py +5 -3
- wbcore/cache/registry.py +14 -7
- wbcore/configs/__init__.py +1 -0
- wbcore/configs/configs.py +5 -0
- wbcore/configs/decorators.py +1 -1
- wbcore/configurations/configurations/apps.py +3 -2
- wbcore/configurations/configurations/authentication.py +1 -1
- wbcore/configurations/configurations/base.py +1 -1
- wbcore/configurations/configurations/cache.py +1 -1
- wbcore/configurations/configurations/i18nl10n.py +2 -1
- wbcore/configurations/configurations/maintenance.py +1 -1
- wbcore/configurations/configurations/media.py +1 -1
- wbcore/configurations/configurations/middleware.py +1 -1
- wbcore/configurations/configurations/rest_framework.py +1 -1
- wbcore/configurations/configurations/static.py +3 -3
- wbcore/configurations/configurations/wbcore.py +1 -1
- wbcore/content_type/serializers.py +13 -5
- wbcore/content_type/utils.py +3 -3
- wbcore/content_type/viewsets.py +2 -2
- wbcore/contrib/agenda/filters/calendar_item.py +5 -4
- wbcore/contrib/agenda/locale/de/LC_MESSAGES/django.po +145 -52
- wbcore/contrib/agenda/locale/de/LC_MESSAGES/django.po.translated +236 -0
- wbcore/contrib/agenda/locale/en/LC_MESSAGES/django.po +200 -0
- wbcore/contrib/agenda/locale/fr/LC_MESSAGES/django.po +201 -0
- wbcore/contrib/agenda/viewsets/calendar_items.py +7 -7
- wbcore/contrib/agenda/viewsets/menu/calendar_items.py +0 -6
- wbcore/contrib/ai/exceptions.py +5 -5
- wbcore/contrib/ai/llm/config.py +76 -27
- wbcore/contrib/ai/llm/mixins.py +5 -8
- wbcore/contrib/ai/llm/utils.py +50 -26
- wbcore/contrib/authentication/admin.py +2 -2
- wbcore/contrib/authentication/factories/__init__.py +8 -1
- wbcore/contrib/authentication/factories/users.py +19 -0
- wbcore/contrib/authentication/filters.py +1 -2
- wbcore/contrib/authentication/locale/de/LC_MESSAGES/django.po +209 -187
- wbcore/contrib/authentication/locale/de/LC_MESSAGES/django.po.translated +634 -0
- wbcore/contrib/authentication/locale/en/LC_MESSAGES/django.po +590 -0
- wbcore/contrib/authentication/locale/fr/LC_MESSAGES/django.po +592 -0
- wbcore/contrib/authentication/models/users.py +3 -3
- wbcore/contrib/authentication/models/users_activities.py +1 -1
- wbcore/contrib/authentication/serializers/users.py +2 -2
- wbcore/contrib/authentication/tests/test_tokens.py +3 -3
- wbcore/contrib/authentication/tests/test_users.py +0 -1
- wbcore/contrib/authentication/urls.py +0 -4
- wbcore/contrib/authentication/viewsets/endpoints/user_activities.py +2 -11
- wbcore/contrib/authentication/viewsets/endpoints/users.py +0 -3
- wbcore/contrib/authentication/viewsets/user_activities.py +2 -1
- wbcore/contrib/authentication/viewsets/users.py +6 -4
- wbcore/contrib/color/models.py +2 -1
- wbcore/contrib/currency/factories.py +1 -1
- wbcore/contrib/currency/import_export/backends/fixerio/currency_fx_rates.py +3 -1
- wbcore/contrib/currency/models.py +30 -8
- wbcore/contrib/currency/serializers.py +5 -1
- wbcore/contrib/currency/tests/test_serializers.py +7 -3
- wbcore/contrib/currency/tests/test_viewsets.py +1 -1
- wbcore/contrib/currency/viewsets/currency.py +2 -2
- wbcore/contrib/currency/viewsets/endpoints/currency_fx_rates.py +0 -9
- wbcore/contrib/dataloader/tests/test/dataloaders/protocols.py +1 -2
- wbcore/contrib/dataloader/utils.py +2 -2
- wbcore/contrib/directory/factories/__init__.py +1 -1
- wbcore/contrib/directory/factories/entries.py +2 -1
- wbcore/contrib/directory/filters/entries.py +9 -0
- wbcore/contrib/directory/locale/de/LC_MESSAGES/django.po +728 -714
- wbcore/contrib/directory/locale/de/LC_MESSAGES/django.po.translated +1779 -0
- wbcore/contrib/directory/locale/en/LC_MESSAGES/django.po +1652 -0
- wbcore/contrib/directory/locale/fr/LC_MESSAGES/django.po +1654 -0
- wbcore/contrib/directory/migrations/0011_person_description_person_i18n.py +24 -0
- wbcore/contrib/directory/migrations/0012_alter_person_managers.py +20 -0
- wbcore/contrib/directory/migrations/0013_alter_clientmanagerrelationship_options.py +17 -0
- wbcore/contrib/directory/models/contacts.py +2 -2
- wbcore/contrib/directory/models/entries.py +31 -5
- wbcore/contrib/directory/models/relationships.py +31 -35
- wbcore/contrib/directory/permissions.py +6 -0
- wbcore/contrib/directory/serializers/companies.py +16 -8
- wbcore/contrib/directory/serializers/contacts.py +8 -8
- wbcore/contrib/directory/serializers/entries.py +26 -15
- wbcore/contrib/directory/serializers/entry_representations.py +4 -2
- wbcore/contrib/directory/serializers/persons.py +12 -10
- wbcore/contrib/directory/serializers/relationships.py +2 -2
- wbcore/contrib/directory/tests/conftest.py +2 -0
- wbcore/contrib/directory/tests/disable_signals.py +11 -1
- wbcore/contrib/directory/tests/signals.py +2 -2
- wbcore/contrib/directory/tests/test_models.py +88 -66
- wbcore/contrib/directory/tests/test_serializers.py +1 -1
- wbcore/contrib/directory/tests/test_viewsets.py +8 -8
- wbcore/contrib/directory/viewsets/buttons/__init__.py +1 -1
- wbcore/contrib/directory/viewsets/buttons/relationships.py +32 -0
- wbcore/contrib/directory/viewsets/contacts.py +6 -6
- wbcore/contrib/directory/viewsets/display/__init__.py +1 -1
- wbcore/contrib/directory/viewsets/display/contacts.py +1 -14
- wbcore/contrib/directory/viewsets/display/entries.py +68 -38
- wbcore/contrib/directory/viewsets/display/relationships.py +26 -50
- wbcore/contrib/directory/viewsets/endpoints/relationships.py +1 -26
- wbcore/contrib/directory/viewsets/entries.py +8 -6
- wbcore/contrib/directory/viewsets/previews/entries.py +3 -3
- wbcore/contrib/directory/viewsets/relationships.py +16 -2
- wbcore/contrib/directory/viewsets/titles/relationships.py +2 -3
- wbcore/contrib/documents/filters.py +0 -2
- wbcore/contrib/documents/locale/de/LC_MESSAGES/django.po +103 -94
- wbcore/contrib/documents/locale/de/LC_MESSAGES/django.po.translated +285 -0
- wbcore/contrib/documents/locale/en/LC_MESSAGES/django.po +271 -0
- wbcore/contrib/documents/locale/fr/LC_MESSAGES/django.po +270 -0
- wbcore/contrib/documents/tests/test_models.py +32 -28
- wbcore/contrib/documents/viewsets/endpoints/shareable_links.py +2 -21
- wbcore/contrib/dynamic_preferences/types.py +108 -0
- wbcore/contrib/dynamic_preferences/viewsets.py +27 -0
- wbcore/contrib/example_app/filters/event.py +3 -1
- wbcore/contrib/example_app/filters/match.py +1 -1
- wbcore/contrib/example_app/models.py +91 -22
- wbcore/contrib/example_app/serializers/person_team.py +4 -4
- wbcore/contrib/example_app/templates/example_app/embedded_view.html +19 -0
- wbcore/contrib/example_app/tests/e2e/test_teams.py +1 -1
- wbcore/contrib/example_app/tests/test_models/test_match.py +17 -7
- wbcore/contrib/example_app/urls.py +2 -0
- wbcore/contrib/example_app/views.py +7 -0
- wbcore/contrib/example_app/viewsets/displays/team.py +23 -4
- wbcore/contrib/example_app/viewsets/menu/menus.py +1 -1
- wbcore/contrib/example_app/viewsets/menus.py +1 -1
- wbcore/contrib/geography/tests/conftest.py +14 -0
- wbcore/contrib/geography/tests/test_models.py +23 -8
- wbcore/contrib/geography/tests/test_viewsets.py +96 -2
- wbcore/contrib/guardian/tests/test_model_mixins.py +3 -4
- wbcore/contrib/guardian/tests/test_tasks.py +9 -9
- wbcore/contrib/guardian/tests/test_viewsets.py +2 -2
- wbcore/contrib/guardian/viewsets/configs/__init__.py +1 -1
- wbcore/contrib/guardian/viewsets/configs/buttons.py +9 -0
- wbcore/contrib/guardian/viewsets/configs/endpoints.py +7 -0
- wbcore/contrib/guardian/viewsets/viewsets.py +2 -0
- wbcore/contrib/i18n/__init__.py +2 -0
- wbcore/contrib/i18n/buttons.py +33 -0
- wbcore/contrib/i18n/serializers/__init__.py +0 -0
- wbcore/contrib/i18n/serializers/fields.py +20 -0
- wbcore/contrib/i18n/serializers/mixins.py +13 -0
- wbcore/contrib/i18n/tests/conftest.py +11 -0
- wbcore/contrib/i18n/tests/test_viewsets.py +67 -0
- wbcore/contrib/i18n/translation.py +140 -0
- wbcore/contrib/i18n/viewsets.py +36 -0
- wbcore/contrib/icons/backends/default.py +1 -0
- wbcore/contrib/icons/backends/material.py +1 -0
- wbcore/contrib/icons/icons.py +5 -8
- wbcore/contrib/io/admin.py +1 -0
- wbcore/contrib/io/backends/mail.py +3 -2
- wbcore/contrib/io/backends/utils.py +14 -17
- wbcore/contrib/io/exceptions.py +8 -0
- wbcore/contrib/io/factories.py +1 -1
- wbcore/contrib/io/import_export/backends/mail.py +1 -0
- wbcore/contrib/io/import_export/backends/sftp.py +29 -20
- wbcore/contrib/io/import_export/backends/stream.py +2 -2
- wbcore/contrib/io/import_export/parsers/__init__.py +0 -0
- wbcore/contrib/io/import_export/parsers/base_csv.py +36 -0
- wbcore/contrib/io/import_export/parsers/resources.py +50 -0
- wbcore/contrib/io/imports.py +33 -25
- wbcore/contrib/io/locale/de/LC_MESSAGES/django.po +114 -22
- wbcore/contrib/io/locale/de/LC_MESSAGES/django.po.translated +103 -0
- wbcore/contrib/io/locale/en/LC_MESSAGES/django.po +138 -0
- wbcore/contrib/io/locale/fr/LC_MESSAGES/django.po +138 -0
- wbcore/contrib/io/migrations/0008_importsource_resource_kwargs.py +18 -0
- wbcore/contrib/io/models.py +65 -45
- wbcore/contrib/io/resources.py +0 -6
- wbcore/contrib/io/serializers.py +2 -2
- wbcore/contrib/io/signals.py +4 -0
- wbcore/contrib/io/tests/test_backends.py +19 -13
- wbcore/contrib/io/tests/test_exports.py +1 -1
- wbcore/contrib/io/tests/test_imports.py +1 -1
- wbcore/contrib/io/tests/test_models.py +47 -14
- wbcore/contrib/io/tests/test_viewsets.py +271 -0
- wbcore/contrib/io/viewset_mixins.py +41 -54
- wbcore/contrib/notifications/admin.py +1 -0
- wbcore/contrib/notifications/apps.py +2 -1
- wbcore/contrib/notifications/backends/abstract_backend.py +2 -4
- wbcore/contrib/notifications/backends/firebase/backends.py +5 -2
- wbcore/contrib/notifications/dispatch.py +18 -7
- wbcore/contrib/notifications/factories/notification_types.py +1 -0
- wbcore/contrib/notifications/locale/de/LC_MESSAGES/django.po +25 -19
- wbcore/contrib/notifications/locale/de/LC_MESSAGES/django.po.translated +63 -0
- wbcore/contrib/notifications/locale/en/LC_MESSAGES/django.po +61 -0
- wbcore/contrib/notifications/locale/fr/LC_MESSAGES/django.po +62 -0
- wbcore/contrib/notifications/migrations/0008_notificationtype_is_lock.py +18 -0
- wbcore/contrib/notifications/migrations/0009_alter_notificationtypesetting_options_and_more.py +32 -0
- wbcore/contrib/notifications/models/notification_types.py +67 -24
- wbcore/contrib/notifications/serializers/notification_types.py +16 -1
- wbcore/contrib/notifications/tests/test_models/test_tokens.py +8 -0
- wbcore/contrib/notifications/tests/test_serializers/test_notification_types.py +5 -0
- wbcore/contrib/notifications/tests/test_viewsets/test_notification_types.py +3 -5
- wbcore/contrib/notifications/utils.py +3 -2
- wbcore/contrib/notifications/viewsets/configs/notification_types.py +28 -6
- wbcore/contrib/notifications/viewsets/menus.py +1 -1
- wbcore/contrib/notifications/viewsets/notification_types.py +12 -2
- wbcore/contrib/pandas/fields.py +38 -10
- wbcore/contrib/pandas/filters.py +4 -1
- wbcore/contrib/pandas/filterset.py +8 -7
- wbcore/contrib/pandas/tests/test_fields/test_number_fields.py +2 -7
- wbcore/contrib/pandas/utils.py +1 -1
- wbcore/contrib/pandas/views.py +14 -13
- wbcore/contrib/tags/models/tags.py +4 -1
- wbcore/contrib/workflow/factories/display.py +2 -2
- wbcore/contrib/workflow/factories/transition.py +16 -15
- wbcore/contrib/workflow/locale/de/LC_MESSAGES/django.po +457 -566
- wbcore/contrib/workflow/locale/de/LC_MESSAGES/django.po.translated +1326 -0
- wbcore/contrib/workflow/locale/en/LC_MESSAGES/django.po +1102 -0
- wbcore/contrib/workflow/locale/fr/LC_MESSAGES/django.po +1114 -0
- wbcore/contrib/workflow/models/data.py +7 -4
- wbcore/contrib/workflow/models/process.py +2 -2
- wbcore/contrib/workflow/models/step.py +57 -15
- wbcore/contrib/workflow/serializers/data.py +8 -8
- wbcore/contrib/workflow/serializers/process.py +3 -2
- wbcore/contrib/workflow/tests/conftest.py +224 -0
- wbcore/contrib/workflow/tests/test_dispatch.py +82 -77
- wbcore/contrib/workflow/tests/test_displays.py +10 -88
- wbcore/contrib/workflow/tests/test_filters.py +57 -40
- wbcore/contrib/workflow/tests/test_models/step/test_decision_step.py +71 -68
- wbcore/contrib/workflow/tests/test_models/step/test_email_step.py +78 -38
- wbcore/contrib/workflow/tests/test_models/step/test_finish_step.py +152 -90
- wbcore/contrib/workflow/tests/test_models/step/test_join_step.py +100 -110
- wbcore/contrib/workflow/tests/test_models/step/test_step.py +168 -33
- wbcore/contrib/workflow/tests/test_models/test_condition.py +1 -1
- wbcore/contrib/workflow/tests/test_models/test_workflow.py +3 -3
- wbcore/contrib/workflow/tests/test_serializers.py +172 -150
- wbcore/contrib/workflow/tests/test_viewsets.py +264 -323
- wbcore/contrib/workflow/tests/test_workflow_assignees.py +215 -205
- wbcore/contrib/workflow/viewsets/process.py +4 -1
- wbcore/contrib/workflow/workflows/assignees.py +12 -7
- wbcore/dynamic_preferences_registry.py +102 -0
- wbcore/enums.py +2 -51
- wbcore/filters/fields/choices.py +4 -6
- wbcore/filters/fields/content_type.py +15 -4
- wbcore/filters/fields/datetime.py +50 -25
- wbcore/filters/fields/models.py +18 -9
- wbcore/filters/fields/numbers.py +9 -8
- wbcore/filters/filterset.py +27 -6
- wbcore/filters/mixins.py +41 -42
- wbcore/forms.py +6 -6
- wbcore/fsm/markdown_extensions.py +1 -1
- wbcore/fsm/mixins.py +20 -6
- wbcore/locale/de/LC_MESSAGES/django.po +982 -397
- wbcore/locale/de/LC_MESSAGES/django.po.translated +1580 -0
- wbcore/locale/en/LC_MESSAGES/django.po +1234 -0
- wbcore/locale/fr/LC_MESSAGES/django.po +1235 -0
- wbcore/markdown/models.py +8 -5
- wbcore/markdown/views.py +1 -1
- wbcore/menus/menus.py +2 -2
- wbcore/metadata/configs/buttons/bases.py +10 -7
- wbcore/metadata/configs/buttons/buttons.py +2 -1
- wbcore/metadata/configs/buttons/enums.py +50 -0
- wbcore/metadata/configs/buttons/view_config.py +13 -46
- wbcore/metadata/configs/display/display.py +2 -2
- wbcore/metadata/configs/display/formatting.py +6 -9
- wbcore/metadata/configs/display/instance_display/display.py +5 -2
- wbcore/metadata/configs/display/instance_display/pages.py +1 -1
- wbcore/metadata/configs/display/instance_display/shortcuts.py +1 -1
- wbcore/metadata/configs/display/list_display.py +54 -40
- wbcore/metadata/configs/display/models.py +6 -0
- wbcore/metadata/configs/display/view_config.py +11 -9
- wbcore/metadata/configs/endpoints.py +11 -4
- wbcore/metadata/configs/fields.py +6 -1
- wbcore/metadata/configs/filter_fields.py +12 -13
- wbcore/metadata/configs/identifiers.py +3 -1
- wbcore/metadata/tests/test_buttons.py +13 -16
- wbcore/models/fields.py +2 -2
- wbcore/pagination.py +1 -2
- wbcore/permissions/permissions.py +2 -2
- wbcore/permissions/utils.py +2 -2
- wbcore/release_notes/display.py +2 -8
- wbcore/release_notes/serializers.py +2 -9
- wbcore/release_notes/viewsets.py +8 -2
- wbcore/reversion/viewsets/titles.py +4 -3
- wbcore/serializers/__init__.py +2 -0
- wbcore/serializers/fields/__init__.py +2 -1
- wbcore/serializers/fields/boolean.py +1 -1
- wbcore/serializers/fields/choice.py +28 -4
- wbcore/serializers/fields/datetime.py +45 -36
- wbcore/serializers/fields/fields.py +1 -1
- wbcore/serializers/fields/fsm.py +1 -1
- wbcore/serializers/fields/list.py +2 -5
- wbcore/serializers/fields/mixins.py +24 -11
- wbcore/serializers/fields/number.py +6 -23
- wbcore/serializers/fields/other.py +2 -10
- wbcore/serializers/fields/related.py +4 -6
- wbcore/serializers/fields/text.py +1 -1
- wbcore/serializers/fields/types.py +2 -0
- wbcore/serializers/serializers.py +12 -3
- wbcore/signals/__init__.py +1 -0
- wbcore/signals/clone.py +4 -0
- wbcore/signals/models.py +2 -6
- wbcore/tasks.py +2 -2
- wbcore/templates/wbcore/email_base_template.html +3 -3
- wbcore/test/e2e_helpers_methods/e2e_checks.py +10 -4
- wbcore/test/e2e_helpers_methods/e2e_helper_methods.py +4 -2
- wbcore/test/mixins.py +52 -102
- wbcore/test/tests.py +6 -9
- wbcore/test/utils.py +3 -4
- wbcore/tests/e2e/test_e2e.py +2 -2
- wbcore/tests/test_cache/test_decorators.py +4 -7
- wbcore/tests/test_configs.py +2 -5
- wbcore/tests/test_enums.py +2 -1
- wbcore/tests/test_fields/test_choice_fields.py +9 -1
- wbcore/tests/test_fields/test_number_fields.py +7 -15
- wbcore/tests/test_fields/test_other_fields.py +1 -2
- wbcore/tests/test_filters/test_mixins.py +35 -35
- wbcore/tests/test_list_display.py +0 -2
- wbcore/tests/test_models/test_mixins.py +1 -1
- wbcore/tests/test_utils/test_date.py +1 -1
- wbcore/tests/test_utils/test_date_builder.py +25 -1
- wbcore/tests/test_utils/test_primary.py +1 -1
- wbcore/urls.py +4 -0
- wbcore/utils/date.py +18 -2
- wbcore/utils/figures.py +2 -2
- wbcore/utils/models.py +21 -4
- wbcore/utils/reportlab.py +7 -0
- wbcore/utils/rrules.py +3 -1
- wbcore/utils/string_loader.py +1 -1
- wbcore/utils/strings.py +3 -3
- wbcore/utils/views.py +8 -3
- wbcore/viewsets/mixins.py +9 -4
- {wbcore-1.46.0.dist-info → wbcore-1.58.2.dist-info}/METADATA +9 -5
- {wbcore-1.46.0.dist-info → wbcore-1.58.2.dist-info}/RECORD +317 -271
- wbcore/contrib/geography/tests/test_serializers.py +0 -7
- wbcore/contrib/geography/tests/tests.py +0 -13
- wbcore/contrib/io/tests/tests.py +0 -19
- wbcore/contrib/workflow/tests/tests.py +0 -25
- {wbcore-1.46.0.dist-info → wbcore-1.58.2.dist-info}/WHEEL +0 -0
|
@@ -1,359 +1,300 @@
|
|
|
1
1
|
from unittest.mock import patch
|
|
2
2
|
|
|
3
3
|
import pytest
|
|
4
|
+
from pytest import FixtureRequest
|
|
4
5
|
from rest_framework import status
|
|
5
|
-
from rest_framework.test import APIRequestFactory
|
|
6
6
|
|
|
7
|
-
from wbcore.contrib.authentication.factories import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
from wbcore.contrib.workflow.models import
|
|
12
|
-
|
|
7
|
+
from wbcore.contrib.authentication.factories import (
|
|
8
|
+
GroupFactory,
|
|
9
|
+
UserFactory,
|
|
10
|
+
)
|
|
11
|
+
from wbcore.contrib.workflow.models import (
|
|
12
|
+
Condition,
|
|
13
|
+
Data,
|
|
14
|
+
DecisionStep,
|
|
15
|
+
Process,
|
|
16
|
+
ProcessStep,
|
|
17
|
+
Transition,
|
|
18
|
+
Workflow,
|
|
19
|
+
)
|
|
13
20
|
from wbcore.contrib.workflow.viewsets import (
|
|
14
21
|
AssignedProcessStepModelViewSet,
|
|
15
|
-
|
|
22
|
+
ConditionModelViewSet,
|
|
23
|
+
DataModelViewSet,
|
|
24
|
+
DecisionStepModelViewSet,
|
|
25
|
+
ProcessModelViewSet,
|
|
16
26
|
ProcessStepModelViewSet,
|
|
27
|
+
TransitionModelViewSet,
|
|
17
28
|
WorkflowModelViewSet,
|
|
18
29
|
)
|
|
19
|
-
from wbcore.test.utils import get_data_from_factory, get_kwargs, get_or_create_superuser
|
|
20
30
|
|
|
21
31
|
|
|
22
32
|
@pytest.mark.django_db
|
|
23
|
-
class
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
vs = WorkflowModelViewSet.as_view({"get": "retrieve"})
|
|
42
|
-
response = vs(request, pk=obj.id)
|
|
43
|
-
assert response.data.get("instance")
|
|
44
|
-
assert not response.data.get("results")
|
|
45
|
-
assert response.status_code == status.HTTP_200_OK
|
|
46
|
-
|
|
47
|
-
def test_post(self, workflow_factory):
|
|
48
|
-
obj = workflow_factory()
|
|
49
|
-
super_user = get_or_create_superuser()
|
|
50
|
-
data = get_data_from_factory(obj, WorkflowModelViewSet, superuser=super_user, delete=True)
|
|
51
|
-
request = self.api_factory.post("", data=data)
|
|
33
|
+
class TestViewSets:
|
|
34
|
+
@pytest.mark.parametrize(
|
|
35
|
+
"viewset, entries",
|
|
36
|
+
[
|
|
37
|
+
(AssignedProcessStepModelViewSet, "assigned_process_steps"),
|
|
38
|
+
(ConditionModelViewSet, "conditions"),
|
|
39
|
+
(DataModelViewSet, "data"),
|
|
40
|
+
(DecisionStepModelViewSet, "decision_steps"),
|
|
41
|
+
(ProcessModelViewSet, "processes"),
|
|
42
|
+
(ProcessStepModelViewSet, "process_steps"),
|
|
43
|
+
(TransitionModelViewSet, "transitions"),
|
|
44
|
+
(WorkflowModelViewSet, "workflows"),
|
|
45
|
+
],
|
|
46
|
+
)
|
|
47
|
+
def test_get(self, request_factory, super_user, viewset, entries, request: FixtureRequest):
|
|
48
|
+
# Arrange
|
|
49
|
+
entries = request.getfixturevalue(entries)
|
|
50
|
+
request = request_factory.get("")
|
|
52
51
|
request.user = super_user
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
response = vs(request, **kwargs)
|
|
59
|
-
assert response.status_code == status.HTTP_201_CREATED
|
|
60
|
-
|
|
61
|
-
def test_delete(self, workflow_factory):
|
|
62
|
-
request = self.api_factory.delete("")
|
|
63
|
-
request.user = get_or_create_superuser()
|
|
64
|
-
obj = workflow_factory()
|
|
65
|
-
kwargs = get_kwargs(obj, WorkflowModelViewSet, request)
|
|
66
|
-
vs = WorkflowModelViewSet.as_view({"delete": "destroy"})
|
|
67
|
-
response = vs(request, **kwargs, pk=obj.pk)
|
|
68
|
-
assert response.status_code == status.HTTP_204_NO_CONTENT
|
|
69
|
-
|
|
70
|
-
def test_put(self, workflow_factory):
|
|
71
|
-
old_obj = workflow_factory()
|
|
72
|
-
new_obj = workflow_factory()
|
|
73
|
-
user = get_or_create_superuser()
|
|
74
|
-
data = get_data_from_factory(new_obj, WorkflowModelViewSet, superuser=user, delete=True)
|
|
75
|
-
request = self.api_factory.put("", data=data)
|
|
76
|
-
request.user = user
|
|
77
|
-
vs = WorkflowModelViewSet.as_view({"put": "update"})
|
|
78
|
-
workflow_site.registered_model_classes_serializer_map[Person] = (
|
|
79
|
-
"wbcore.contrib.directory.serializers.PersonModelSerializer"
|
|
80
|
-
)
|
|
81
|
-
response = vs(request, pk=old_obj.id)
|
|
82
|
-
assert response.status_code == status.HTTP_200_OK
|
|
83
|
-
|
|
84
|
-
def test_patch(self, workflow_factory):
|
|
85
|
-
obj = workflow_factory()
|
|
86
|
-
request = self.api_factory.patch("", data={"name": "New Name"})
|
|
87
|
-
request.user = get_or_create_superuser()
|
|
88
|
-
vs = WorkflowModelViewSet.as_view({"patch": "partial_update"})
|
|
89
|
-
workflow_site.registered_model_classes_serializer_map[Person] = (
|
|
90
|
-
"wbcore.contrib.directory.serializers.PersonModelSerializer"
|
|
91
|
-
)
|
|
92
|
-
response = vs(request, pk=obj.id)
|
|
52
|
+
viewset = viewset.as_view({"get": "list"})
|
|
53
|
+
# Act
|
|
54
|
+
response = viewset(request)
|
|
55
|
+
# Assert
|
|
56
|
+
assert response.data["count"] == 3
|
|
93
57
|
assert response.status_code == status.HTTP_200_OK
|
|
94
58
|
|
|
95
|
-
@
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
request
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
59
|
+
@pytest.mark.parametrize(
|
|
60
|
+
"viewset, model",
|
|
61
|
+
[
|
|
62
|
+
(AssignedProcessStepModelViewSet, "assigned_process_step"),
|
|
63
|
+
(ConditionModelViewSet, "condition"),
|
|
64
|
+
(DataModelViewSet, "singular_data"),
|
|
65
|
+
(DecisionStepModelViewSet, "decision_step"),
|
|
66
|
+
(ProcessModelViewSet, "process"),
|
|
67
|
+
(ProcessStepModelViewSet, "process_step"),
|
|
68
|
+
(TransitionModelViewSet, "transition"),
|
|
69
|
+
(WorkflowModelViewSet, "workflow"),
|
|
70
|
+
],
|
|
71
|
+
)
|
|
72
|
+
def test_retrieve(self, request_factory, super_user, viewset, model, request: FixtureRequest):
|
|
73
|
+
# Arrange
|
|
74
|
+
entries = request.getfixturevalue(model)
|
|
75
|
+
request = request_factory.get("")
|
|
76
|
+
request.user = super_user
|
|
77
|
+
vs = viewset.as_view({"get": "retrieve"})
|
|
78
|
+
# Act
|
|
79
|
+
response = vs(request, pk=entries.id)
|
|
80
|
+
instance = response.data.get("instance")
|
|
81
|
+
# Assert
|
|
82
|
+
assert instance is not None
|
|
83
|
+
assert instance["id"] == entries.id
|
|
120
84
|
assert response.status_code == status.HTTP_200_OK
|
|
121
|
-
assert mock_start.call_args.args == (
|
|
122
|
-
start_step,
|
|
123
|
-
attached_person,
|
|
124
|
-
)
|
|
125
85
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
86
|
+
@pytest.mark.parametrize(
|
|
87
|
+
"viewset, build_data, can_create",
|
|
88
|
+
[
|
|
89
|
+
(AssignedProcessStepModelViewSet, "assigned_process_steps_build", False),
|
|
90
|
+
(ConditionModelViewSet, "condition_build", True),
|
|
91
|
+
(DataModelViewSet, "data_build", True),
|
|
92
|
+
(DecisionStepModelViewSet, "decision_step_build", True),
|
|
93
|
+
(ProcessModelViewSet, "process_build", False),
|
|
94
|
+
(ProcessStepModelViewSet, "process_steps_build", False),
|
|
95
|
+
(TransitionModelViewSet, "transition_build", True),
|
|
96
|
+
(WorkflowModelViewSet, "workflow_build", True),
|
|
97
|
+
],
|
|
98
|
+
)
|
|
99
|
+
def test_create(
|
|
100
|
+
self,
|
|
101
|
+
request_factory,
|
|
102
|
+
super_user,
|
|
103
|
+
viewset,
|
|
104
|
+
build_data,
|
|
105
|
+
can_create,
|
|
106
|
+
request: FixtureRequest,
|
|
107
|
+
):
|
|
108
|
+
# Arrange
|
|
109
|
+
data = request.getfixturevalue(build_data)
|
|
110
|
+
request = request_factory.post("", data=data, format="json")
|
|
111
|
+
request.user = super_user
|
|
112
|
+
vs = viewset.as_view({"post": "create"})
|
|
113
|
+
# Act
|
|
136
114
|
response = vs(request)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
assert
|
|
140
|
-
assert response.status_code == status.HTTP_200_OK
|
|
115
|
+
expected_status_code = status.HTTP_201_CREATED if can_create else status.HTTP_405_METHOD_NOT_ALLOWED
|
|
116
|
+
# Assert
|
|
117
|
+
assert response.status_code == expected_status_code
|
|
141
118
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
119
|
+
@pytest.mark.parametrize(
|
|
120
|
+
"viewset, entries, model",
|
|
121
|
+
[
|
|
122
|
+
(AssignedProcessStepModelViewSet, "assigned_process_steps", ProcessStep),
|
|
123
|
+
(ConditionModelViewSet, "conditions", Condition),
|
|
124
|
+
(DataModelViewSet, "data", Data),
|
|
125
|
+
(DecisionStepModelViewSet, "decision_steps", DecisionStep),
|
|
126
|
+
(ProcessModelViewSet, "processes", Process),
|
|
127
|
+
(ProcessStepModelViewSet, "process_steps", ProcessStep),
|
|
128
|
+
(TransitionModelViewSet, "transitions", Transition),
|
|
129
|
+
(WorkflowModelViewSet, "workflows", Workflow),
|
|
130
|
+
],
|
|
131
|
+
)
|
|
132
|
+
def test_delete(
|
|
133
|
+
self,
|
|
134
|
+
request_factory,
|
|
135
|
+
super_user,
|
|
136
|
+
viewset,
|
|
137
|
+
entries,
|
|
138
|
+
model,
|
|
139
|
+
request: FixtureRequest,
|
|
140
|
+
):
|
|
141
|
+
# Arrange
|
|
142
|
+
entries = request.getfixturevalue(entries)
|
|
143
|
+
entry_id = entries[1].id
|
|
144
|
+
request = request_factory.delete("", args=entry_id)
|
|
167
145
|
request.user = super_user
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
assert response.status_code == status.HTTP_405_METHOD_NOT_ALLOWED
|
|
173
|
-
|
|
174
|
-
kwargs.pop("workflow_id")
|
|
175
|
-
response = vs(request, **kwargs)
|
|
176
|
-
assert response.status_code == status.HTTP_201_CREATED
|
|
177
|
-
|
|
178
|
-
def test_delete(self, email_step_factory):
|
|
179
|
-
request = self.api_factory.delete("")
|
|
180
|
-
request.user = get_or_create_superuser()
|
|
181
|
-
obj = email_step_factory()
|
|
182
|
-
kwargs = get_kwargs(obj, EmailStepModelViewSet, request)
|
|
183
|
-
vs = EmailStepModelViewSet.as_view({"delete": "destroy"})
|
|
184
|
-
response = vs(request, **kwargs, pk=obj.pk)
|
|
146
|
+
vs = viewset.as_view({"delete": "destroy"})
|
|
147
|
+
# Act
|
|
148
|
+
response = vs(request, pk=entry_id)
|
|
149
|
+
# Assert
|
|
185
150
|
assert response.status_code == status.HTTP_204_NO_CONTENT
|
|
151
|
+
assert model.objects.count() == 2
|
|
152
|
+
assert not model.objects.filter(id=entry_id).exists()
|
|
186
153
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
"
|
|
196
|
-
"
|
|
197
|
-
"
|
|
198
|
-
"
|
|
199
|
-
"
|
|
200
|
-
"
|
|
201
|
-
"
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
api_factory = APIRequestFactory()
|
|
224
|
-
|
|
225
|
-
def test_get(self, process_step_factory):
|
|
226
|
-
request = self.api_factory.get("")
|
|
227
|
-
request.user = get_or_create_superuser()
|
|
228
|
-
process_step_factory.create_batch(3)
|
|
229
|
-
vs = ProcessStepModelViewSet.as_view({"get": "list"})
|
|
230
|
-
response = vs(request)
|
|
231
|
-
assert response.data.get("results")
|
|
232
|
-
assert not response.data.get("instance")
|
|
233
|
-
assert len(response.data.get("results")) == 3
|
|
234
|
-
assert response.status_code == status.HTTP_200_OK
|
|
235
|
-
|
|
236
|
-
def test_retrieve(self, process_step_factory):
|
|
237
|
-
request = self.api_factory.get("")
|
|
238
|
-
request.user = get_or_create_superuser()
|
|
239
|
-
obj = process_step_factory()
|
|
240
|
-
vs = ProcessStepModelViewSet.as_view({"get": "retrieve"})
|
|
241
|
-
response = vs(request, pk=obj.id)
|
|
242
|
-
assert response.data.get("instance")
|
|
243
|
-
assert not response.data.get("results")
|
|
154
|
+
@pytest.mark.parametrize(
|
|
155
|
+
"viewset, entry, new_entry",
|
|
156
|
+
[
|
|
157
|
+
(
|
|
158
|
+
AssignedProcessStepModelViewSet,
|
|
159
|
+
"assigned_process_step",
|
|
160
|
+
"assigned_process_steps_build",
|
|
161
|
+
),
|
|
162
|
+
(ConditionModelViewSet, "condition", "condition_build"),
|
|
163
|
+
(DataModelViewSet, "singular_data", "data_build"),
|
|
164
|
+
(DecisionStepModelViewSet, "decision_step", "decision_step_build"),
|
|
165
|
+
(ProcessModelViewSet, "process", "process_build"),
|
|
166
|
+
(ProcessStepModelViewSet, "process_step", "process_steps_build"),
|
|
167
|
+
(TransitionModelViewSet, "transition", "transition_build"),
|
|
168
|
+
(WorkflowModelViewSet, "workflow", "workflow_build"),
|
|
169
|
+
],
|
|
170
|
+
)
|
|
171
|
+
def test_put(
|
|
172
|
+
self,
|
|
173
|
+
request_factory,
|
|
174
|
+
super_user,
|
|
175
|
+
viewset,
|
|
176
|
+
entry,
|
|
177
|
+
new_entry,
|
|
178
|
+
request: FixtureRequest,
|
|
179
|
+
):
|
|
180
|
+
# Arrange
|
|
181
|
+
entry = request.getfixturevalue(entry)
|
|
182
|
+
new_data = request.getfixturevalue(new_entry)
|
|
183
|
+
new_data["id"] = entry.id
|
|
184
|
+
request = request_factory.put("", data=new_data, format="json")
|
|
185
|
+
request.user = super_user
|
|
186
|
+
vs = viewset.as_view({"put": "update"})
|
|
187
|
+
# Act
|
|
188
|
+
response = vs(request, pk=entry.id)
|
|
189
|
+
# Assert
|
|
244
190
|
assert response.status_code == status.HTTP_200_OK
|
|
245
191
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
192
|
+
@pytest.mark.parametrize(
|
|
193
|
+
"viewset, entry, field, is_editable",
|
|
194
|
+
[
|
|
195
|
+
(AssignedProcessStepModelViewSet, "assigned_process_step", "status", False),
|
|
196
|
+
(ConditionModelViewSet, "condition", "expected_value", True),
|
|
197
|
+
(DataModelViewSet, "singular_data", "label", True),
|
|
198
|
+
(DecisionStepModelViewSet, "decision_step", "status", True),
|
|
199
|
+
(ProcessModelViewSet, "process", "state", False),
|
|
200
|
+
(ProcessStepModelViewSet, "process_step", "status", False),
|
|
201
|
+
(TransitionModelViewSet, "transition", "name", True),
|
|
202
|
+
(WorkflowModelViewSet, "workflow", "name", True),
|
|
203
|
+
],
|
|
204
|
+
)
|
|
205
|
+
def test_patch(
|
|
206
|
+
self,
|
|
207
|
+
request_factory,
|
|
208
|
+
super_user,
|
|
209
|
+
viewset,
|
|
210
|
+
entry,
|
|
211
|
+
field,
|
|
212
|
+
is_editable,
|
|
213
|
+
request: FixtureRequest,
|
|
214
|
+
):
|
|
215
|
+
# Arrange
|
|
216
|
+
entry = request.getfixturevalue(entry)
|
|
217
|
+
old_field_data = getattr(entry, field)
|
|
218
|
+
new_field_data = "Foo Bar"
|
|
219
|
+
request = request_factory.patch("", data={field: new_field_data})
|
|
251
220
|
request.user = super_user
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
response = vs(request,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
request = self.api_factory.delete("")
|
|
259
|
-
request.user = get_or_create_superuser()
|
|
260
|
-
obj = process_step_factory()
|
|
261
|
-
kwargs = get_kwargs(obj, ProcessStepModelViewSet, request)
|
|
262
|
-
vs = ProcessStepModelViewSet.as_view({"delete": "destroy"})
|
|
263
|
-
response = vs(request, **kwargs, pk=obj.pk)
|
|
264
|
-
assert response.status_code == status.HTTP_204_NO_CONTENT
|
|
265
|
-
|
|
266
|
-
def test_patch(self, process_step_factory):
|
|
267
|
-
obj = process_step_factory()
|
|
268
|
-
request = self.api_factory.patch("", data={"name": "New Name"})
|
|
269
|
-
request.user = get_or_create_superuser()
|
|
270
|
-
vs = ProcessStepModelViewSet.as_view({"patch": "partial_update"})
|
|
271
|
-
response = vs(request, pk=obj.id)
|
|
221
|
+
vs = viewset.as_view({"patch": "partial_update"})
|
|
222
|
+
# Act
|
|
223
|
+
response = vs(request, pk=entry.id)
|
|
224
|
+
field_data = new_field_data if is_editable else old_field_data
|
|
225
|
+
entry.refresh_from_db()
|
|
226
|
+
# Assert
|
|
272
227
|
assert response.status_code == status.HTTP_200_OK
|
|
228
|
+
assert getattr(entry, field) == field_data
|
|
273
229
|
|
|
274
|
-
def
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
request
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
230
|
+
def test_get_process_step_su(self, request_factory, super_user, permission, process_step_factory):
|
|
231
|
+
# Arrange
|
|
232
|
+
process_step_a = process_step_factory(permission=permission)
|
|
233
|
+
process_step_b = process_step_factory()
|
|
234
|
+
request = request_factory.get("")
|
|
235
|
+
request.user = super_user
|
|
236
|
+
# Act
|
|
237
|
+
vs = ProcessStepModelViewSet(request=request, kwargs={})
|
|
238
|
+
qs = vs.get_queryset()
|
|
239
|
+
id_list = list(map(str, qs.values_list("id", flat=True)))
|
|
240
|
+
# Assert
|
|
241
|
+
assert process_step_a.id in id_list
|
|
242
|
+
assert process_step_b.id in id_list
|
|
243
|
+
|
|
244
|
+
def test_get_queryset_user_permission(self, request_factory, user, permission, process_step_factory):
|
|
245
|
+
# Arrange
|
|
288
246
|
user.user_permissions.add(permission)
|
|
247
|
+
process_step_a = process_step_factory(permission=permission)
|
|
248
|
+
process_step_b = process_step_factory()
|
|
249
|
+
request = request_factory.get("")
|
|
289
250
|
request.user = user
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
251
|
+
# Act
|
|
252
|
+
vs = ProcessStepModelViewSet(request=request, kwargs={})
|
|
253
|
+
qs = vs.get_queryset()
|
|
254
|
+
id_list = list(map(str, qs.values_list("id", flat=True)))
|
|
255
|
+
# Assert
|
|
256
|
+
assert process_step_a.id in id_list
|
|
257
|
+
assert process_step_b.id in id_list
|
|
258
|
+
|
|
259
|
+
def test_get_queryset_user_no_permission(self, request_factory, user, permission, process_step_factory):
|
|
260
|
+
# Arrange
|
|
261
|
+
process_step_a = process_step_factory(permission=permission)
|
|
262
|
+
process_step_b = process_step_factory()
|
|
263
|
+
request = request_factory.get("")
|
|
264
|
+
request.user = user
|
|
265
|
+
# Act
|
|
266
|
+
vs = ProcessStepModelViewSet(request=request, kwargs={})
|
|
267
|
+
qs = vs.get_queryset()
|
|
268
|
+
id_list = list(map(str, qs.values_list("id", flat=True)))
|
|
269
|
+
# Assert
|
|
270
|
+
assert process_step_a.id not in id_list
|
|
271
|
+
assert process_step_b.id in id_list
|
|
272
|
+
|
|
273
|
+
def test_get_queryset_group_permission(self, request_factory, permission, process_step_factory):
|
|
274
|
+
# Arrange
|
|
275
|
+
process_step_a = process_step_factory(permission=permission)
|
|
276
|
+
process_step_b = process_step_factory()
|
|
298
277
|
group = GroupFactory(permissions=[permission])
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
assert set(str(x.pk) for x in mvs.get_queryset()) == {process_step2.pk}
|
|
278
|
+
user = UserFactory(is_superuser=False, groups=[group])
|
|
279
|
+
request = request_factory.get("")
|
|
280
|
+
request.user = user
|
|
281
|
+
# Act
|
|
282
|
+
vs = ProcessStepModelViewSet(request=request, kwargs={})
|
|
283
|
+
qs = vs.get_queryset()
|
|
284
|
+
id_list = list(map(str, qs.values_list("id", flat=True)))
|
|
285
|
+
# Assert
|
|
286
|
+
assert process_step_a.id in id_list
|
|
287
|
+
assert process_step_b.id in id_list
|
|
310
288
|
|
|
311
289
|
@patch("wbcore.contrib.workflow.models.step.Step.start_next_step")
|
|
312
|
-
def test_next(self, mock_next,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
request = self.api_factory.get("")
|
|
316
|
-
request.user = get_or_create_superuser()
|
|
290
|
+
def test_next(self, mock_next, request_factory, super_user, process_step, transition):
|
|
291
|
+
request = request_factory.get("")
|
|
292
|
+
request.user = super_user
|
|
317
293
|
request.GET = request.GET.copy()
|
|
318
|
-
request.GET["transition_id"] = transition.
|
|
294
|
+
request.GET["transition_id"] = transition.id
|
|
319
295
|
response = ProcessStepModelViewSet().next(request, pk=process_step.pk)
|
|
320
296
|
assert response.status_code == status.HTTP_200_OK
|
|
321
|
-
assert set(str(x.pk) for x in mock_next.call_args.args) == {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
[
|
|
326
|
-
Step.StepType.DECISIONSTEP,
|
|
327
|
-
Step.StepType.EMAILSTEP,
|
|
328
|
-
Step.StepType.FINISHSTEP,
|
|
329
|
-
Step.StepType.JOINSTEP,
|
|
330
|
-
Step.StepType.SCRIPTSTEP,
|
|
331
|
-
Step.StepType.SPLITSTEP,
|
|
332
|
-
],
|
|
333
|
-
)
|
|
334
|
-
@pytest.mark.parametrize(
|
|
335
|
-
"bad_states",
|
|
336
|
-
[
|
|
337
|
-
ProcessStep.StepState.CANCELED,
|
|
338
|
-
ProcessStep.StepState.FAILED,
|
|
339
|
-
ProcessStep.StepState.FINISHED,
|
|
340
|
-
ProcessStep.StepState.WAITING,
|
|
341
|
-
],
|
|
342
|
-
)
|
|
343
|
-
def test_assigned_process_steps(self, process_step_factory, user_step_factory, bad_types, bad_states):
|
|
344
|
-
request = self.api_factory.get("")
|
|
345
|
-
group = GroupFactory()
|
|
346
|
-
user = UserFactory(groups=[group], is_superuser=True)
|
|
347
|
-
request.user = user
|
|
348
|
-
step = user_step_factory(assignee_method=None)
|
|
349
|
-
process_step1 = process_step_factory(step=step, state=ProcessStep.StepState.ACTIVE, assignee=user)
|
|
350
|
-
process_step2 = process_step_factory(step=step, state=ProcessStep.StepState.ACTIVE, group=group)
|
|
351
|
-
process_step_factory(step__step_type=bad_types, state=ProcessStep.StepState.ACTIVE, assignee=user)
|
|
352
|
-
process_step_factory(step=step, state=bad_states, assignee=user)
|
|
353
|
-
vs = AssignedProcessStepModelViewSet.as_view({"get": "list"})
|
|
354
|
-
response = vs(request)
|
|
355
|
-
assert response.data.get("results")
|
|
356
|
-
assert not response.data.get("instance")
|
|
357
|
-
id_set = {x["id"] for x in response.data.get("results")}
|
|
358
|
-
assert id_set == {str(process_step1.pk), str(process_step2.pk)}
|
|
359
|
-
assert response.status_code == status.HTTP_200_OK
|
|
297
|
+
assert set(str(x.pk) for x in mock_next.call_args.args) == {
|
|
298
|
+
process_step.pk,
|
|
299
|
+
str(transition.pk),
|
|
300
|
+
}
|