spiff-arena/tests/spiffworkflow_backend/scripts/test_get_group_members.py

61 lines
2.3 KiB
Python
Raw Normal View History

"""Test_get_localtime."""
from flask.app import Flask
Squashed 'spiffworkflow-backend/' changes from b8924100d..64ac70428 64ac70428 Move to Python 3.11 (#27) 167851df1 remove leading slash from model identifiers 3503fe400 one instance test left for cypress w/ burnettk 7e09363c4 merged in main and resolved conflicts w/ burnettk cullerton afbc3157d fixed some acceptance tests w/ burnettk cullerton 96e7b63c6 made a process model form w/ burnettk c19aac25f Somethings up w/authentication. Maybe the stored token is bad d17007eaa Merge branch 'main' into feature/nested-groups 729b13881 script to modify all model json files to use full path for model id. Also removes process_group_id 7856b8caa return next task when running an instance w/ burnettk d183b961c First pass at custom report/perspective for Process Instance List (#23) f303c0f77 remove process_group_identifier from process-instances endpoint 207de9ab8 Merge branch 'main' into feature/nested-groups fec8d06b8 started test for test_script_unit_test_run ea31c7a12 fixed process_model_identifier in script_unit_test_create 5d058cbea Fix url in test f8afd7bdd Remove the `_2` methods 7c13ec802 Fix urls for uspend and resume endpoints 19158d7b0 Get testing bpmn files out of the config directory 5f1ee7f16 fixed failing test de3b4b81d Merge branch 'main' into feature/nested-groups 440871d57 First stab at nested folders. Added temp endpoints Changes to tests and test helpers 1bd6a199f Don't need parent. Just use the whole path for the group id a2ab420b2 Committing so Jon can view code git-subtree-dir: spiffworkflow-backend git-subtree-split: 64ac7042887af80869963bc103c01f56404727f2
2022-11-09 20:02:19 +00:00
from flask.testing import FlaskClient
from flask_bpmn.models.db import db
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
from spiffworkflow_backend.models.group import GroupModel
Squashed 'spiffworkflow-backend/' changes from b8924100d..64ac70428 64ac70428 Move to Python 3.11 (#27) 167851df1 remove leading slash from model identifiers 3503fe400 one instance test left for cypress w/ burnettk 7e09363c4 merged in main and resolved conflicts w/ burnettk cullerton afbc3157d fixed some acceptance tests w/ burnettk cullerton 96e7b63c6 made a process model form w/ burnettk c19aac25f Somethings up w/authentication. Maybe the stored token is bad d17007eaa Merge branch 'main' into feature/nested-groups 729b13881 script to modify all model json files to use full path for model id. Also removes process_group_id 7856b8caa return next task when running an instance w/ burnettk d183b961c First pass at custom report/perspective for Process Instance List (#23) f303c0f77 remove process_group_identifier from process-instances endpoint 207de9ab8 Merge branch 'main' into feature/nested-groups fec8d06b8 started test for test_script_unit_test_run ea31c7a12 fixed process_model_identifier in script_unit_test_create 5d058cbea Fix url in test f8afd7bdd Remove the `_2` methods 7c13ec802 Fix urls for uspend and resume endpoints 19158d7b0 Get testing bpmn files out of the config directory 5f1ee7f16 fixed failing test de3b4b81d Merge branch 'main' into feature/nested-groups 440871d57 First stab at nested folders. Added temp endpoints Changes to tests and test helpers 1bd6a199f Don't need parent. Just use the whole path for the group id a2ab420b2 Committing so Jon can view code git-subtree-dir: spiffworkflow-backend git-subtree-split: 64ac7042887af80869963bc103c01f56404727f2
2022-11-09 20:02:19 +00:00
from spiffworkflow_backend.models.user import UserModel
from spiffworkflow_backend.services.process_instance_processor import (
ProcessInstanceProcessor,
)
from spiffworkflow_backend.services.user_service import UserService
class TestGetGroupMembers(BaseTest):
"""TestGetGroupMembers."""
def test_can_get_members_of_a_group(
self,
app: Flask,
Squashed 'spiffworkflow-backend/' changes from b8924100d..64ac70428 64ac70428 Move to Python 3.11 (#27) 167851df1 remove leading slash from model identifiers 3503fe400 one instance test left for cypress w/ burnettk 7e09363c4 merged in main and resolved conflicts w/ burnettk cullerton afbc3157d fixed some acceptance tests w/ burnettk cullerton 96e7b63c6 made a process model form w/ burnettk c19aac25f Somethings up w/authentication. Maybe the stored token is bad d17007eaa Merge branch 'main' into feature/nested-groups 729b13881 script to modify all model json files to use full path for model id. Also removes process_group_id 7856b8caa return next task when running an instance w/ burnettk d183b961c First pass at custom report/perspective for Process Instance List (#23) f303c0f77 remove process_group_identifier from process-instances endpoint 207de9ab8 Merge branch 'main' into feature/nested-groups fec8d06b8 started test for test_script_unit_test_run ea31c7a12 fixed process_model_identifier in script_unit_test_create 5d058cbea Fix url in test f8afd7bdd Remove the `_2` methods 7c13ec802 Fix urls for uspend and resume endpoints 19158d7b0 Get testing bpmn files out of the config directory 5f1ee7f16 fixed failing test de3b4b81d Merge branch 'main' into feature/nested-groups 440871d57 First stab at nested folders. Added temp endpoints Changes to tests and test helpers 1bd6a199f Don't need parent. Just use the whole path for the group id a2ab420b2 Committing so Jon can view code git-subtree-dir: spiffworkflow-backend git-subtree-split: 64ac7042887af80869963bc103c01f56404727f2
2022-11-09 20:02:19 +00:00
client: FlaskClient,
with_db_and_bpmn_file_cleanup: None,
Squashed 'spiffworkflow-backend/' changes from b8924100d..64ac70428 64ac70428 Move to Python 3.11 (#27) 167851df1 remove leading slash from model identifiers 3503fe400 one instance test left for cypress w/ burnettk 7e09363c4 merged in main and resolved conflicts w/ burnettk cullerton afbc3157d fixed some acceptance tests w/ burnettk cullerton 96e7b63c6 made a process model form w/ burnettk c19aac25f Somethings up w/authentication. Maybe the stored token is bad d17007eaa Merge branch 'main' into feature/nested-groups 729b13881 script to modify all model json files to use full path for model id. Also removes process_group_id 7856b8caa return next task when running an instance w/ burnettk d183b961c First pass at custom report/perspective for Process Instance List (#23) f303c0f77 remove process_group_identifier from process-instances endpoint 207de9ab8 Merge branch 'main' into feature/nested-groups fec8d06b8 started test for test_script_unit_test_run ea31c7a12 fixed process_model_identifier in script_unit_test_create 5d058cbea Fix url in test f8afd7bdd Remove the `_2` methods 7c13ec802 Fix urls for uspend and resume endpoints 19158d7b0 Get testing bpmn files out of the config directory 5f1ee7f16 fixed failing test de3b4b81d Merge branch 'main' into feature/nested-groups 440871d57 First stab at nested folders. Added temp endpoints Changes to tests and test helpers 1bd6a199f Don't need parent. Just use the whole path for the group id a2ab420b2 Committing so Jon can view code git-subtree-dir: spiffworkflow-backend git-subtree-split: 64ac7042887af80869963bc103c01f56404727f2
2022-11-09 20:02:19 +00:00
with_super_admin_user: UserModel,
) -> None:
"""Test_can_get_members_of_a_group."""
initiator_user = self.find_or_create_user("initiator_user")
testuser1 = self.find_or_create_user("testuser1")
testuser2 = self.find_or_create_user("testuser2")
testuser3 = self.find_or_create_user("testuser3")
group_a = GroupModel(identifier="groupA")
group_b = GroupModel(identifier="groupB")
db.session.add(group_a)
db.session.add(group_b)
db.session.commit()
UserService.add_user_to_group(testuser1, group_a)
UserService.add_user_to_group(testuser2, group_a)
UserService.add_user_to_group(testuser3, group_b)
Squashed 'spiffworkflow-backend/' changes from b8924100d..64ac70428 64ac70428 Move to Python 3.11 (#27) 167851df1 remove leading slash from model identifiers 3503fe400 one instance test left for cypress w/ burnettk 7e09363c4 merged in main and resolved conflicts w/ burnettk cullerton afbc3157d fixed some acceptance tests w/ burnettk cullerton 96e7b63c6 made a process model form w/ burnettk c19aac25f Somethings up w/authentication. Maybe the stored token is bad d17007eaa Merge branch 'main' into feature/nested-groups 729b13881 script to modify all model json files to use full path for model id. Also removes process_group_id 7856b8caa return next task when running an instance w/ burnettk d183b961c First pass at custom report/perspective for Process Instance List (#23) f303c0f77 remove process_group_identifier from process-instances endpoint 207de9ab8 Merge branch 'main' into feature/nested-groups fec8d06b8 started test for test_script_unit_test_run ea31c7a12 fixed process_model_identifier in script_unit_test_create 5d058cbea Fix url in test f8afd7bdd Remove the `_2` methods 7c13ec802 Fix urls for uspend and resume endpoints 19158d7b0 Get testing bpmn files out of the config directory 5f1ee7f16 fixed failing test de3b4b81d Merge branch 'main' into feature/nested-groups 440871d57 First stab at nested folders. Added temp endpoints Changes to tests and test helpers 1bd6a199f Don't need parent. Just use the whole path for the group id a2ab420b2 Committing so Jon can view code git-subtree-dir: spiffworkflow-backend git-subtree-split: 64ac7042887af80869963bc103c01f56404727f2
2022-11-09 20:02:19 +00:00
self.create_process_group(
client, with_super_admin_user, "test_group", "test_group"
)
process_model = load_test_spec(
Squashed 'spiffworkflow-backend/' changes from b8924100d..64ac70428 64ac70428 Move to Python 3.11 (#27) 167851df1 remove leading slash from model identifiers 3503fe400 one instance test left for cypress w/ burnettk 7e09363c4 merged in main and resolved conflicts w/ burnettk cullerton afbc3157d fixed some acceptance tests w/ burnettk cullerton 96e7b63c6 made a process model form w/ burnettk c19aac25f Somethings up w/authentication. Maybe the stored token is bad d17007eaa Merge branch 'main' into feature/nested-groups 729b13881 script to modify all model json files to use full path for model id. Also removes process_group_id 7856b8caa return next task when running an instance w/ burnettk d183b961c First pass at custom report/perspective for Process Instance List (#23) f303c0f77 remove process_group_identifier from process-instances endpoint 207de9ab8 Merge branch 'main' into feature/nested-groups fec8d06b8 started test for test_script_unit_test_run ea31c7a12 fixed process_model_identifier in script_unit_test_create 5d058cbea Fix url in test f8afd7bdd Remove the `_2` methods 7c13ec802 Fix urls for uspend and resume endpoints 19158d7b0 Get testing bpmn files out of the config directory 5f1ee7f16 fixed failing test de3b4b81d Merge branch 'main' into feature/nested-groups 440871d57 First stab at nested folders. Added temp endpoints Changes to tests and test helpers 1bd6a199f Don't need parent. Just use the whole path for the group id a2ab420b2 Committing so Jon can view code git-subtree-dir: spiffworkflow-backend git-subtree-split: 64ac7042887af80869963bc103c01f56404727f2
2022-11-09 20:02:19 +00:00
process_model_id="test_group/get_group_members",
bpmn_file_name="get_group_members.bpmn",
Squashed 'spiffworkflow-backend/' changes from b8924100d..64ac70428 64ac70428 Move to Python 3.11 (#27) 167851df1 remove leading slash from model identifiers 3503fe400 one instance test left for cypress w/ burnettk 7e09363c4 merged in main and resolved conflicts w/ burnettk cullerton afbc3157d fixed some acceptance tests w/ burnettk cullerton 96e7b63c6 made a process model form w/ burnettk c19aac25f Somethings up w/authentication. Maybe the stored token is bad d17007eaa Merge branch 'main' into feature/nested-groups 729b13881 script to modify all model json files to use full path for model id. Also removes process_group_id 7856b8caa return next task when running an instance w/ burnettk d183b961c First pass at custom report/perspective for Process Instance List (#23) f303c0f77 remove process_group_identifier from process-instances endpoint 207de9ab8 Merge branch 'main' into feature/nested-groups fec8d06b8 started test for test_script_unit_test_run ea31c7a12 fixed process_model_identifier in script_unit_test_create 5d058cbea Fix url in test f8afd7bdd Remove the `_2` methods 7c13ec802 Fix urls for uspend and resume endpoints 19158d7b0 Get testing bpmn files out of the config directory 5f1ee7f16 fixed failing test de3b4b81d Merge branch 'main' into feature/nested-groups 440871d57 First stab at nested folders. Added temp endpoints Changes to tests and test helpers 1bd6a199f Don't need parent. Just use the whole path for the group id a2ab420b2 Committing so Jon can view code git-subtree-dir: spiffworkflow-backend git-subtree-split: 64ac7042887af80869963bc103c01f56404727f2
2022-11-09 20:02:19 +00:00
process_model_source_directory="get_group_members",
)
process_instance = self.create_process_instance_from_process_model(
process_model=process_model, user=initiator_user
)
processor = ProcessInstanceProcessor(process_instance)
processor.do_engine_steps(save=True)
assert processor.bpmn_process_instance.data
assert processor.bpmn_process_instance.data["members_a"] == [
"testuser1",
"testuser2",
]
assert processor.bpmn_process_instance.data["members_b"] == ["testuser3"]