Skip to content

Commit

Permalink
Merge pull request #42 from uw-it-aca/feature/apps-by-adsel-id
Browse files Browse the repository at this point in the history
adding call
  • Loading branch information
devights committed Oct 31, 2023
2 parents 2e595d9 + d88577d commit 7585b20
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 1 deletion.
30 changes: 29 additions & 1 deletion uw_adsel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
]
23 changes: 23 additions & 0 deletions uw_adsel/tests/test_adsel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7585b20

Please sign in to comment.