Skip to content

Commit

Permalink
Merge pull request #18 from uw-it-aca/feature/apps_by_syskey_list
Browse files Browse the repository at this point in the history
syskey list feature
  • Loading branch information
devights committed Jan 16, 2021
2 parents 42170b4 + d33fb76 commit 81646be
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 0 deletions.
18 changes: 18 additions & 0 deletions uw_adsel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import logging
from restclients_core.exceptions import DataFailureException
from restclients_core.dao import MockDAO
from uw_adsel.dao import ADSEL_DAO
from uw_adsel.models import Major, Cohort, Quarter, Activity, Application
import dateutil.parser
Expand Down Expand Up @@ -88,6 +89,23 @@ def get_applications_by_qtr_syskey(self, quarter_id, syskey):
application = self._get_applications_from_json(response)
return application

def get_applications_by_qtr_syskey_list(self, quarter_id, syskey_list):
if isinstance(self.DAO.get_implementation(), MockDAO):
all_applications = self._get_live_apps_by_qtr_syskey_list(
quarter_id,
syskey_list)
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)
response = self._post_resource(url, syskey_list)
applications = self._get_applications_from_json(response)
return applications

def _get_applications_from_json(self, response):
applications = []
for app in response:
Expand Down
82 changes: 82 additions & 0 deletions uw_adsel/resources/adsel/file/api/v1/applications/SystemKeys/0
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
[
{
"admissionsSelectionId": 54687,
"applicationNbr": 1,
"systemKey": 456340,
"campus": 0,
"academicQtrKeyId": 0,
"assignedCohort": 1,
"assignedMajor": null,
"majorProgramCode": null
},
{
"admissionsSelectionId": 84136,
"applicationNbr": 1,
"systemKey": 856340,
"campus": 0,
"academicQtrKeyId": 0,
"assignedCohort": 2,
"assignedMajor": "CSE",
"majorProgramCode": "0_CSE_123"
},
{
"admissionsSelectionId": 45743,
"applicationNbr": 1,
"systemKey": 156340,
"campus": 1,
"academicQtrKeyId": 0,
"assignedCohort": 2,
"assignedMajor": null,
"majorProgramCode": null
},
{
"admissionsSelectionId": 73445,
"applicationNbr": 1,
"systemKey": 656340,
"campus": 1,
"academicQtrKeyId": 0,
"assignedCohort": null,
"assignedMajor": "CSE",
"majorProgramCode": "0_CSE_123"
},
{
"admissionsSelectionId": 17508,
"applicationNbr": 1,
"systemKey": 456340,
"campus": 0,
"academicQtrKeyId": 0,
"assignedCohort": 1,
"assignedMajor": null,
"majorProgramCode": null
},
{
"admissionsSelectionId": 76512,
"applicationNbr": 1,
"systemKey": 97508,
"campus": 0,
"academicQtrKeyId": 0,
"assignedCohort": 2,
"assignedMajor": "CSE",
"majorProgramCode": "0_CSE_123"
},
{
"admissionsSelectionId": 35254,
"applicationNbr": 1,
"systemKey": 156340,
"campus": 1,
"academicQtrKeyId": 0,
"assignedCohort": 2,
"assignedMajor": null,
"majorProgramCode": null
},
{
"admissionsSelectionId": 27865,
"applicationNbr": 1,
"systemKey": 76711,
"campus": 1,
"academicQtrKeyId": 0,
"assignedCohort": null,
"assignedMajor": "CSE",
"majorProgramCode": "0_CSE_123"
}
]
19 changes: 19 additions & 0 deletions uw_adsel/tests/test_adsel.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ def test_get_application(self):
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])
self.assertEqual(len(applications), 0)
# Partial Match
applications = self.adsel.get_applications_by_qtr_syskey_list(0,
[123,
76711,
656340])
self.assertEqual(len(applications), 2)
# Full Match
applications = self.adsel.get_applications_by_qtr_syskey_list(0,
[456340,
97508,
156340,
76711])
self.assertEqual(len(applications), 6)

def test_post(self):
a1 = Application()
a1.adsel_id = 123
Expand Down

0 comments on commit 81646be

Please sign in to comment.