From 45775fd968232fa775487051c4bca3f469a531f2 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Wed, 18 Dec 2024 18:04:57 -0500 Subject: [PATCH] chore: add pagerduty migrator tests --- .../lib/tests/pagerduty/test_migrate.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tools/migrators/lib/tests/pagerduty/test_migrate.py diff --git a/tools/migrators/lib/tests/pagerduty/test_migrate.py b/tools/migrators/lib/tests/pagerduty/test_migrate.py new file mode 100644 index 000000000..3926d8f92 --- /dev/null +++ b/tools/migrators/lib/tests/pagerduty/test_migrate.py @@ -0,0 +1,25 @@ +from unittest.mock import call, patch + +from lib.pagerduty.migrate import migrate + + +@patch("lib.pagerduty.migrate.MIGRATE_USERS", False) +@patch("lib.pagerduty.migrate.APISession") +@patch("lib.pagerduty.migrate.OnCallAPIClient") +def test_users_are_skipped_when_migrate_users_is_false(MockOnCallAPIClient, MockAPISession): + mock_session = MockAPISession.return_value + mock_session.list_all.return_value = [] + mock_oncall_client = MockOnCallAPIClient.return_value + + migrate() + + # Assert no user-related fetching or migration occurs + assert mock_session.list_all.call_args_list == [ + call("schedules", params={"include[]": "schedule_layers", "time_zone": "UTC"}), + call("escalation_policies"), + call("services", params={"include[]": "integrations"}), + call("vendors"), + # no user notification rules fetching + ] + + mock_oncall_client.list_users_with_notification_rules.assert_not_called()