Skip to content

Commit

Permalink
Merge pull request #14 from uw-it-aca/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
devights committed Aug 10, 2017
2 parents 912c315 + 4637096 commit ab9727f
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 10 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
author="UW-IT AXDD",
author_email="aca-it@uw.edu",
include_package_data=True,
install_requires=['UW-RestClients-Core>=0.9,<1.0',
'UW-RestClients-PWS>=0.5,<1.0',
install_requires=['UW-RestClients-Core<1.0',
'UW-RestClients-PWS<1.0',
'pytz'
],
license='Apache License, Version 2.0',
Expand Down
18 changes: 11 additions & 7 deletions uw_iasystem/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import json
import logging
from uw_iasystem.dao import IASystem_DAO
from restclients_core.exceptions import DataFailureException
from uw_iasystem.dao import IASystem_DAO
from uw_iasystem.exceptions import TermEvalNotCreated


logger = logging.getLogger(__name__)
Expand All @@ -19,11 +20,14 @@ def get_resource(url, campus):
"""
headers = {"Accept": "application/vnd.collection+json"}
response = IASystem_DAO(campus).getURL(url, headers)

logger.info("%s ==status==> %s" % (url, response.status))

if response.status != 200:
logger.error("%s ==data==> %s" % (url, response.data))
raise DataFailureException(url, response.status, response.data)
status = response.status
logger.info("%s ==status==> %s", url, status)
if status != 200:
message = response.data
logger.error("%s ==data==> %s", url, message)
if status == 400:
if "Term is out of range" in response.data:
raise TermEvalNotCreated(url, status, message)
raise DataFailureException(url, status, message)

return json.loads(response.data)
7 changes: 7 additions & 0 deletions uw_iasystem/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from restclients_core.exceptions import DataFailureException


class TermEvalNotCreated(DataFailureException):

def __init__(self, url, status, msg):
super(TermEvalNotCreated, self).__init__(url, status, msg)
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@
},
{
"rel": "self",
"href": "https://uw.iasysdev.org/api/v1/evaluation?student_id=1230430&term_name=Autumn&year=2014",
"href": "https://uw.iasysdev.org/api/v1/evaluation?instructor_id=123456789&term_name=Autumn&year=2014",
"prompt": "IASystem Evaluation Listing"
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"collection":{
"links":[
{"rel":"home","prompt":"IASystem v1 Web API","href":"https://uw.iasystem.org/api/v1"},
{"prompt":"IASystem Evaluation Listing","href":"https://uw.iasystem.org/api/v1/evaluation","rel":"self"}],
"queries":[
{"rel":"collection filter",
"href":"https://uw.iasystem.org/api/v1/evaluation",
"data":[
{"prompt":"Year",
"name":"year",
"required":true},
{"required":true,
"name":"term_name",
"prompt":"Term Name"},
{"name":"curriculum_abbreviation",
"prompt":"Curriculum Abbreviation"},
{"name":"course_number",
"prompt":"Course Number"},
{"name":"section_id",
"prompt":"Section ID"},
{"prompt":"Student ID",
"name":"student_id"},
{"prompt":"Instructor ID",
"name":"instructor_id"}],
"prompt":"Evaluation Search Resource"}],
"error":{"message":"The year and term_name parameters did not match an existing term.",
"title":"Term is out of range",
"code":400},
"version":"1.0",
"href":"https://uw.iasystem.org/api/v1/evaluation"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"status":400,
"headers":{}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"collection":{
"links":[
{"rel":"home","prompt":"IASystem v1 Web API","href":"https://uw.iasystem.org/api/v1"},
{"prompt":"IASystem Evaluation Listing","href":"https://uw.iasystem.org/api/v1/evaluation?year=2016&term_name=Autumn&instructor_id=123456789","rel":"self"}],
"queries":[
{"rel":"collection filter",
"href":"https://uw.iasystem.org/api/v1/evaluation",
"data":[
{"prompt":"Year",
"name":"year",
"required":true},
{"required":true,
"name":"term_name",
"prompt":"Term Name"},
{"name":"curriculum_abbreviation",
"prompt":"Curriculum Abbreviation"},
{"name":"course_number",
"prompt":"Course Number"},
{"name":"section_id",
"prompt":"Section ID"},
{"prompt":"Student ID",
"name":"student_id"},
{"prompt":"Instructor ID",
"name":"instructor_id"}],
"prompt":"Evaluation Search Resource"}],
"error":{"message":"...",
"title":"Internal Server Error",
"code":500},
"version":"1.0",
"href":"https://uw.iasystem.org/api/v1/evaluation"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"status":500,
"headers":{}
}
23 changes: 23 additions & 0 deletions uw_iasystem/tests/test_evaluation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import datetime
import pytz
from unittest import TestCase
from restclients_core.exceptions import DataFailureException
from uw_iasystem.exceptions import TermEvalNotCreated
from uw_iasystem.evaluation import search_evaluations,\
get_evaluation_by_id
from uw_iasystem.util import fdao_ias_override
Expand Down Expand Up @@ -159,3 +161,24 @@ def test_multiple_evals(self):
6, 59, 59,
tzinfo=pytz.utc))
self.assertTrue(evals[2].is_completed)

def test_search_eval_by_instructor(self):
evals = search_evaluations("seattle",
year=2014,
term_name='Autumn',
instructor_id=123456789)
try:
evals = search_evaluations("seattle",
year=2015,
term_name='Winter',
instructor_id=123456789)
except TermEvalNotCreated as ex:
self.assertEqual(ex.status, 400)

try:
evals = search_evaluations("seattle",
year=2016,
term_name='Winter',
instructor_id=123456789)
except DataFailureException as ex:
self.assertEqual(ex.status, 500)

0 comments on commit ab9727f

Please sign in to comment.