From d88577db2072fab583c54b238c17e6f9c19ab8f9 Mon Sep 17 00:00:00 2001 From: Stephen De Vight Date: Tue, 31 Oct 2023 12:37:16 -0700 Subject: [PATCH] adding call --- uw_adsel/__init__.py | 30 ++++++- .../v1/applications/AdmissionSelectionId/0/1 | 90 +++++++++++++++++++ uw_adsel/tests/test_adsel.py | 23 +++++ 3 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 uw_adsel/resources/adsel/file/api/v1/applications/AdmissionSelectionId/0/1 diff --git a/uw_adsel/__init__.py b/uw_adsel/__init__.py index 2a35ac3..ec94b3f 100644 --- a/uw_adsel/__init__.py +++ b/uw_adsel/__init__.py @@ -127,7 +127,35 @@ def _get_live_apps_by_qtr_syskey_list(self, quarter_id, applications = self._get_applications_from_json(response) return applications - def _get_applications_from_json(self, response): + def get_applications_by_qtr_adselid_list(self, + quarter_id, + adselid_list, + workspace_id): + if isinstance(self.DAO.get_implementation(), MockDAO): + all_applications = self._get_live_apps_by_qtr_adselid_list( + quarter_id, + adselid_list, + workspace_id) + return [app for app in all_applications + if app.adsel_id in adselid_list] + else: + return self._get_live_apps_by_qtr_adselid_list(quarter_id, + adselid_list, + workspace_id) + + def _get_live_apps_by_qtr_adselid_list(self, + quarter_id, + adselid_list, + workspace_id): + url = "{}/applications/AdmissionSelectionId/{}/{}".format(self.API, + quarter_id, + workspace_id) + response = self._post_resource(url, adselid_list) + applications = self._get_applications_from_json(response) + return applications + + @staticmethod + def _get_applications_from_json(response): applications = [] for app in response: application = Application() diff --git a/uw_adsel/resources/adsel/file/api/v1/applications/AdmissionSelectionId/0/1 b/uw_adsel/resources/adsel/file/api/v1/applications/AdmissionSelectionId/0/1 new file mode 100644 index 0000000..c8347cc --- /dev/null +++ b/uw_adsel/resources/adsel/file/api/v1/applications/AdmissionSelectionId/0/1 @@ -0,0 +1,90 @@ +[ + { + "admissionsSelectionId": 54687, + "applicationNbr": 1, + "systemKey": 456340, + "campus": 0, + "academicQtrKeyId": 0, + "assignedCohort": 1, + "assignedMajor": null, + "majorProgramCode": null, + "applicationType": "Postbac" + }, + { + "admissionsSelectionId": 84136, + "applicationNbr": 1, + "systemKey": 856340, + "campus": 0, + "academicQtrKeyId": 0, + "assignedCohort": 2, + "assignedMajor": "CSE", + "majorProgramCode": "0_CSE_123", + "applicationType": "Transfer" + }, + { + "admissionsSelectionId": 45743, + "applicationNbr": 1, + "systemKey": 156340, + "campus": 1, + "academicQtrKeyId": 0, + "assignedCohort": 2, + "assignedMajor": null, + "majorProgramCode": null, + "applicationType": "Transfer" + }, + { + "admissionsSelectionId": 73445, + "applicationNbr": 1, + "systemKey": 656340, + "campus": 1, + "academicQtrKeyId": 0, + "assignedCohort": null, + "assignedMajor": "CSE", + "majorProgramCode": "0_CSE_123", + "applicationType": "Transfer" + }, + { + "admissionsSelectionId": 17508, + "applicationNbr": 1, + "systemKey": 456340, + "campus": 0, + "academicQtrKeyId": 0, + "assignedCohort": 1, + "assignedMajor": null, + "majorProgramCode": null, + "applicationType": "Freshman" + }, + { + "admissionsSelectionId": 76512, + "applicationNbr": 1, + "systemKey": 97508, + "campus": 0, + "academicQtrKeyId": 0, + "assignedCohort": 2, + "assignedMajor": "CSE", + "majorProgramCode": "0_CSE_123", + "applicationType": "Freshman" + }, + { + "admissionsSelectionId": 35254, + "applicationNbr": 1, + "systemKey": 156340, + "campus": 1, + "academicQtrKeyId": 0, + "assignedCohort": 2, + "assignedMajor": null, + "majorProgramCode": null, + "applicationType": "Freshman" + }, + { + "admissionsSelectionId": 27865, + "applicationNbr": 1, + "systemKey": 76711, + "campus": 1, + "academicQtrKeyId": 0, + "assignedCohort": null, + "assignedMajor": "CSE", + "majorProgramCode": "0_CSE_123", + "applicationType": null + } +] \ No newline at end of file diff --git a/uw_adsel/tests/test_adsel.py b/uw_adsel/tests/test_adsel.py index 1df9b4b..cb82234 100644 --- a/uw_adsel/tests/test_adsel.py +++ b/uw_adsel/tests/test_adsel.py @@ -109,6 +109,29 @@ def test_get_applications_by_syskey_list(self): self.assertEqual(applications[0].application_type, "Postbac") self.assertIsNone(applications[5].application_type) + def test_get_applications_by_adselid_list(self): + # No Match + applications = self.adsel.get_applications_by_qtr_adselid_list(0, + [123], + 1) + self.assertEqual(len(applications), 0) + # Partial Match + applications = self.adsel.get_applications_by_qtr_adselid_list(0, + [123, + 54687, + 84136], + 1) + self.assertEqual(len(applications), 2) + # Full Match + applications = self.adsel.get_applications_by_qtr_adselid_list(0, + [73445, + 45743, + 17508, + 76512], + 1) + self.assertEqual(len(applications), 4) + self.assertEqual(applications[0].application_type, "Transfer") + def test_post(self): a1 = Application() a1.adsel_id = 123