From 44a962c4638af1d74ce758a1971289276e81e38a Mon Sep 17 00:00:00 2001 From: Stephen De Vight Date: Tue, 24 Oct 2023 17:51:19 -0700 Subject: [PATCH] adding ws context to more endpoints --- uw_adsel/__init__.py | 34 +++++++++++++------ .../file/api/v1/applications/0/{123 => 123/1} | 0 .../file/api/v1/applications/0/{all => all/1} | 0 .../api/v1/applications/SystemKeys/{0 => 0/1} | 0 uw_adsel/tests/test_adsel.py | 13 ++++--- 5 files changed, 32 insertions(+), 15 deletions(-) rename uw_adsel/resources/adsel/file/api/v1/applications/0/{123 => 123/1} (100%) rename uw_adsel/resources/adsel/file/api/v1/applications/0/{all => all/1} (100%) rename uw_adsel/resources/adsel/file/api/v1/applications/SystemKeys/{0 => 0/1} (100%) diff --git a/uw_adsel/__init__.py b/uw_adsel/__init__.py index 9f7362a..2a35ac3 100644 --- a/uw_adsel/__init__.py +++ b/uw_adsel/__init__.py @@ -84,31 +84,45 @@ def _quarters_from_json(self, response): quarters.append(qtr) return quarters - def get_all_applications_by_qtr(self, quarter_id): - url = "{}/applications/{}/all".format(self.API, quarter_id) + def get_all_applications_by_qtr(self, quarter_id, workspace_id): + url = "{}/applications/{}/all/{}".format(self.API, + quarter_id, + workspace_id) response = self._get_resource(url) applications = self._get_applications_from_json(response) return applications - def get_applications_by_qtr_syskey(self, quarter_id, syskey): - url = "{}/applications/{}/{}".format(self.API, quarter_id, syskey) + def get_applications_by_qtr_syskey(self, quarter_id, syskey, workspace_id): + url = "{}/applications/{}/{}/{}".format(self.API, + quarter_id, + syskey, + workspace_id) response = self._get_resource(url) application = self._get_applications_from_json(response) return application - def get_applications_by_qtr_syskey_list(self, quarter_id, syskey_list): + def get_applications_by_qtr_syskey_list(self, + quarter_id, + syskey_list, + workspace_id): if isinstance(self.DAO.get_implementation(), MockDAO): all_applications = self._get_live_apps_by_qtr_syskey_list( quarter_id, - syskey_list) + syskey_list, + workspace_id) return [app for app in all_applications if app.system_key in syskey_list] else: return self._get_live_apps_by_qtr_syskey_list(quarter_id, - syskey_list) - - def _get_live_apps_by_qtr_syskey_list(self, quarter_id, syskey_list): - url = "{}/applications/SystemKeys/{}".format(self.API, quarter_id) + syskey_list, + workspace_id) + + def _get_live_apps_by_qtr_syskey_list(self, quarter_id, + syskey_list, + workspace_id): + url = "{}/applications/SystemKeys/{}/{}".format(self.API, + quarter_id, + workspace_id) response = self._post_resource(url, syskey_list) applications = self._get_applications_from_json(response) return applications diff --git a/uw_adsel/resources/adsel/file/api/v1/applications/0/123 b/uw_adsel/resources/adsel/file/api/v1/applications/0/123/1 similarity index 100% rename from uw_adsel/resources/adsel/file/api/v1/applications/0/123 rename to uw_adsel/resources/adsel/file/api/v1/applications/0/123/1 diff --git a/uw_adsel/resources/adsel/file/api/v1/applications/0/all b/uw_adsel/resources/adsel/file/api/v1/applications/0/all/1 similarity index 100% rename from uw_adsel/resources/adsel/file/api/v1/applications/0/all rename to uw_adsel/resources/adsel/file/api/v1/applications/0/all/1 diff --git a/uw_adsel/resources/adsel/file/api/v1/applications/SystemKeys/0 b/uw_adsel/resources/adsel/file/api/v1/applications/SystemKeys/0/1 similarity index 100% rename from uw_adsel/resources/adsel/file/api/v1/applications/SystemKeys/0 rename to uw_adsel/resources/adsel/file/api/v1/applications/SystemKeys/0/1 diff --git a/uw_adsel/tests/test_adsel.py b/uw_adsel/tests/test_adsel.py index 0b98efa..1df9b4b 100644 --- a/uw_adsel/tests/test_adsel.py +++ b/uw_adsel/tests/test_adsel.py @@ -81,27 +81,30 @@ def test_get_filtered_activities(self): self.assertEqual(len(activities), 4) def test_get_application(self): - applications = self.adsel.get_applications_by_qtr_syskey(0, 123) + applications = self.adsel.get_applications_by_qtr_syskey(0, 123, 1) self.assertEqual(len(applications), 4) self.assertEqual(applications[0].adsel_id, 1) def test_get_applications_by_syskey_list(self): # No Match applications = self.adsel.get_applications_by_qtr_syskey_list(0, - [123]) + [123], + 1) self.assertEqual(len(applications), 0) # Partial Match applications = self.adsel.get_applications_by_qtr_syskey_list(0, [123, 76711, - 656340]) + 656340], + 1) self.assertEqual(len(applications), 2) # Full Match applications = self.adsel.get_applications_by_qtr_syskey_list(0, [456340, 97508, 156340, - 76711]) + 76711], + 1) self.assertEqual(len(applications), 6) self.assertEqual(applications[0].application_type, "Postbac") self.assertIsNone(applications[5].application_type) @@ -160,7 +163,7 @@ def test_post(self): self.fail('assign_majors raised an exception') def test_get_all_app(self): - apps = self.adsel.get_all_applications_by_qtr(0) + apps = self.adsel.get_all_applications_by_qtr(0, 1) self.assertEqual(len(apps), 4) def test_purple_gold_assignment(self):