diff --git a/redcap/methods/events.py b/redcap/methods/events.py index def5f3f..e8ea429 100644 --- a/redcap/methods/events.py +++ b/redcap/methods/events.py @@ -34,8 +34,8 @@ def export_events( Examples: >>> proj.export_events() - [{"event_name": "Event 1", "arm_num": 1, "unique_event_name": "event_1_arm_1", - "custom_event_label": null, "event_id": 1}] + [{'event_name': 'Event 1', 'arm_num': 1, 'unique_event_name': 'event_1_arm_1', + 'custom_event_label': '', 'event_id': ...}, {'event_name': 'Event 2', ...}] """ # pylint:enable=line-too-long payload = self._initialize_payload(content="event", format_type=format_type) diff --git a/redcap/methods/user_roles.py b/redcap/methods/user_roles.py index 06e8d55..09532e9 100644 --- a/redcap/methods/user_roles.py +++ b/redcap/methods/user_roles.py @@ -40,8 +40,8 @@ def export_user_roles( Examples: >>> proj.export_user_roles() - [{'unique_role_name': ..., 'role_label': 'Test role', 'design': '0', 'user_rights': '0', - 'data_access_groups': '0', 'reports': '0', 'stats_and_charts': '0', + [{'unique_role_name': ..., 'role_label': 'Test role', 'design': '0', 'alerts': '0', + 'user_rights': '0', 'data_access_groups': '0', 'reports': '0', 'stats_and_charts': '0', 'manage_survey_participants': '0', 'calendar': '0', 'data_import_tool': '0', 'data_comparison_tool': '0', 'logging': '0', 'file_repository': '0', 'data_quality_create': '0', 'data_quality_execute': '0', 'api_export': '0', diff --git a/redcap/methods/users.py b/redcap/methods/users.py index 9ed2084..cc88609 100644 --- a/redcap/methods/users.py +++ b/redcap/methods/users.py @@ -31,8 +31,8 @@ def export_users( Examples: >>> proj.export_users() [{'username': ..., 'email': ..., 'expiration': '', 'data_access_group': '', - 'data_access_group_id': '', 'design': 1, 'user_rights': 1, 'data_access_groups': 1, - 'reports': 1, ...}] + 'data_access_group_id': '', 'design': 1, 'alerts': 1, 'user_rights': 1, + 'data_access_groups': 1, 'reports': 1, ...}] """ payload = self._initialize_payload(content="user", format_type=format_type) return_type = self._lookup_return_type(format_type, request_type="export") diff --git a/tests/integration/test_long_project.py b/tests/integration/test_long_project.py index d5f59e3..c8c97f6 100644 --- a/tests/integration/test_long_project.py +++ b/tests/integration/test_long_project.py @@ -4,6 +4,8 @@ import pytest +from redcap import RedcapError + if not os.getenv("REDCAPDEMO_SUPERUSER_TOKEN"): pytest.skip( @@ -115,8 +117,8 @@ def test_arms_export(long_project): assert len(response) == 2 - arm_nums = list(response.keys()) - arm_names = list(response.values()) + arm_nums = [arm["arm_num"] for arm in response] + arm_names = [arm["name"] for arm in response] assert arm_nums == [1, 2] assert arm_names == ["Drug A", "Drug B"] @@ -137,8 +139,8 @@ def test_arms_import(long_project): response = long_project.export_arms() assert len(response) == 3 - arm_nums = list(response.keys()) - arm_names = list(response.values()) + arm_nums = [arm["arm_num"] for arm in response] + arm_names = [arm["name"] for arm in response] assert arm_nums == [1, 2, 3] assert arm_names == ["Drug A", "Drug B", "Drug C"] @@ -155,8 +157,8 @@ def test_arms_import_rename(long_project): assert len(response) == 3 - arm_nums = list(response.keys()) - arm_names = list(response.values()) + arm_nums = [arm["arm_num"] for arm in response] + arm_names = [arm["name"] for arm in response] assert arm_nums == [1, 2, 3] assert arm_names == ["Drug Alpha", "Drug B", "Drug C"] @@ -173,8 +175,8 @@ def test_arms_delete(long_project): assert len(response) == 2 - arm_nums = list(response.keys()) - arm_names = list(response.values()) + arm_nums = [arm["arm_num"] for arm in response] + arm_names = [arm["name"] for arm in response] assert arm_nums == [1, 2] assert arm_names == ["Drug Alpha", "Drug B"] @@ -182,10 +184,15 @@ def test_arms_delete(long_project): @pytest.mark.integration def test_arms_import_override(long_project): + # Cache current events, so they can be restored for subsequent tests + current_events = long_project.export_events() + new_arms = [{"arm_num": 3, "name": "Drug C"}] response = long_project.import_arms(new_arms) - assert response == 1 + # Add event for new arm + new_event = [{"event_name": "new_event", "arm_num": "3"}] + response = long_project.import_events(new_event) response = long_project.export_arms() @@ -195,13 +202,18 @@ def test_arms_import_override(long_project): response = long_project.import_arms(new_arms, override=1) assert response == 2 + # Confirm that there are no events associated with new override arms + with pytest.raises(RedcapError): + response = long_project.export_arms() - response = long_project.export_arms() + response = long_project.import_events(current_events) + assert response == 16 + response = long_project.export_arms() assert len(response) == 2 - arm_nums = list(response.keys()) - arm_names = list(response.values()) + arm_nums = [arm["arm_num"] for arm in response] + arm_names = [arm["name"] for arm in response] assert arm_nums == [1, 2] assert arm_names == ["Drug A", "Drug B"] @@ -233,6 +245,6 @@ def test_events_delete(long_project): assert response == 1 - response = long_project.export_arms() + response = long_project.export_events() assert len(response) == 16