forked from ScottyLabs/cmupy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
executable file
·29 lines (23 loc) · 8.97 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python
import unittest
import cmu
import secrets
class TestScheduling(unittest.TestCase):
def setUp(self):
self.api = cmu.Scheduling(app_id=secrets.APP_ID,
app_secret_key=secrets.APP_SECRET_KEY)
def test_departments(self):
departments = self.api.departments(semester='S14')
self.assertEqual(len(departments), 60)
self.assertIn({ u'id': 15, u'name': 'Computer Science' }, departments)
def test_courses(self):
courses = self.api.courses(semester='S14', department=15)
self.assertEqual(len(courses), 95)
self.assertIn({u'units': 12, u'lectures': [{u'time_start': u'03:00PM', u'section': u'Lec 1', u'instructors': u'Sleator, Sutner', u'days': u'TR', u'time_end': u'04:20PM', u'recitations': [{u'time_start': u'09:30AM', u'section': u'A', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'10:20AM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'09:30AM', u'days': u'MF', u'time_end': u'10:20AM'}]}, {u'time_start': u'11:30AM', u'section': u'C', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'12:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'11:30AM', u'days': u'MF', u'time_end': u'12:20PM'}]}, {u'time_start': u'01:30PM', u'section': u'E', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'02:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'01:30PM', u'days': u'MF', u'time_end': u'02:20PM'}]}, {u'time_start': u'03:30PM', u'section': u'G', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'04:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'03:30PM', u'days': u'MF', u'time_end': u'04:20PM'}]}, {u'time_start': u'10:30AM', u'section': u'B', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'11:20AM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'10:30AM', u'days': u'MF', u'time_end': u'11:20AM'}]}, {u'time_start': u'12:30PM', u'section': u'D', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'01:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'12:30PM', u'days': u'MF', u'time_end': u'01:20PM'}]}, {u'time_start': u'02:30PM', u'section': u'F', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'03:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'02:30PM', u'days': u'MF', u'time_end': u'03:20PM'}]}], u'location': u'WEH 7500', u'meetings': [{u'location': u'WEH 7500', u'time_start': u'03:00PM', u'days': u'TR', u'time_end': u'04:20PM'}]}, {u'time_start': u'01:30PM', u'section': u'Lec 2', u'instructors': u'Kapoutsis', u'days': u'MW', u'time_end': u'02:50PM', u'recitations': [{u'time_start': u'01:30PM', u'section': u'W', u'instructors': u'Kapoutsis', u'days': u'TR', u'time_end': u'02:20PM', u'location': u'CMB 1064', u'meetings': [{u'location': u'CMB 1064', u'time_start': u'01:30PM', u'days': u'TR', u'time_end': u'02:20PM'}]}], u'location': u'CMB 1064', u'meetings': [{u'location': u'CMB 1064', u'time_start': u'01:30PM', u'days': u'MW', u'time_end': u'02:50PM'}]}], u'number': u'15251', u'name': u'Great Theoretical Ideas in Computer Science', u'department_id': 15}, courses)
def test_course(self):
courseA = self.api.course(semester='S14', department=15, course_id=251)
courseB = self.api.course(semester='S14', course_number=15251)
self.assertDictEqual({u'units': 12, u'lectures': [{u'time_start': u'03:00PM', u'section': u'Lec 1', u'instructors': u'Sleator, Sutner', u'days': u'TR', u'time_end': u'04:20PM', u'recitations': [{u'time_start': u'09:30AM', u'section': u'A', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'10:20AM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'09:30AM', u'days': u'MF', u'time_end': u'10:20AM'}]}, {u'time_start': u'11:30AM', u'section': u'C', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'12:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'11:30AM', u'days': u'MF', u'time_end': u'12:20PM'}]}, {u'time_start': u'01:30PM', u'section': u'E', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'02:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'01:30PM', u'days': u'MF', u'time_end': u'02:20PM'}]}, {u'time_start': u'03:30PM', u'section': u'G', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'04:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'03:30PM', u'days': u'MF', u'time_end': u'04:20PM'}]}, {u'time_start': u'10:30AM', u'section': u'B', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'11:20AM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'10:30AM', u'days': u'MF', u'time_end': u'11:20AM'}]}, {u'time_start': u'12:30PM', u'section': u'D', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'01:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'12:30PM', u'days': u'MF', u'time_end': u'01:20PM'}]}, {u'time_start': u'02:30PM', u'section': u'F', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'03:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'02:30PM', u'days': u'MF', u'time_end': u'03:20PM'}]}], u'location': u'WEH 7500', u'meetings': [{u'location': u'WEH 7500', u'time_start': u'03:00PM', u'days': u'TR', u'time_end': u'04:20PM'}]}, {u'time_start': u'01:30PM', u'section': u'Lec 2', u'instructors': u'Kapoutsis', u'days': u'MW', u'time_end': u'02:50PM', u'recitations': [{u'time_start': u'01:30PM', u'section': u'W', u'instructors': u'Kapoutsis', u'days': u'TR', u'time_end': u'02:20PM', u'location': u'CMB 1064', u'meetings': [{u'location': u'CMB 1064', u'time_start': u'01:30PM', u'days': u'TR', u'time_end': u'02:20PM'}]}], u'location': u'CMB 1064', u'meetings': [{u'location': u'CMB 1064', u'time_start': u'01:30PM', u'days': u'MW', u'time_end': u'02:50PM'}]}], u'number': u'15251', u'name': u'Great Theoretical Ideas in Computer Science', u'department_id': 15}, courseA)
self.assertDictEqual({u'units': 12, u'lectures': [{u'time_start': u'03:00PM', u'section': u'Lec 1', u'instructors': u'Sleator, Sutner', u'days': u'TR', u'time_end': u'04:20PM', u'recitations': [{u'time_start': u'09:30AM', u'section': u'A', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'10:20AM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'09:30AM', u'days': u'MF', u'time_end': u'10:20AM'}]}, {u'time_start': u'11:30AM', u'section': u'C', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'12:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'11:30AM', u'days': u'MF', u'time_end': u'12:20PM'}]}, {u'time_start': u'01:30PM', u'section': u'E', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'02:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'01:30PM', u'days': u'MF', u'time_end': u'02:20PM'}]}, {u'time_start': u'03:30PM', u'section': u'G', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'04:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'03:30PM', u'days': u'MF', u'time_end': u'04:20PM'}]}, {u'time_start': u'10:30AM', u'section': u'B', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'11:20AM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'10:30AM', u'days': u'MF', u'time_end': u'11:20AM'}]}, {u'time_start': u'12:30PM', u'section': u'D', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'01:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'12:30PM', u'days': u'MF', u'time_end': u'01:20PM'}]}, {u'time_start': u'02:30PM', u'section': u'F', u'instructors': u'Instructor TBA', u'days': u'MF', u'time_end': u'03:20PM', u'location': u'DH 1217', u'meetings': [{u'location': u'DH 1217', u'time_start': u'02:30PM', u'days': u'MF', u'time_end': u'03:20PM'}]}], u'location': u'WEH 7500', u'meetings': [{u'location': u'WEH 7500', u'time_start': u'03:00PM', u'days': u'TR', u'time_end': u'04:20PM'}]}, {u'time_start': u'01:30PM', u'section': u'Lec 2', u'instructors': u'Kapoutsis', u'days': u'MW', u'time_end': u'02:50PM', u'recitations': [{u'time_start': u'01:30PM', u'section': u'W', u'instructors': u'Kapoutsis', u'days': u'TR', u'time_end': u'02:20PM', u'location': u'CMB 1064', u'meetings': [{u'location': u'CMB 1064', u'time_start': u'01:30PM', u'days': u'TR', u'time_end': u'02:20PM'}]}], u'location': u'CMB 1064', u'meetings': [{u'location': u'CMB 1064', u'time_start': u'01:30PM', u'days': u'MW', u'time_end': u'02:50PM'}]}], u'number': u'15251', u'name': u'Great Theoretical Ideas in Computer Science', u'department_id': 15}, courseB)
if __name__ == '__main__':
unittest.main()