Ejemplo n.º 1
0
 def test_get_courses_by_number(self):
     c1, c2 = CourseFactory.create_batch(2, number=1337)
     c3, c4 = CourseFactory.create_batch(2)
     json = self.json_get('v4:courses', get='?number=1337', status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(c1),
             self.to_dict(c2),
         ]
     })
Ejemplo n.º 2
0
 def test_get_courses_by_number(self):
     c1, c2 = CourseFactory.create_batch(2, number=1337)
     c3, c4 = CourseFactory.create_batch(2)
     json = self.json_get('v4:courses', get='?number=1337', status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(c1),
             self.to_dict(c2),
         ]
     })
Ejemplo n.º 3
0
 def test_get_courses_by_dept_id(self):
     d = DepartmentFactory.create(code='CSCI')
     c1, c2 = CourseFactory.create_batch(2, department=d)
     c3, c4 = CourseFactory.create_batch(2)
     json = self.json_get(
         'v4:courses', get='?department_id=%s' % d.id, status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(c1),
             self.to_dict(c2),
         ]
     })
Ejemplo n.º 4
0
 def test_get_courses_by_dept_id(self):
     d = DepartmentFactory.create(code='CSCI')
     c1, c2 = CourseFactory.create_batch(2, department=d)
     c3, c4 = CourseFactory.create_batch(2)
     json = self.json_get(
         'v4:courses', get='?department_id=%s' % d.id, status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(c1),
             self.to_dict(c2),
         ]
     })
Ejemplo n.º 5
0
 def test_search_department_name(self):
     c1, c2 = CourseFactory.create_batch(2)
     d = DepartmentFactory.create(name='Computer Science')
     c3, c4 = CourseFactory.create_batch(2, department=d)
     json = self.json_get(
         'v4:courses', get='?search=Computer', status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(c3),
             self.to_dict(c4),
         ],
     })
Ejemplo n.º 6
0
 def test_search_department_name(self):
     c1, c2 = CourseFactory.create_batch(2)
     d = DepartmentFactory.create(name='Computer Science')
     c3, c4 = CourseFactory.create_batch(2, department=d)
     json = self.json_get(
         'v4:courses', get='?search=Computer', status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(c3),
             self.to_dict(c4),
         ],
     })
Ejemplo n.º 7
0
 def test_get_course_by_id(self):
     c1, c2 = CourseFactory.create_batch(2)
     json = self.json_get('v4:courses', id=c1.id, status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": self.to_dict(c1),
     })
Ejemplo n.º 8
0
 def test_get_course_by_id(self):
     c1, c2 = CourseFactory.create_batch(2)
     json = self.json_get('v4:courses', id=c1.id, status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": self.to_dict(c1),
     })
Ejemplo n.º 9
0
 def test_search_name(self):
     c1, c2 = CourseFactory.create_batch(2)
     c3 = CourseFactory.create(name="Cakes for Dummies")
     json = self.json_get(
         'v4:courses', get='?search=cakes dum', status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [self.to_dict(c3)],
     })
Ejemplo n.º 10
0
 def test_search_department_code(self):
     c1, c2 = CourseFactory.create_batch(2)
     d = DepartmentFactory.create(code='CSCI')
     c3 = CourseFactory.create(department=d)
     json = self.json_get('v4:courses', get='?search=CSCI', status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [self.to_dict(c3)],
     })
Ejemplo n.º 11
0
 def test_search_name(self):
     c1, c2 = CourseFactory.create_batch(2)
     c3 = CourseFactory.create(name="Cakes for Dummies")
     json = self.json_get(
         'v4:courses', get='?search=cakes dum', status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [self.to_dict(c3)],
     })
Ejemplo n.º 12
0
 def test_search_department_code(self):
     c1, c2 = CourseFactory.create_batch(2)
     d = DepartmentFactory.create(code='CSCI')
     c3 = CourseFactory.create(department=d)
     json = self.json_get(
         'v4:courses', get='?search=CSCI', status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [self.to_dict(c3)],
     })
Ejemplo n.º 13
0
 def test_get_courses(self):
     c1, c2, c3 = CourseFactory.create_batch(3)
     json = self.json_get('v4:courses', status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(c1),
             self.to_dict(c2),
             self.to_dict(c3),
         ]
     })
Ejemplo n.º 14
0
 def test_get_courses(self):
     c1, c2, c3 = CourseFactory.create_batch(3)
     json = self.json_get('v4:courses', status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(c1),
             self.to_dict(c2),
             self.to_dict(c3),
         ]
     })
Ejemplo n.º 15
0
 def test_get_courses_by_ids(self):
     c1, c2, c3, c4 = CourseFactory.create_batch(4)
     json = self.json_get(
         'v4:courses',
         get='?id=%d&id=%d' % (c1.id, c3.id),
         status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(c1),
             self.to_dict(c3),
         ]
     })
Ejemplo n.º 16
0
 def test_search_instructor(self):
     c1, c2 = CourseFactory.create_batch(2)
     c3 = CourseFactory.create()
     sec = SectionFactory.create(course=c3)
     sp = SectionPeriodFactory.create(section=sec, instructor='Moorthy')
     json = self.json_get('v4:courses', get='?search=moor', status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(c3),
         ]
     })
Ejemplo n.º 17
0
 def test_search_instructor(self):
     c1, c2 = CourseFactory.create_batch(2)
     c3 = CourseFactory.create()
     sec = SectionFactory.create(course=c3)
     sp = SectionPeriodFactory.create(section=sec, instructor='Moorthy')
     json = self.json_get('v4:courses', get='?search=moor', status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(c3),
         ]
     })
Ejemplo n.º 18
0
 def test_get_courses_by_ids(self):
     c1, c2, c3, c4 = CourseFactory.create_batch(4)
     json = self.json_get(
         'v4:courses',
         get='?id=%d&id=%d' % (c1.id, c3.id),
         status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(c1),
             self.to_dict(c3),
         ]
     })
Ejemplo n.º 19
0
    def test_get_semester_by_course(self):
        c1, c2 = CourseFactory.create_batch(2)
        OfferedForFactory.create(semester=self.s1, course=c1)
        OfferedForFactory.create(semester=self.s2, course=c2)
        json = self.json_get('v4:semesters', get='?course_id=%d' % c2.id)

        # for some odd reason, accuracy is lost for datetimes.
        for row in json['result']:
            row['date_updated'] = row['date_updated'][:-7]

        self.assertEqual(json, {
            u"version": 4,
            u"success": True,
            u"result": [self.as_dict(self.s2)],
        })
Ejemplo n.º 20
0
    def test_get_semester_by_course(self):
        c1, c2 = CourseFactory.create_batch(2)
        OfferedForFactory.create(semester=self.s1, course=c1)
        OfferedForFactory.create(semester=self.s2, course=c2)
        json = self.json_get('v4:semesters', get='?course_id=%d' % c2.id)

        # for some odd reason, accuracy is lost for datetimes.
        for row in json['result']:
            row['date_updated'] = row['date_updated'][:-7]

        self.assertEqual(json, {
            u"version": 4,
            u"success": True,
            u"result": [self.as_dict(self.s2)],
        })
Ejemplo n.º 21
0
 def setup(self):
     CourseFactory.create_batch(2)