Exemple #1
0
    def setUp(self):
        super(SearchTest, self).setUp()
        course = CourseFactory.create(department=self.cs_dept,
                                      number=4230,
                                      name='Intro to Computing')
        OfferedForFactory.create(course=course, semester=self.semester)

        course2 = CourseFactory.create(department=self.cs_dept,
                                       number=4231,
                                       name='Skynet 101')
        OfferedForFactory.create(course=course2, semester=self.semester)

        # another department
        course3 = CourseFactory.create(department=self.ecse_dept,
                                       number=4230,
                                       name='Imaginary Power')
        OfferedForFactory.create(course=course3, semester=self.semester)

        section = SectionFactory.create(course=course, semester=self.semester)
        period = PeriodFactory.create(start=datetime.time(hour=12),
                                      end=datetime.time(hour=13),
                                      days_of_week_flag=1)
        SectionPeriodFactory.create(section=section,
                                    period=period,
                                    instructor='Moorthy',
                                    semester=self.semester)

        self.course1, self.course2, self.course3 = course, course2, course3
Exemple #2
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)],
     })
Exemple #3
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)],
     })
Exemple #4
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)],
     })
Exemple #5
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)],
     })
Exemple #6
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),
         ]
     })
Exemple #7
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),
         ]
     })
Exemple #8
0
    def setUp(self):
        self.sem = SemesterFactory.create()
        self.dept1 = DepartmentFactory.create(code='CSCI')
        self.dept2 = DepartmentFactory.create()

        self.course1 = CourseFactory.create(department=self.dept1, name='the course')
        OfferedForFactory.create(course=self.course1, semester=self.sem)

        self.course2 = CourseFactory.create(department=self.dept2)
        OfferedForFactory.create(course=self.course2, semester=self.sem)

        self.course3 = CourseFactory.create(department=self.dept1, name='another course')
        OfferedForFactory.create(course=self.course3, semester=self.sem)
Exemple #9
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),
         ]
     })
Exemple #10
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),
         ]
     })
Exemple #11
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),
         ]
     })
Exemple #12
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),
         ]
     })
Exemple #13
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),
         ],
     })
Exemple #14
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),
         ],
     })
Exemple #15
0
    def setUp(self):
        self.sem = SemesterFactory.create()
        self.dept1 = DepartmentFactory.create(code='CSCI')
        self.dept2 = DepartmentFactory.create()

        self.course1 = CourseFactory.create(department=self.dept1,
                                            name='the course')
        OfferedForFactory.create(course=self.course1, semester=self.sem)

        self.course2 = CourseFactory.create(department=self.dept2)
        OfferedForFactory.create(course=self.course2, semester=self.sem)

        self.course3 = CourseFactory.create(department=self.dept1,
                                            name='another course')
        OfferedForFactory.create(course=self.course3, semester=self.sem)
    def setUp(self):
        semester = SemesterFactory()
        pre_req = PreReqFactory()
        continence = ContinenceFactory()
        equivalence = EquivalenceFactory()
        subject = SubjectFactory()
        semester.subjects.add(subject)
        pre_req.subjects.add(subject)
        continence.subjects.add(subject)
        equivalence.subjects.add(subject)

        self.class_attributes = {
            'class_id': 'A',
            'positions': 30,
            'enrolled': 28,
            'subject': subject
        }
        self._class = Class.objects.create(**self.class_attributes)

        course = CourseFactory()
        schedule = ScheduleFactory()
        professor = ProfessorFactory()

        self.class_attributes['schedules'] = schedule
        self.class_attributes['course'] = course
        self.class_attributes['professors'] = professor
        course.classes.add(self._class)
        professor.classes.add(self._class)
Exemple #17
0
    def test_saving_and_loading(self):
        course1 = CourseFactory.create()
        course2 = CourseFactory.create()
        section1 = SectionFactory.create(course=course1)
        section2 = SectionFactory.create(course=course1)
        section3 = SectionFactory.create(course=course2)

        json = self.json_post('v4:saved-selections',
                              data={
                                  'section_ids':
                                  ','.join([
                                      str(section1.id),
                                      str(section2.id),
                                      str(section3.id),
                                  ]),
                                  'blocked_times':
                                  ','.join(
                                      ['Wednesday_12:0:0', 'Thursday_14:0:0'])
                              },
                              status_code=200)

        selection = SavedSelection.objects.all()[0]

        expected_json = {
            u"version": 4,
            u"success": True,
            u"result": {
                u'id': selection.id,
                u'selection': {
                    unicode(course1.id): [
                        section1.id,
                        section2.id,
                    ],
                    unicode(course2.id): [section3.id]
                },
                u'blocked_times': [
                    u'Thursday_14:0:0',
                    u'Wednesday_12:0:0',
                ]
            }
        }

        self.assertEqual(json, expected_json)
        json = self.json_post('v4:saved-selection',
                              id=selection.id,
                              status_code=200)
        self.assertEqual(json, expected_json)
Exemple #18
0
    def test_crns(self):
        course = CourseFactory.create()
        section1 = SectionFactory.create(crn=123, course=course)
        section2 = SectionFactory.create(crn=124, course=course)
        SectionPeriodFactory.create(section=section1)
        SectionPeriodFactory.create(section=section2)

        self.assertEqual([123, 124], list(course.crns))
Exemple #19
0
    def test_crns(self):
        course = CourseFactory.create()
        section1 = SectionFactory.create(crn=123, course=course)
        section2 = SectionFactory.create(crn=124, course=course)
        SectionPeriodFactory.create(section=section1)
        SectionPeriodFactory.create(section=section2)

        self.assertEqual([123, 124], list(course.crns))
Exemple #20
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),
     })
Exemple #21
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),
     })
Exemple #22
0
    def setUp(self):
        super(SearchTest, self).setUp()
        course = CourseFactory.create(department=self.cs_dept, number=4230, name='Intro to Computing')
        OfferedForFactory.create(course=course, semester=self.semester)

        course2 = CourseFactory.create(department=self.cs_dept, number=4231, name='Skynet 101')
        OfferedForFactory.create(course=course2, semester=self.semester)

        # another department
        course3 = CourseFactory.create(department=self.ecse_dept, number=4230, name='Imaginary Power')
        OfferedForFactory.create(course=course3, semester=self.semester)

        section = SectionFactory.create(course=course, semester=self.semester)
        period = PeriodFactory.create(start=datetime.time(hour=12), end=datetime.time(hour=13), days_of_week_flag=1)
        SectionPeriodFactory.create(section=section, period=period, instructor='Moorthy', semester=self.semester)

        self.course1, self.course2, self.course3 = course, course2, course3
Exemple #23
0
 def test_fetch_should_not_exclude_comm_intense(self):
     c1 = CourseFactory.create(is_comm_intense=True)
     json = self.json_get('v4:courses', id=c1.id, status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": self.to_dict(c1),
     })
Exemple #24
0
 def test_fetch_should_not_exclude_comm_intense(self):
     c1 = CourseFactory.create(is_comm_intense=True)
     json = self.json_get('v4:courses', id=c1.id, status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": self.to_dict(c1),
     })
Exemple #25
0
    def test_get_departments_by_courses(self):
        d1, d2, d3 = DepartmentFactory.create_batch(3)
        c1 = CourseFactory.create(department=d1)
        c2 = CourseFactory.create(department=d2)
        c3 = CourseFactory.create(department=d3)

        json = self.json_get(
            'v4:departments',
            get='?course_id=%d&course_id=%d' % (c1.id, c2.id),
            status_code=200)

        self.assertEqual(json, {
            u"version": 4,
            u"success": True,
            u"result": [
                self.as_dict(d1),
                self.as_dict(d2),
            ]
        })
Exemple #26
0
    def setUp(self):
        self.sem = SemesterFactory.create(year=2011, month=1)
        self.dept = DepartmentFactory.create(code='CSCI')
        SemesterDepartmentFactory.create(department=self.dept, semester=self.sem)

        self.course = CourseFactory.create(number=2222, department=self.dept)
        OfferedForFactory.create(course=self.course, semester=self.sem)

        self.section = SectionFactory.create(course=self.course, semester=self.sem)
        SectionPeriodFactory.create(section=self.section)
Exemple #27
0
    def test_get_departments_by_courses(self):
        d1, d2, d3 = DepartmentFactory.create_batch(3)
        c1 = CourseFactory.create(department=d1)
        c2 = CourseFactory.create(department=d2)
        c3 = CourseFactory.create(department=d3)

        json = self.json_get(
            'v4:departments',
            get='?course_id=%d&course_id=%d' % (c1.id, c2.id),
            status_code=200)

        self.assertEqual(json, {
            u"version": 4,
            u"success": True,
            u"result": [
                self.as_dict(d1),
                self.as_dict(d2),
            ]
        })
Exemple #28
0
    def test_specialization_creation(self):
        course = CourseFactory()
        specialization = SpecializationFactory()
        self.assertTrue(isinstance(specialization, Specialization))
        self.assertEqual(
            str(specialization),
            str(specialization.code) + ' - ' +
            str(specialization.specialization))

        self.assertEqual(specialization.code, "AB")
Exemple #29
0
    def test_kinds(self):
        course = CourseFactory.create()
        section1 = SectionFactory.create(crn=123, course=course)
        section2 = SectionFactory.create(crn=124, course=course, seats_total=1)
        SectionPeriodFactory.create(section=section1, kind='foo')
        SectionPeriodFactory.create(section=section1, kind='foobar')
        SectionPeriodFactory.create(section=section1, kind='fizzbuzz')
        SectionPeriodFactory.create(section=section2, kind='fizz')

        self.assertEqual(set(['foo', 'foobar', 'fizzbuzz', 'fizz']), set(course.kinds))
Exemple #30
0
    def test_full_crns(self):
        course = CourseFactory.create()
        section1 = SectionFactory.create(
            crn=123, course=course, seats_total=1, seats_taken=0)
        section2 = SectionFactory.create(
            crn=124, course=course, seats_total=1, seats_taken=5)
        SectionPeriodFactory.create(section=section1)
        SectionPeriodFactory.create(section=section2)

        self.assertEqual([124], list(course.full_crns))
Exemple #31
0
    def test_saving_and_loading(self):
        course1 = CourseFactory.create()
        course2 = CourseFactory.create()
        section1 = SectionFactory.create(course=course1)
        section2 = SectionFactory.create(course=course1)
        section3 = SectionFactory.create(course=course2)

        json = self.json_post('v4:saved-selections', data={
            'section_ids': ','.join([
                str(section1.id),
                str(section2.id),
                str(section3.id),
            ]),
            'blocked_times': ','.join(['Wednesday_12:0:0', 'Thursday_14:0:0'])
        }, status_code=200)

        selection = SavedSelection.objects.all()[0]

        expected_json = {
            u"version": 4,
            u"success": True,
            u"result": {
                u'id': selection.id,
                u'selection': {
                    unicode(course1.id): [
                        section1.id,
                        section2.id,
                    ],
                    unicode(course2.id): [
                        section3.id
                    ]
                },
                u'blocked_times': [
                    u'Thursday_14:0:0',
                    u'Wednesday_12:0:0',
                ]
            }
        }

        self.assertEqual(json, expected_json)
        json = self.json_post('v4:saved-selection', id=selection.id, status_code=200)
        self.assertEqual(json, expected_json)
Exemple #32
0
    def test_kinds(self):
        course = CourseFactory.create()
        section1 = SectionFactory.create(crn=123, course=course)
        section2 = SectionFactory.create(crn=124, course=course, seats_total=1)
        SectionPeriodFactory.create(section=section1, kind='foo')
        SectionPeriodFactory.create(section=section1, kind='foobar')
        SectionPeriodFactory.create(section=section1, kind='fizzbuzz')
        SectionPeriodFactory.create(section=section2, kind='fizz')

        self.assertEqual(set(['foo', 'foobar', 'fizzbuzz', 'fizz']),
                         set(course.kinds))
Exemple #33
0
    def setUp(self):
        self.sem = SemesterFactory.create(year=2011, month=1)
        self.dept = DepartmentFactory.create(code='CSCI')
        SemesterDepartmentFactory.create(department=self.dept,
                                         semester=self.sem)

        self.course = CourseFactory.create(number=2222, department=self.dept)
        OfferedForFactory.create(course=self.course, semester=self.sem)

        self.section = SectionFactory.create(course=self.course,
                                             semester=self.sem)
        SectionPeriodFactory.create(section=self.section)
Exemple #34
0
    def init(self, is_superuser, university_code=None):
        self.backoffice_group, _created = Group.objects.get_or_create(name='fun_backoffice')
        self.user.is_staff = False
        self.user.is_superuser = is_superuser
        self.user.save()
        UserProfile.objects.create(user=self.user)
        self.course = CourseFactory.create(org=university_code)

        self.fun_course = FunCourseFactory.create(key=unicode(self.course.scope_ids.usage_id.course_key))
        if university_code:
            self.university = UniversityFactory.create(slug=university_code, code=university_code)
            CourseUniversityRelationFactory(course=self.fun_course, university=self.university)
Exemple #35
0
 def setUp(self):
     next_week = now() + timedelta(days=7)
     self.api_url = reverse('fun-courses-api:courses-list')
     self.active_1 = CourseFactory(
         title='active course 1',
         show_in_catalog=True,
         is_active=True,
         end_date=next_week,
     )
     self.active_2 = CourseFactory(
         title='active course 2',
         show_in_catalog=True,
         is_active=True,
         end_date=next_week,
     )
     self.not_active = CourseFactory(
         title='course not active',
         show_in_catalog=True,
         is_active=False,
         end_date=next_week,
     )
     self.not_in_catalog = CourseFactory(
         title='course not in catalog',
         show_in_catalog=False,
         is_active=True,
         end_date=next_week,
     )
     self.user = UserFactory(username='******', password='******')  # user with profile
Exemple #36
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),
         ]
     })
Exemple #37
0
 def test_to_json(self):
     course = CourseFactory.create(
     pk=1, name='foo', number=5050, min_credits=4, max_credits=5, description='foo',
     )
     expected = {
         'id': 1,
         'name': 'foo',
         'number': 5050,
         'min_credits': 4,
         'max_credits': 5,
         'description': 'foo',
     }
     self.assertEqual(expected, course.toJSON())
Exemple #38
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),
         ]
     })
Exemple #39
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),
         ]
     })
Exemple #40
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),
         ]
     })
Exemple #41
0
    def test_full_crns(self):
        course = CourseFactory.create()
        section1 = SectionFactory.create(crn=123,
                                         course=course,
                                         seats_total=1,
                                         seats_taken=0)
        section2 = SectionFactory.create(crn=124,
                                         course=course,
                                         seats_total=1,
                                         seats_taken=5)
        SectionPeriodFactory.create(section=section1)
        SectionPeriodFactory.create(section=section2)

        self.assertEqual([124], list(course.full_crns))
Exemple #42
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)],
        })
Exemple #43
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)],
        })
class CourseDetailViewTestCase(TestCase):
    def setUp(self):
        self.course = CourseFactory()
        self.material1 = MaterialFactory(course=self.course, rank=0)
        self.material2 = MaterialFactory(course=self.course, rank=1)

    def test_good_view(self):
        url = self.course.get_absolute_url()
        response = self.client.get(url)
        assert response.status_code == 200
        self.assertTemplateUsed(response, "courses/course_detail.html")
        self.assertIn("next", response.context_data)
        self.assertEqual(
            response.context_data["next"],
            {
                "title": self.material1.title,
                "url": self.material1.get_absolute_url()
            },
        )

    def test_headline(self):
        course_url = self.course.get_absolute_url()
        response = self.client.get(course_url)
        self.assertContains(response, self.course.title)
Exemple #45
0
 def test_get_sections_by_course(self):
     c1 = CourseFactory.create()
     sec1, sec2 = SectionFactory.create_batch(2, course=c1)
     s1 = SectionPeriodFactory.create(section=sec1)
     s2 = SectionPeriodFactory.create(section=sec2)
     s3, s4 = SectionPeriodFactory.create_batch(2)
     json = self.json_get(
         'v4:sections', get='?course_id=%d' % c1.id, status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(s1),
             self.to_dict(s2),
         ]
     })
Exemple #46
0
 def test_get_sections_by_course(self):
     c1 = CourseFactory.create()
     sec1, sec2 = SectionFactory.create_batch(2, course=c1)
     s1 = SectionPeriodFactory.create(section=sec1)
     s2 = SectionPeriodFactory.create(section=sec2)
     s3, s4 = SectionPeriodFactory.create_batch(2)
     json = self.json_get(
         'v4:sections', get='?course_id=%d' % c1.id, status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(s1),
             self.to_dict(s2),
         ]
     })
Exemple #47
0
    def setUp(self):
        semester = SemesterFactory.create(year=2011, month=1)
        course = CourseFactory.create(pk=2)
        OfferedForFactory.create(semester=semester, course=course)

        section = SectionFactory.create(number=1, course=course, semester=semester)
        sa_section = SectionFactory.create(number=models.Section.STUDY_ABROAD, course=course, semester=semester)
        crn_section = SectionFactory.create(crn=13337, course=course, semester=semester)

        cs_dept = DepartmentFactory.create(code='CSCI')
        SemesterDepartmentFactory.create(semester=semester, department=cs_dept)

        ecse_dept = DepartmentFactory.create(code='ECSE')
        SemesterDepartmentFactory.create(semester=semester, department=ecse_dept)

        self.semester, self.course, self.cs_dept, self.ecse_dept = semester, course, cs_dept, ecse_dept
Exemple #48
0
    def init(self, is_superuser, university_code=None):
        self.backoffice_group, _created = Group.objects.get_or_create(
            name='fun_backoffice')
        self.user.is_staff = False
        self.user.is_superuser = is_superuser
        self.user.save()
        UserProfile.objects.create(user=self.user)
        self.course = CourseFactory.create(org=university_code)

        self.fun_course = FunCourseFactory.create(
            key=unicode(self.course.scope_ids.usage_id.course_key))
        if university_code:
            self.university = UniversityFactory.create(slug=university_code,
                                                       code=university_code)
            CourseUniversityRelationFactory(course=self.fun_course,
                                            university=self.university)
Exemple #49
0
    def setup(self):
        user_password = 32768
        self.user = UserFactory.create(password=user_password)
        self.course = CourseFactory.create()
        self.lesson = LessonFactory.create(course=self.course,
                                           name='L1',
                                           date=datetime.datetime(
                                               2018,
                                               6,
                                               11,
                                               21,
                                               30,
                                               tzinfo=pytz.UTC))

        rf = RequestFactory()
        self.request = rf.get('/')

        client.login(username=self.user.username, password=32768)
Exemple #50
0
 def test_to_json(self):
     course = CourseFactory.create(pk=1,
                                   name='foo',
                                   number=5050,
                                   min_credits=4,
                                   max_credits=5,
                                   description='foo',
                                   prereqs='foo',
                                   is_comm_intense=True)
     expected = {
         'id': 1,
         'name': 'foo',
         'number': 5050,
         'min_credits': 4,
         'max_credits': 5,
         'description': 'foo',
         'prereqs': 'foo',
         'is_comm_intense': True
     }
     self.assertEqual(expected, course.toJSON())
Exemple #51
0
    def setUp(self):
        course = CourseFactory()
        semester = SemesterFactory()
        pre_req = PreReqFactory()
        continence = ContinenceFactory()
        equivalence = EquivalenceFactory()
        subject = SubjectFactory()

        semester.subjects.add(subject)
        pre_req.subjects.add(subject)
        continence.subjects.add(subject)
        equivalence.subjects.add(subject)

        self.student_attributes = {
            'ra': '100000',
            'name': 'Victor Palmerini',
            'email': '*****@*****.**',
            'course': course
        }

        self.student = Student.objects.create(**self.student_attributes)
    def test_entries_display(self):
        course = CourseFactory()
        pinned_post = PostFactory(
            pinned=True,
            show_on_index=True,
            status=Post.STATUS_CHOICES.published,
        )
        material = MaterialFactory(
            course=course,
            show_on_index=True,
            status=Material.STATUS.published,
            pub_date=timezone.now(),
        )

        response = self.client.get(self.url)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "[置顶] " + pinned_post.title)
        self.assertContains(response, pinned_post.brief)

        self.assertContains(response, material.title)
        self.assertContains(response, "系列教程")
Exemple #53
0
    def setUp(self):
        semester = SemesterFactory.create(year=2011, month=1)
        course = CourseFactory.create(pk=2)
        OfferedForFactory.create(semester=semester, course=course)

        section = SectionFactory.create(number=1,
                                        course=course,
                                        semester=semester)
        sa_section = SectionFactory.create(number=models.Section.STUDY_ABROAD,
                                           course=course,
                                           semester=semester)
        crn_section = SectionFactory.create(crn=13337,
                                            course=course,
                                            semester=semester)

        cs_dept = DepartmentFactory.create(code='CSCI')
        SemesterDepartmentFactory.create(semester=semester, department=cs_dept)

        ecse_dept = DepartmentFactory.create(code='ECSE')
        SemesterDepartmentFactory.create(semester=semester,
                                         department=ecse_dept)

        self.semester, self.course, self.cs_dept, self.ecse_dept = semester, course, cs_dept, ecse_dept
Exemple #54
0
    def setUp(self):
        self.semester = SemesterFactory.create(year=2011, month=1)

        self.course1 = CourseFactory.create(id=1, min_credits=4, max_credits=4)
        OfferedForFactory.create(course=self.course1, semester=self.semester)
        self.course2 = CourseFactory.create(id=2, min_credits=4, max_credits=4)
        OfferedForFactory.create(course=self.course2, semester=self.semester)

        self.periods = create_periods(
            ((10, 0), (11, 50), models.Period.MONDAY | models.Period.THURSDAY),  # 0
            ((10, 0), (10, 50), models.Period.MONDAY | models.Period.THURSDAY),  # 1
            ((11, 0), (11, 50), models.Period.TUESDAY | models.Period.FRIDAY),  # 2
            ((12, 0), (13, 50), models.Period.TUESDAY | models.Period.FRIDAY),  # 3
            ((14, 0), (16, 50), models.Period.WEDNESDAY),  # 4
            ((10, 0), (10, 50), models.Period.TUESDAY | models.Period.FRIDAY),  # 5
            ((10, 0), (11, 50), models.Period.TUESDAY | models.Period.FRIDAY),  # 6
        )
        # conflicts: (0, 1), (2, 3), (5, 6)

        self.section1 = create_section(
            id=1,
            course=self.course1,
            crn=1000,
            number=1,
            seats_taken=3,
            seats_total=10,
            semester=self.semester,
            periods=[
                dict(period=self.periods[0], semester=self.semester),
                dict(period=self.periods[4], semester=self.semester),
            ],
        )
        self.section2 = create_section(
            id=2,
            course=self.course1,
            crn=1001,
            number=2,
            seats_taken=4,
            seats_total=5,
            semester=self.semester,
            periods=[
                dict(period=self.periods[1], semester=self.semester),
            ],
        )
        self.section3 = create_section(
            id=3,
            course=self.course2,
            crn=1002,
            number=1,
            seats_taken=4,
            seats_total=6,
            semester=self.semester,
            periods=[
                dict(period=self.periods[4], semester=self.semester),
            ],
        )
        self.section4 = create_section(
            id=4,
            course=self.course2,
            crn=1003,
            number=2,
            seats_taken=7,
            seats_total=6,
            semester=self.semester,
            periods=[
                dict(period=self.periods[5], semester=self.semester),
            ]
        )
        # can't figure out where the other semester objects get created
        # its do to get(models.Section, ...) but not sure where
        #models.Semester.objects.filter(id__gt=self.semester.id).delete()
        cache_conflicts(semester=self.semester)
Exemple #55
0
 def test_code(self):
     dept = DepartmentFactory.build(code='CSCI')
     course = CourseFactory.build(department=dept, number=1100)
     self.assertEqual('CSCI 1100', course.code)
Exemple #56
0
 def test_credits_display_for_equivalent_min_and_max_credits(self):
     course = CourseFactory.build(min_credits=4, max_credits=4)
     self.assertEqual('4 credits', course.credits_display)
Exemple #57
0
 def test_credits_display_for_equivalent_min_and_max_credits_as_one_credit(self):
     course = CourseFactory.build(min_credits=1, max_credits=1)
     self.assertEqual('1 credit', course.credits_display)
Exemple #58
0
 def test_available_sections(self):
     course = CourseFactory.build()
     queryset = models.Course.sections.by_availability = Mock(return_value='foobar')
     self.assertEqual('foobar', course.available_sections)
     queryset.assert_called_with()
Exemple #59
0
 def test_credits_display_for_range(self):
     course = CourseFactory.build(min_credits=1, max_credits=8)
     self.assertEqual('1 - 8 credits', course.credits_display)