diff --git a/uw_adsel/__init__.py b/uw_adsel/__init__.py index b0a6a12..46ee0d9 100644 --- a/uw_adsel/__init__.py +++ b/uw_adsel/__init__.py @@ -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) @@ -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, @@ -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} diff --git a/uw_adsel/resources/adsel_azure/file/cohort b/uw_adsel/resources/adsel_azure/file/cohort deleted file mode 100644 index bc00bb9..0000000 --- a/uw_adsel/resources/adsel_azure/file/cohort +++ /dev/null @@ -1,17 +0,0 @@ -{ - "summaryPostStatus": "AzureSubmitSuccess", - "items": [ - { - "status": "string", - "application": { - "admissionSelectionId": 0, - "applicationNbr": 0, - "systemKey": 0 - }, - "cohortNbr": 0, - "majorAbbr": "string", - "message": "string" - } - ], - "message": "string" -} \ No newline at end of file diff --git a/uw_adsel/resources/adsel_azure/file/cohort/bulk b/uw_adsel/resources/adsel_azure/file/cohort/bulk new file mode 100644 index 0000000..e69de29 diff --git a/uw_adsel/tests/test_adsel.py b/uw_adsel/tests/test_adsel.py index 571ee6d..bf6059a 100644 --- a/uw_adsel/tests/test_adsel.py +++ b/uw_adsel/tests/test_adsel.py @@ -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): diff --git a/uw_adsel/tests/test_adselazure.py b/uw_adsel/tests/test_adselazure.py index 2e7ef17..7523e7c 100644 --- a/uw_adsel/tests/test_adselazure.py +++ b/uw_adsel/tests/test_adselazure.py @@ -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"], {})