Skip to content

Commit

Permalink
Merge b0f406f into 5408238
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaney committed Oct 9, 2018
2 parents 5408238 + b0f406f commit 7b441e2
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -8,9 +8,9 @@ before_script:
- pip install nose2
- pip install coverage
- pip install commonconf
- pip install python-coveralls
- pip install coveralls
script:
- pycodestyle uw_myplan/ --exclude=uw_myplan/tests
- pycodestyle uw_myplan/
- coverage run --source=uw_myplan uw_myplan/test.py -v
after_script:
- coveralls
Expand Down
9 changes: 5 additions & 4 deletions uw_myplan/__init__.py
Expand Up @@ -5,8 +5,8 @@

from uw_myplan.dao import MyPlan_DAO
from restclients_core.exceptions import DataFailureException
from uw_myplan.models import MyPlan, MyPlanTerm, MyPlanCourse, \
MyPlanCourseSection
from uw_myplan.models import (
MyPlan, MyPlanTerm, MyPlanCourse, MyPlanCourseSection)
import json


Expand Down Expand Up @@ -53,5 +53,6 @@ def get_plan(regid, year, quarter, terms=4):
return plan


def get_plan_url(regid, year, quarter, terms):
return "/student/api/plan/v1/%s,%s,%s,%s" % (year, quarter, terms, regid)
def get_plan_url(regid, year, quarter, terms=4):
return "/student/api/plan/v1/{year},{quarter},{terms},{uwregid}".format(
year=year, quarter=quarter, terms=terms, uwregid=regid)
59 changes: 44 additions & 15 deletions uw_myplan/tests/test_myplan.py
@@ -1,10 +1,26 @@
from unittest import TestCase
from uw_myplan import get_plan
from uw_myplan import get_plan, get_plan_url


class MyPlanTestData(TestCase):
def test_plan_url(self):
self.assertEquals(
get_plan_url(
"9136CCB8F66711D5BE060004AC494FFE", 2013, "spring", 2), (
"/student/api/plan/v1/2013,spring,2,"
"9136CCB8F66711D5BE060004AC494FFE"))

self.assertEquals(
get_plan_url(
"9136CCB8F66711D5BE060004AC494FFE", 2012, "summer"), (
"/student/api/plan/v1/2012,summer,4,"
"9136CCB8F66711D5BE060004AC494FFE"))

def test_javerage(self):
plan = get_plan(regid="9136CCB8F66711D5BE060004AC494FFE", year=2013, quarter="spring", terms=4)
plan = get_plan(regid="9136CCB8F66711D5BE060004AC494FFE",
year=2013,
quarter="spring",
terms=4)
self.assertEquals(len(plan.terms), 4)

self.assertEquals(plan.terms[0].year, 2013)
Expand All @@ -22,14 +38,22 @@ def test_javerage(self):
self.assertEquals(len(plan.terms[2].courses), 0)
self.assertEquals(len(plan.terms[3].courses), 0)
term_data = plan.terms[0]
self.assertEquals(term_data.course_search_href,
"https://uwkseval.cac.washington.edu/student/myplan/mplogin/netid?rd=/student/myplan/course")
self.assertEquals(term_data.degree_audit_href,
"https://uwkseval.cac.washington.edu/student/myplan/mplogin/netid?rd=/student/myplan/audit/degree")
self.assertEquals(term_data.myplan_href,
"https://uwkseval.cac.washington.edu/student/myplan/mplogin/netid?rd=/student/myplan/plan/20132")
self.assertEquals(term_data.registration_href,
"https://uwkseval.cac.washington.edu/student/myplan/mplogin/netid?rd=/student/myplan/registration/20132")
self.assertEquals(
term_data.course_search_href, (
"https://uwkseval.cac.washington.edu/student/myplan/mplogin/"
"netid?rd=/student/myplan/course"))
self.assertEquals(
term_data.degree_audit_href, (
"https://uwkseval.cac.washington.edu/student/myplan/mplogin/"
"netid?rd=/student/myplan/audit/degree"))
self.assertEquals(
term_data.myplan_href, (
"https://uwkseval.cac.washington.edu/student/myplan/mplogin/"
"netid?rd=/student/myplan/plan/20132"))
self.assertEquals(
term_data.registration_href, (
"https://uwkseval.cac.washington.edu/student/myplan/mplogin/"
"netid?rd=/student/myplan/registration/20132"))
self.assertEquals(term_data.registered_courses_count, 0)
self.assertEquals(term_data.registered_sections_count, 0)
self.assertEquals(term_data.courses[0].registrations_available, True)
Expand All @@ -46,10 +70,15 @@ def test_json(self):
terms=4)
json_data = plan.json_data()
term_data = json_data["terms"][0]
self.assertEquals(term_data["courses"][0]["sections"][1]["section_id"], "AA")
self.assertEquals(
term_data["courses"][0]["sections"][1]["section_id"], "AA")
self.assertEquals(term_data["registered_courses_count"], 0)
self.assertEquals(term_data["registration_href"],
"https://uwkseval.cac.washington.edu/student/myplan/mplogin/netid?rd=/student/myplan/registration/20132")
self.assertEquals(term_data["course_search_href"],
"https://uwkseval.cac.washington.edu/student/myplan/mplogin/netid?rd=/student/myplan/course")
self.assertEquals(
term_data["registration_href"], (
"https://uwkseval.cac.washington.edu/student/myplan/mplogin/"
"netid?rd=/student/myplan/registration/20132"))
self.assertEquals(
term_data["course_search_href"], (
"https://uwkseval.cac.washington.edu/student/myplan/mplogin/"
"netid?rd=/student/myplan/course"))
self.assertEquals(term_data["quarter"], "Spring")

0 comments on commit 7b441e2

Please sign in to comment.