Skip to content

Commit

Permalink
Merge pull request #41 from uw-it-aca/feature/more-ws-context
Browse files Browse the repository at this point in the history
adding ws context to more endpoints
  • Loading branch information
devights authored Oct 30, 2023
2 parents e782529 + 44a962c commit 2e595d9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
34 changes: 24 additions & 10 deletions uw_adsel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions uw_adsel/tests/test_adsel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 2e595d9

Please sign in to comment.