Skip to content

Commit

Permalink
Merge pull request #46 from uw-it-aca/feature/bulk-submit
Browse files Browse the repository at this point in the history
Feature/bulk submit
  • Loading branch information
devights authored Oct 30, 2024
2 parents 887725b + a1b6cf7 commit 5b00393
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 32 deletions.
17 changes: 11 additions & 6 deletions uw_adsel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ def assign_majors(self, major_assignment):
return {"response": response, "request": request}

def assign_cohorts_bulk(self, cohort_assignment):
url = "{}/assignments/cohort/bulk".format(self.API)
request = cohort_assignment.json_data()
response = self._post_resource(url, request)
return {"response": response, "request": request}
return AdSelAzure().assign_cohorts_bulk(cohort_assignment)

def assign_cohorts_manual(self, cohort_assignment):
return AdSelAzure().assign_cohorts_manual(cohort_assignment)
Expand Down Expand Up @@ -519,8 +516,10 @@ def _post_resource(self, url, request):
if response.status not in [200, 201]:
self._log_error(url, response)
raise DataFailureException(url, response.status, response.data)

return json.loads(response.data)
try:
return json.loads(response.data)
except json.JSONDecodeError:
return {}

def _put_resource(self, url, request):
response = self.DAO.putURL(url,
Expand Down Expand Up @@ -558,3 +557,9 @@ def assign_cohorts_manual(self, cohort_assignment):
request = cohort_assignment.json_data()
response = self._post_resource(url, request)
return {"response": response, "request": request}

def assign_cohorts_bulk(self, cohort_assignment):
url = "/cohort/bulk"
request = cohort_assignment.json_data()
response = self._post_resource(url, request)
return {"response": response, "request": request}
17 changes: 0 additions & 17 deletions uw_adsel/resources/adsel_azure/file/cohort

This file was deleted.

Empty file.
7 changes: 3 additions & 4 deletions uw_adsel/tests/test_adsel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ def test_get_majors(self):
self.assertEqual(len(workspace_majors), 1)
self.assertEqual(workspace_majors[0].assigned_count, 120)

def test_assign(self):
def test_assign_bulk(self):
cohort = CohortAssignment(cohort_number=1, campus=2)
submit = self.adsel.assign_cohorts_manual(cohort)
self.assertEqual(submit['response']['summaryPostStatus'],
"AzureSubmitSuccess")
submit = self.adsel.assign_cohorts_bulk(cohort)
self.assertEqual(submit['response'], {})

@mock.patch('uw_adsel.AdSel.get_now', side_effect=mocked_get_now)
def test_get_quarters(self, mock_obj):
Expand Down
9 changes: 4 additions & 5 deletions uw_adsel/tests/test_adselazure.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

class AdselTest(TestCase):
adsel = AdSelAzure()
cohort = CohortAssignment(cohort_number=1, campus=2)

def test_assign_cohort(self):
cohort = CohortAssignment(cohort_number=1, campus=2)
submit = self.adsel.assign_cohorts_manual(cohort)
self.assertEqual(submit['response']['summaryPostStatus'],
"AzureSubmitSuccess")
def test_bulk_assign(self):
submit = self.adsel.assign_cohorts_bulk(self.cohort)
self.assertEqual(submit["response"], {})

0 comments on commit 5b00393

Please sign in to comment.