Skip to content

Commit

Permalink
Merge pull request #45 from uw-it-aca/feature/new-cohort-submit
Browse files Browse the repository at this point in the history
Feature/new cohort submit
  • Loading branch information
devights authored Oct 29, 2024
2 parents ec22bd4 + bb858d9 commit 887725b
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 7 deletions.
21 changes: 17 additions & 4 deletions uw_adsel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from restclients_core.exceptions import DataFailureException
from restclients_core.dao import MockDAO
from uw_adsel.dao import ADSEL_DAO
from uw_adsel.adselazure_dao import ADSEL_AZURE_DAO
from uw_adsel.models import Major, Cohort, Quarter, Activity, Application, \
Decision, AdminMajor, AdminCohort, Workspace
import dateutil.parser
Expand Down Expand Up @@ -44,10 +45,7 @@ def assign_cohorts_bulk(self, cohort_assignment):
return {"response": response, "request": request}

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

def assign_purple_gold(self, pg_assignments):
url = "{}/assignments/purpleAndGold".format(self.API)
Expand Down Expand Up @@ -545,3 +543,18 @@ def _post_headers(self):
def _log_error(self, url, response):
logger.error("{0} ==> status:{1} data:{2}".format(
url, response.status, response.data))


class AdSelAzure(AdSel):
"""
The AdSel object has methods for interacting with endpoints
deployed to azureapi
"""
def __init__(self):
self.DAO = ADSEL_AZURE_DAO()

def assign_cohorts_manual(self, cohort_assignment):
url = "/cohort"
request = cohort_assignment.json_data()
response = self._post_resource(url, request)
return {"response": response, "request": request}
15 changes: 15 additions & 0 deletions uw_adsel/adselazure_dao.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
Contains UW AdSEL Azure DAO implementations.
"""
from restclients_core.dao import DAO
from os.path import abspath, dirname
import os


class ADSEL_AZURE_DAO(DAO):
def service_name(self):
return 'adsel_azure'

def service_mock_paths(self):
path = [abspath(os.path.join(dirname(__file__), "resources"))]
return path
17 changes: 17 additions & 0 deletions uw_adsel/resources/adsel_azure/file/cohort
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"summaryPostStatus": "AzureSubmitSuccess",
"items": [
{
"status": "string",
"application": {
"admissionSelectionId": 0,
"applicationNbr": 0,
"systemKey": 0
},
"cohortNbr": 0,
"majorAbbr": "string",
"message": "string"
}
],
"message": "string"
}
11 changes: 8 additions & 3 deletions uw_adsel/tests/test_adsel.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from unittest import TestCase, mock
from restclients_core.exceptions import DataFailureException
from uw_adsel.utilities import fdao_adsel_override
from uw_adsel import AdSel
from uw_adsel.models import CohortAssignment, MajorAssignment, Application,\
PurpleGoldApplication, PurpleGoldAssignment, DecisionAssignment,\
from uw_adsel.models import CohortAssignment, MajorAssignment, Application, \
PurpleGoldApplication, PurpleGoldAssignment, DecisionAssignment, \
DepartmentalDecisionApplication
from datetime import datetime

Expand Down Expand Up @@ -35,6 +34,12 @@ def test_get_majors(self):
self.assertEqual(len(workspace_majors), 1)
self.assertEqual(workspace_majors[0].assigned_count, 120)

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

@mock.patch('uw_adsel.AdSel.get_now', side_effect=mocked_get_now)
def test_get_quarters(self, mock_obj):
quarters = self.adsel.get_quarters()
Expand Down
13 changes: 13 additions & 0 deletions uw_adsel/tests/test_adselazure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from unittest import TestCase
from uw_adsel import AdSelAzure
from uw_adsel.models import CohortAssignment


class AdselTest(TestCase):
adsel = AdSelAzure()

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")

0 comments on commit 887725b

Please sign in to comment.