Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/new cohort submit #45

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add support for assigning cohorts via new host
  • Loading branch information
devights committed Oct 29, 2024
commit bb858d9bd1dbe23ecbd15b7845a80c8fd9fdd100
25 changes: 16 additions & 9 deletions uw_adsel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
MAJOR_TYPE = "major"
COHORT_TYPE = "cohort"

class AdSelAzure(AdSel):

API = ''

def __init(self):
self.DAO = ADSEL_AZURE_DAO()
class AdSel(object):
"""
The AdSel object has methods for interacting with the AdSel API.
Expand All @@ -50,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 @@ -551,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}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"summaryPostStatus": "string",
"summaryPostStatus": "AzureSubmitSuccess",
"items": [
{
"status": "string",
Expand Down
9 changes: 4 additions & 5 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 @@ -38,8 +37,8 @@ def test_get_majors(self):
def test_assign(self):
cohort = CohortAssignment(cohort_number=1, campus=2)
submit = self.adsel.assign_cohorts_manual(cohort)
print(submit)
self.assertFalse(True)
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):
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")
Loading