diff --git a/uw_sws/enrollment.py b/uw_sws/enrollment.py index 14c2ecb..532c550 100644 --- a/uw_sws/enrollment.py +++ b/uw_sws/enrollment.py @@ -4,15 +4,17 @@ import logging import re from uw_pws import PWS -from uw_sws.models import (Term, StudentGrades, StudentCourseGrade, Enrollment, - Major, Minor, SectionReference, +from uw_sws.models import (StudentGrades, StudentCourseGrade, Enrollment, + Major, Minor, SectionReference, Term, IndependentStartSectionReference) from uw_sws import get_resource, parse_sws_date from uw_sws.section import get_section_by_url +from uw_sws.term import get_term_by_year_and_quarter logger = logging.getLogger(__name__) enrollment_res_url_prefix = "/student/v5/enrollment" +enrollment_search_url_prefix = "/student/v5/enrollment.json?reg_id=" def get_grades_by_regid_and_term(regid, term): @@ -46,6 +48,39 @@ def _json_to_grades(data, regid, term): return grades +def enrollment_search_by_regid(regid, + verbose='true', + transcriptable_course='all', + changed_since_date=''): + """ + See SWS Enrollment search resource spec at: + https://wiki.cac.washington.edu/x/_qjeAw + :return: a dictionary of {Term: Enrollment} + """ + url = "%s%s&verbose=%s&transcriptable_course=%s&changed_since_date=%s" %\ + (enrollment_search_url_prefix, + regid, + verbose, + transcriptable_course, + changed_since_date) + return _json_to_term_enrollment_dict(get_resource(url)) + + +def _json_to_term_enrollment_dict(json_data): + term_enrollment_dict = {} + if "Enrollments" not in json_data: + return term_enrollment_dict + for term_enro in json_data["Enrollments"]: + if "Term" in term_enro and\ + "Year" in term_enro["Term"] and\ + "Quarter" in term_enro["Term"]: + term = Term(year=term_enro["Term"]["Year"], + quarter=term_enro["Term"]["Quarter"].lower()) + enrollment = _json_to_enrollment(term_enro, term) + term_enrollment_dict[term] = enrollment + return term_enrollment_dict + + def get_enrollment_by_regid_and_term(regid, term): url = "%s/%s,%s,%s.json" % (enrollment_res_url_prefix, term.year, diff --git a/uw_sws/models.py b/uw_sws/models.py index d0822db..489cf0b 100644 --- a/uw_sws/models.py +++ b/uw_sws/models.py @@ -230,7 +230,15 @@ class Term(models.Model): registration_period3_end = models.DateTimeField(blank=True) def __eq__(self, other): - return self.year == other.year and self.quarter == other.quarter + return (other is not None and + type(self) == type(other) and + self.__key() == other.__key()) + + def __hash__(self): + return hash(self.__key()) + + def __key(self): + return (str(self.year), self.quarter) def is_grading_period_open(self): if self.quarter == self.SUMMER: diff --git a/uw_sws/resources/sws/file/student/v5/enrollment.json_reg_id_00000000000000000000000000000001_verbose_true_transcriptable_course_all_changed_since_date_ b/uw_sws/resources/sws/file/student/v5/enrollment.json_reg_id_00000000000000000000000000000001_verbose_true_transcriptable_course_all_changed_since_date_ new file mode 100644 index 0000000..e51e953 --- /dev/null +++ b/uw_sws/resources/sws/file/student/v5/enrollment.json_reg_id_00000000000000000000000000000001_verbose_true_transcriptable_course_all_changed_since_date_ @@ -0,0 +1,7 @@ +{ +"Current":{ +"Href":"\/student\/v5\/enrollment.json?reg_id=00000000000000000000000000000001&verbose=true&changed_since_date=&transcriptable_course=all", +"RegID":"00000000000000000000000000000001", +"Verbose":true}, +"Enrollments":[],"Next":null,"PageSize":"10","PageStart":"1","Previous":null,"TotalCount":0 +} diff --git a/uw_sws/resources/sws/file/student/v5/enrollment.json_reg_id_9136CCB8F66711D5BE060004AC494FFE_verbose_true_transcriptable_course_all_changed_since_date_ b/uw_sws/resources/sws/file/student/v5/enrollment.json_reg_id_9136CCB8F66711D5BE060004AC494FFE_verbose_true_transcriptable_course_all_changed_since_date_ new file mode 100644 index 0000000..e571a68 --- /dev/null +++ b/uw_sws/resources/sws/file/student/v5/enrollment.json_reg_id_9136CCB8F66711D5BE060004AC494FFE_verbose_true_transcriptable_course_all_changed_since_date_ @@ -0,0 +1,1291 @@ +{ + "Current": + { + "Href": "/student/v5/enrollment.json?reg_id=9136CCB8F66711D5BE060004AC494FFE&verbose=true&changed_since_date=&transcriptable_course=all", + "RegID": "9136CCB8F66711D5BE060004AC494FFE", + "Verbose": true + }, + "Enrollments": [ + { + "ClassLevel": "FRESHMAN", + "CurrentRegisteredCredits": null, + "EnrollmentStatus": "Registered", + "EnrollmentStatusDate": "", + "FullName": "John Joseph Average", + "HonorsProgram": false, + "LeaveEndQuarter": 0, + "LeaveEndYear": 0, + "Majors": [ + { + "Abbreviation": "PREMAJ", + "Campus": "Seattle", + "CollegeAbbreviation": "A & S", + "CollegeFullName": "COLLEGE OF ARTS & SCIENCES", + "DegreeLevel": 0, + "DegreeName": null, + "DegreeType": 0, + "FullName": "Pre Major (Arts & Sciences)", + "MajorName": "PRE MAJOR (A&S)", + "Pathway": 0, + "ShortName": "PRE MJR(A&S)" + } + ], + "Metadata": "EnrollmentSourceLocation=SDB;", + "Minors": [], + "PendingClassChange": false, + "PendingHonorsChange": false, + "PendingMajorChange": false, + "PendingResidentChange": false, + "PendingSpecialProgramChange": false, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "QtrGradePoints": 36.00, + "QtrGradedAttmp": 14.0, + "QtrNonGrdEarned": 2.0, + "RegID": "9136CCB8F66711D5BE060004AC494FFE", + "Registrations": [ + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "4.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "4.0", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/1996,autumn,CSE,142,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RepositoryTimeStamp": "3/28/2017 1:58:36 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "142", + "CurriculumAbbreviation": "CSE", + "Href": "/student/v5/course/1996,autumn,CSE,142/.json", + "Quarter": "autumn", + "SectionID": "", + "Year": 1996 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + }, + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "5.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "0.0", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/1996,autumn,MATH,126,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RepositoryTimeStamp": "3/28/2017 1:59:03 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "126", + "CurriculumAbbreviation": "MATH", + "Href": "/student/v5/course/1996,autumn,MATH,126/.json", + "Quarter": "autumn", + "SectionID": "", + "Year": 1996 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + }, + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "4.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "4.0", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/1996,autumn,PHYS,121,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RepositoryTimeStamp": "3/28/2017 1:59:16 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "121", + "CurriculumAbbreviation": "PHYS", + "Href": "/student/v5/course/1996,autumn,PHYS,121/.json", + "Quarter": "autumn", + "SectionID": "", + "Year": 1996 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + }, + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "1.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "4.0", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/1996,autumn,PHYS,131,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RepositoryTimeStamp": "3/28/2017 1:59:17 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "131", + "CurriculumAbbreviation": "PHYS", + "Href": "/student/v5/course/1996,autumn,PHYS,131/.json", + "Quarter": "autumn", + "SectionID": "", + "Year": 1996 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + } + ], + "RepositoryTimeStamp": "3/28/2017 2:35:26 PM", + "Term": { + "Href": "/student/v5/term/1996,autumn.json", + "Quarter": "autumn", + "Year": 1996 + } + }, + { + "ClassLevel": "SOPHOMORE", + "CurrentRegisteredCredits": null, + "EnrollmentStatus": "Registered", + "EnrollmentStatusDate": "", + "FullName": "James McMiddle Average", + "HonorsProgram": false, + "LeaveEndQuarter": 0, + "LeaveEndYear": 0, + "Majors": [ + { + "Abbreviation": "PREMAJ", + "Campus": "Seattle", + "CollegeAbbreviation": "A & S", + "CollegeFullName": "COLLEGE OF ARTS & SCIENCES", + "DegreeLevel": 0, + "DegreeName": null, + "DegreeType": 0, + "FullName": "Pre Major (Arts & Sciences)", + "MajorName": "PRE MAJOR (A&S)", + "Pathway": 0, + "ShortName": "PRE MJR(A&S)" + } + ], + "Metadata": "EnrollmentSourceLocation=SDB;", + "Minors": [], + "PendingClassChange": false, + "PendingHonorsChange": false, + "PendingMajorChange": false, + "PendingResidentChange": false, + "PendingSpecialProgramChange": false, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "QtrGradePoints": 44.00, + "QtrGradedAttmp": 11.0, + "QtrNonGrdEarned": 4.0, + "RegID": "9136CCB8F66711D5BE060004AC494FFE", + "Registrations": [ + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "3.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "4.0", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/1997,spring,MATH,307,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RepositoryTimeStamp": "3/28/2017 1:57:16 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "307", + "CurriculumAbbreviation": "MATH", + "Href": "/student/v5/course/1997,spring,MATH,307/.json", + "Quarter": "spring", + "SectionID": "", + "Year": 1997 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + }, + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "3.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "4.0", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/1997,spring,MATH,308,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RepositoryTimeStamp": "3/28/2017 1:57:16 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "308", + "CurriculumAbbreviation": "MATH", + "Href": "/student/v5/course/1997,spring,MATH,308/.json", + "Quarter": "spring", + "SectionID": "", + "Year": 1997 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + }, + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "4.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "4.0", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/1997,spring,PHYS,122,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RepositoryTimeStamp": "3/28/2017 1:57:27 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "122", + "CurriculumAbbreviation": "PHYS", + "Href": "/student/v5/course/1997,spring,PHYS,122/.json", + "Quarter": "spring", + "SectionID": "", + "Year": 1997 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + }, + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "1.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "4.0", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/1997,spring,PHYS,132,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RepositoryTimeStamp": "3/28/2017 1:57:27 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "132", + "CurriculumAbbreviation": "PHYS", + "Href": "/student/v5/course/1997,spring,PHYS,132/.json", + "Quarter": "spring", + "SectionID": "", + "Year": 1997 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + }, + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "4.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "S", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/1997,spring,QMETH,201,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RepositoryTimeStamp": "3/28/2017 1:57:32 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "201", + "CurriculumAbbreviation": "QMETH", + "Href": "/student/v5/course/1997,spring,QMETH,201/.json", + "Quarter": "spring", + "SectionID": "", + "Year": 1997 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + } + ], + "RepositoryTimeStamp": "3/28/2017 2:34:51 PM", + "Term": { + "Href": "/student/v5/term/1997,spring.json", + "Quarter": "spring", + "Year": 1997 + } + }, + { + "ClassLevel": "JUNIOR", + "CurrentRegisteredCredits": null, + "EnrollmentStatus": "Registered", + "EnrollmentStatusDate": "", + "FullName": "James McMiddle Average", + "HonorsProgram": false, + "LeaveEndQuarter": 0, + "LeaveEndYear": 0, + "Majors": [ + { + "Abbreviation": "B A", + "Campus": "Seattle", + "CollegeAbbreviation": "B A", + "CollegeFullName": "FOSTER SCHOOL OF BUSINESS", + "DegreeLevel": 1, + "DegreeName": "BACHELOR OF ARTS IN BUSINESS ADMINISTRATION", + "DegreeType": 2, + "FullName": "Business Administration", + "MajorName": "BUSINESS ADMINISTRATION", + "Pathway": 0, + "ShortName": "BUSINESS ADM" + } + ], + "Metadata": "EnrollmentSourceLocation=SDB;", + "Minors": [], + "PendingClassChange": false, + "PendingHonorsChange": false, + "PendingMajorChange": false, + "PendingResidentChange": false, + "PendingSpecialProgramChange": false, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "QtrGradePoints": 46.60, + "QtrGradedAttmp": 12.0, + "QtrNonGrdEarned": 0.0, + "RegID": "9136CCB8F66711D5BE060004AC494FFE", + "Registrations": [ + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "3.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "3.7", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/1998,autumn,CSE,322,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": true, + "RepositoryTimeStamp": "3/28/2017 1:55:11 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "322", + "CurriculumAbbreviation": "CSE", + "Href": "/student/v5/course/1998,autumn,CSE,322/.json", + "Quarter": "autumn", + "SectionID": "", + "Year": 1998 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + }, + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "4.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "4.0", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/1998,autumn,CSE,451,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RepositoryTimeStamp": "3/28/2017 1:55:12 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "451", + "CurriculumAbbreviation": "CSE", + "Href": "/student/v5/course/1998,autumn,CSE,451/.json", + "Quarter": "autumn", + "SectionID": "", + "Year": 1998 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + }, + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "5.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "3.9", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/1998,autumn,LING,100,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RepositoryTimeStamp": "3/28/2017 1:55:35 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "100", + "CurriculumAbbreviation": "LING", + "Href": "/student/v5/course/1998,autumn,LING,100/.json", + "Quarter": "autumn", + "SectionID": "", + "Year": 1998 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + }, + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "2.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "4.0", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/1998,autumn,MUSIC,116,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": true, + "RepositoryTimeStamp": "3/28/2017 1:55:43 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "116", + "CurriculumAbbreviation": "MUSIC", + "Href": "/student/v5/course/1998,autumn,MUSIC,116/.json", + "Quarter": "autumn", + "SectionID": "", + "Year": 1998 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + } + ], + "RepositoryTimeStamp": "3/28/2017 2:34:21 PM", + "Term": { + "Href": "/student/v5/term/1998,autumn.json", + "Quarter": "autumn", + "Year": 1998 + } + }, + { + "ClassLevel": "SENIOR", + "CurrentRegisteredCredits": null, + "EnrollmentStatus": "Registered", + "EnrollmentStatusDate": "2012-03-15", + "FullName": "James McMiddle Average", + "HonorsProgram": false, + "LeaveEndQuarter": 0, + "LeaveEndYear": 0, + "Majors": [ + { + "Abbreviation": "C SCI", + "Campus": "Seattle", + "CollegeAbbreviation": "A & S", + "CollegeFullName": "COLLEGE OF ARTS & SCIENCES", + "DegreeLevel": 1, + "DegreeName": "BACHELOR OF SCIENCE (COMPUTER SCIENCE)", + "DegreeType": 5, + "FullName": "Computer Science", + "MajorName": "COMPUTER SCIENCE", + "Pathway": 0, + "ShortName": "COMPUTER SCI" + } + ], + "Metadata": "EnrollmentSourceLocation=SDB;", + "Minors": [ + { + "Abbreviation": "MATH", + "CampusName": "Seattle", + "FullName": "Mathematics", + "Name": "MATHEMATICS", + "Pathway": 0, + "ShortName": "MATH" + } + ], + "PendingClassChange": false, + "PendingHonorsChange": false, + "PendingMajorChange": false, + "PendingResidentChange": false, + "PendingSpecialProgramChange": false, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "QtrGradePoints": 11.40, + "QtrGradedAttmp": 3.0, + "QtrNonGrdEarned": 5.0, + "RegID": "9136CCB8F66711D5BE060004AC494FFE", + "Registrations": [ + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "3.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "3.8", + "GradeDate": "", + "GradeDocumentID": "4190099999", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/2012,spring,CSE,498,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RepositoryTimeStamp": "3/28/2017 1:51:39 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "498", + "CurriculumAbbreviation": "CSE", + "Href": "/student/v5/course/2012,spring,CSE,498/.json", + "Quarter": "spring", + "SectionID": "", + "Year": 2012 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + }, + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "3.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "W", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/2012,spring,MATH,301,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RepositoryTimeStamp": "3/28/2017 1:52:03 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "301", + "CurriculumAbbreviation": "MATH", + "Href": "/student/v5/course/2012,spring,MATH,301/.json", + "Quarter": "spring", + "SectionID": "", + "Year": 2012 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + }, + { + "AccessDateRangeEnd": "", + "AccessDateRangeStart": "", + "Auditor": false, + "Credits": "5.0", + "DuplicateCode": "0", + "EducationUnitType": null, + "EndDate": "", + "FeeBaseType": "", + "Grade": "S", + "GradeDate": "", + "GradeDocumentID": "", + "GradingSystem": null, + "HonorsCourse": false, + "Href": "/student/v5/registration/2012,spring,STAT,311,,9136CCB8F66711D5BE060004AC494FFE,0.json", + "Instructor": null, + "IsActive": true, + "IsCredit": true, + "IsIndependentStart": false, + "Metadata": "RegistrationSourceLocation=SDB;", + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RepositoryTimeStamp": "3/28/2017 1:52:26 PM", + "RequestDate": "", + "RequestStatus": "", + "Section": { + "CourseNumber": "311", + "CurriculumAbbreviation": "STAT", + "Href": "/student/v5/course/2012,spring,STAT,311/.json", + "Quarter": "spring", + "SectionID": "", + "Year": 2012 + }, + "StartDate": "", + "VariableCredit": false, + "WritingCourse": false + } + ], + "RepositoryTimeStamp": "3/28/2017 2:33:14 PM", + "Term": { + "Href": "/student/v5/term/2012,spring.json", + "Quarter": "spring", + "Year": 2012 + } + }, + { + "ClassLevel": "SENIOR", + "CurrentRegisteredCredits": null, + "EnrollmentStatus": "Registered", + "EnrollmentStatusDate": "2013-06-08", + "FullName": "James McMiddle Average", + "HonorsProgram": false, + "LeaveEndQuarter": 0, + "LeaveEndYear": 0, + "Majors": [ + {"Abbreviation": "ACMS", + "Campus": "Seattle", + "DegreeLevel": 1, + "DegreeName": "BACHELOR OF SCIENCE (APPLIED & COMPUTATIONAL MATH SCIENCES)", + "DegreeType": 5, + "FullName": "App & Comp Math Sci (Social & Behav Sci)", + "MajorName": "ACMS (SOC & BEH SCI)", + "Pathway": 80, + "ShortName": "ACMS (SBS)" + } + ], + "Metadata": "EnrollmentSourceLocation=SDB;", + "Minors": [ + {"Abbreviation":"ASL", + "CampusName":"Seattle", + "FullName":"American Sign Language", + "Name":"AMERICAN SIGN LANGUAGE", + "Pathway":0, + "ShortName":"ASL"} + ], + "PendingClassChange": false, + "PendingHonorsChange": false, + "PendingMajorChange": false, + "PendingResidentChange": false, + "PendingSpecialProgramChange": false, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "James McMiddle Average", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "QtrGradePoints": 30, + "QtrGradedAttmp": 10, + "QtrNonGrdEarned": 2, + "RegID": "9136CCB8F66711D5BE060004AC494FFE", + "Registrations": [ + { + "AddAccessCode": "", + "Auditor": false, + "Credits": " 2.0", + "DropAccessCode": "", + "DuplicateCode": "1", + "FacultySequenceNumber": "", + "FeeBaseType": "", + "Grade": "CR", + "GradeDate": "", + "GradeDocumentID": "061102100", + "HonorsCourse": false, + "IsActive": true, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "AVERAGE,JAMES", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RequestDate": "", + "RequestStatus": "", + "Section": { + "Href": "/student/v5/course/2013,spring,TRAIN,101/A.json", + "CourseNumber": "101", + "CurriculumAbbreviation": "TRAIN", + "Quarter": "spring", + "SectionID": "A", + "Year": "2013" + }, + "VariableCredit": false, + "WritingCourse": false + }, + { + "AddAccessCode": "", + "Auditor": false, + "Credits": " 5.0", + "DropAccessCode": "", + "DuplicateCode": "1", + "FacultySequenceNumber": "", + "FeeBaseType": "", + "Grade": "2.9", + "GradeDate": "", + "GradeDocumentID": "061702503", + "HonorsCourse": false, + "IsActive": true, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "AVERAGE,JAMES", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RequestDate": "", + "RequestStatus": "", + "Section": { + "Href": "/student/v5/course/2013,spring,TRAIN,100/A.json", + "CourseNumber": "100", + "CurriculumAbbreviation": "TRAIN", + "Quarter": "spring", + "SectionID": "A", + "Year": "2013" + }, + "VariableCredit": false, + "WritingCourse": false + }, + { + "AddAccessCode": "", + "Auditor": false, + "Credits": " 3.0", + "DropAccessCode": "", + "DuplicateCode": "1", + "FacultySequenceNumber": "", + "FeeBaseType": "", + "Grade": "3.1", + "GradeDate": "", + "GradeDocumentID": "061702510", + "HonorsCourse": false, + "IsActive": true, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "AVERAGE,JAMES", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RequestDate": "", + "RequestStatus": "", + "Section": { + "Href": "/student/v5/course/2013,spring,PHYS,121/A.json", + "CourseNumber": "121", + "CurriculumAbbreviation": "PHYS", + "Quarter": "spring", + "SectionID": "A", + "Year": "2013" + }, + "VariableCredit": false, + "WritingCourse": true + }, + { + "AddAccessCode": "", + "Auditor": false, + "Credits": " 1.0", + "DropAccessCode": "", + "DuplicateCode": "1", + "FacultySequenceNumber": "", + "FeeBaseType": "", + "Grade": "3.1", + "GradeDate": "", + "GradeDocumentID": "061702510", + "HonorsCourse": false, + "IsActive": true, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "AVERAGE,JAMES", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RequestDate": "", + "RequestStatus": "", + "Section": { + "Href": "/student/v5/course/2013,spring,PHYS,121/AC.json", + "CourseNumber": "121", + "CurriculumAbbreviation": "PHYS", + "Quarter": "spring", + "SectionID": "AC", + "Year": "2013" + }, + "VariableCredit": false, + "WritingCourse": true + }, + { + "AddAccessCode": "", + "Auditor": false, + "Credits": " 1.0", + "DropAccessCode": "", + "DuplicateCode": "1", + "FacultySequenceNumber": "", + "FeeBaseType": "", + "Grade": "3.1", + "GradeDate": "", + "GradeDocumentID": "061702510", + "HonorsCourse": false, + "IsActive": true, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "AVERAGE,JAMES", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RequestDate": "", + "RequestStatus": "", + "Section": { + "Href": "/student/v5/course/2013,spring,PHYS,121/AQ.json", + "CourseNumber": "121", + "CurriculumAbbreviation": "PHYS", + "Quarter": "spring", + "SectionID": "AQ", + "Year": "2013" + }, + "VariableCredit": false, + "WritingCourse": true + } + ], + "RepositoryTimeStamp": "3/28/2017 2:21:36 PM", + "Term": { + "Href": "/student/v5/term/2013,spring.json", + "Quarter": "spring", + "Year": 2013 + } + }, + { + "ClassLevel": "SENIOR", + "FullName": "AVERAGE,JAMES", + "HonorsProgram": false, + "LeaveEndQuarter": 0, + "LeaveEndYear": 0, + "Majors": [ + { + "Abbreviation": "ACMS", + "Campus": "Seattle", + "DegreeLevel": 1, + "DegreeName": "BACHELOR OF SCIENCE (APPLIED & COMPUTATIONAL MATH SCIENCES)", + "DegreeType": 5, + "FullName": "App & Comp Math Sci (Social & Behav Sci)", + "MajorName": "ACMS (SOC & BEH SCI)", + "Pathway": 80, + "ShortName": "ACMS (SBS)" + } + ], + "PendingClassChange": false, + "PendingHonorsChange": false, + "PendingMajorChange": false, + "PendingResidentChange": false, + "PendingSpecialProgramChange": false, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "AVERAGE,JAMES", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "QtrGradePoints": 30, + "QtrGradedAttmp": 10, + "QtrNonGrdEarned": 2, + "RegID": "9136CCB8F66711D5BE060004AC494FFE", + "Registrations": [ + { + "AddAccessCode": "", + "Auditor": false, + "Credits": " 2.0", + "DropAccessCode": "", + "DuplicateCode": "0", + "FacultySequenceNumber": "", + "FeeBaseType": "", + "Grade": "CR", + "GradeDate": "", + "GradeDocumentID": "061102100", + "HonorsCourse": false, + "IsActive": true, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "AVERAGE,JAMES", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RequestDate": "", + "RequestStatus": "", + "Section": { + "Href": "/student/v5/course/2013,summer,TRAIN,101/A.json", + "CourseNumber": "101", + "CurriculumAbbreviation": "TRAIN", + "Quarter": "summer", + "SectionID": "A", + "Year": "2013" + }, + "VariableCredit": false, + "WritingCourse": false + }, + { + "AddAccessCode": "", + "Auditor": false, + "Credits": " 5.0", + "DropAccessCode": "", + "DuplicateCode": "0", + "FacultySequenceNumber": "", + "FeeBaseType": "", + "Grade": "2.9", + "GradeDate": "", + "GradeDocumentID": "061702503", + "HonorsCourse": false, + "IsActive": true, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "AVERAGE,JAMES", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RequestDate": "", + "RequestStatus": "", + "Section": { + "Href": "/student/v5/course/2013,summer,TRAIN,100/A.json", + "CourseNumber": "100", + "CurriculumAbbreviation": "TRAIN", + "Quarter": "summer", + "SectionID": "A", + "Year": "2013" + }, + "VariableCredit": false, + "WritingCourse": false + }, + { + "AddAccessCode": "", + "Auditor": false, + "Credits": " 3.0", + "DropAccessCode": "", + "DuplicateCode": "0", + "FacultySequenceNumber": "", + "FeeBaseType": "", + "Grade": "3.1", + "GradeDate": "", + "GradeDocumentID": "061702510", + "HonorsCourse": false, + "IsActive": true, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "AVERAGE,JAMES", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RequestDate": "", + "RequestStatus": "", + "Section": { + "Href": "/student/v5/course/2013,summer,PHYS,121/A.json", + "CourseNumber": "121", + "CurriculumAbbreviation": "PHYS", + "Quarter": "summer", + "SectionID": "A", + "Year": "2013" + }, + "VariableCredit": false, + "WritingCourse": true + }, + { + "AddAccessCode": "", + "Auditor": false, + "Credits": " 1.0", + "DropAccessCode": "", + "DuplicateCode": "0", + "FacultySequenceNumber": "", + "FeeBaseType": "", + "Grade": "3.1", + "GradeDate": "", + "GradeDocumentID": "061702510", + "HonorsCourse": false, + "IsActive": true, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "AVERAGE,JAMES", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RequestDate": "", + "RequestStatus": "", + "Section": { + "Href": "/student/v5/course/2013,summer,PHYS,121/AC.json", + "CourseNumber": "121", + "CurriculumAbbreviation": "PHYS", + "Quarter": "summer", + "SectionID": "AC", + "Year": "2013" + }, + "VariableCredit": false, + "WritingCourse": true + }, + { + "AddAccessCode": "", + "Auditor": false, + "Credits": " 1.0", + "DropAccessCode": "", + "DuplicateCode": "0", + "FacultySequenceNumber": "", + "FeeBaseType": "", + "Grade": "3.1", + "GradeDate": "", + "GradeDocumentID": "061702510", + "HonorsCourse": false, + "IsActive": true, + "Person": { + "Href": "/student/v5/person/9136CCB8F66711D5BE060004AC494FFE.json", + "Name": "AVERAGE,JAMES", + "RegID": "9136CCB8F66711D5BE060004AC494FFE" + }, + "RepeatCourse": false, + "RequestDate": "", + "RequestStatus": "", + "Section": { + "Href": "/student/v5/course/2013,summer,PHYS,121/AQ.json", + "CourseNumber": "121", + "CurriculumAbbreviation": "PHYS", + "Quarter": "summer", + "SectionID": "AQ", + "Year": "2013" + }, + "VariableCredit": false, + "WritingCourse": true + } + ], + "RepositoryTimeStamp": "3/28/2017 2:35:26 PM", + "Term": { + "Href": "/student/v5/term/2013,summer.json", + "Quarter": "summer", + "Year": "2013" + } + } + ], + "Next": null, + "PageSize": "10", + "PageStart": "1", + "Previous": null, + "TotalCount": 6 +} diff --git a/uw_sws/tests/test_enrollment.py b/uw_sws/tests/test_enrollment.py index a674ed5..a67132e 100644 --- a/uw_sws/tests/test_enrollment.py +++ b/uw_sws/tests/test_enrollment.py @@ -1,9 +1,11 @@ from unittest import TestCase from uw_sws.util import fdao_sws_override from uw_pws.util import fdao_pws_override -from uw_sws.term import get_current_term, get_term_by_year_and_quarter +from uw_sws.models import Term +from uw_sws.term import get_current_term, get_next_term,\ + get_term_by_year_and_quarter, get_term_after from uw_sws.enrollment import get_grades_by_regid_and_term,\ - get_enrollment_by_regid_and_term + get_enrollment_by_regid_and_term, enrollment_search_by_regid from restclients_core.exceptions import DataFailureException @@ -88,3 +90,35 @@ def test_offterm_enrolled_courses(self): 'section_label': u'2013,winter,PSYCH,203/A', 'url': u'/student/v5/course/2013,winter,PSYCH,203/A.json', 'year': 2013}) + + def test_enrollment_search(self): + result_dict = enrollment_search_by_regid( + '9136CCB8F66711D5BE060004AC494FFE') + self.assertEqual(len(result_dict), 6) + term = get_current_term() + self.assertTrue(term in result_dict) + self.assertIsNotNone(result_dict.get(term)) + enrollement = result_dict.get(term) + self.assertEquals(enrollement.class_level, "SENIOR") + self.assertEquals(len(enrollement.majors), 1) + self.assertEquals(len(enrollement.minors), 1) + + term2 = get_term_by_year_and_quarter(2013, 'autumn') + self.assertIsNone(result_dict.get(term2)) + + term3 = get_term_by_year_and_quarter(2012, 'spring') + self.assertTrue(term3 in result_dict) + self.assertIsNotNone(result_dict.get(term3)) + + term1 = get_term_by_year_and_quarter(2013, 'summer') + self.assertTrue(term1 in result_dict) + self.assertIsNotNone(result_dict.get(term1)) + + term4 = Term(year=1996, quarter='autumn') + self.assertTrue(term4 in result_dict) + self.assertIsNotNone(result_dict.get(term4)) + + # regid of none + result_dict = enrollment_search_by_regid( + '00000000000000000000000000000001') + self.assertEqual(len(result_dict), 0) diff --git a/uw_sws/tests/test_term.py b/uw_sws/tests/test_term.py index 2207d36..75cd5f0 100644 --- a/uw_sws/tests/test_term.py +++ b/uw_sws/tests/test_term.py @@ -3,6 +3,7 @@ from uw_pws.util import fdao_pws_override from datetime import datetime, timedelta from restclients_core.exceptions import DataFailureException +from uw_sws.models import Term from uw_sws.term import get_term_by_year_and_quarter,\ get_term_before, get_term_after, get_current_term, get_next_term,\ get_previous_term, get_term_by_date, get_specific_term,\ @@ -503,3 +504,16 @@ def test_by_date(self): self.assertEquals(term.year, 2013) self.assertEquals(term.quarter, 'autumn') + def test_key(self): + term = Term() + term.year = 2013 + term.quarter = 'spring' + self.assertEqual(type(term), Term) + + term1 = get_current_term() + self.assertEqual(term, term1) + self.assertEqual(hash(term), hash(term1)) + + term2 = Term(year=2013, quarter='autumn') + self.assertFalse(term == term2) + self.assertFalse(hash(term) == hash(term2))