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