Exemplo n.º 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
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
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
Exemplo n.º 6
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))
Exemplo n.º 7
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))
Exemplo n.º 8
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),
     })
Exemplo n.º 9
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),
     })
Exemplo n.º 10
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),
            ]
        })
Exemplo n.º 11
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)
Exemplo n.º 12
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),
            ]
        })
Exemplo n.º 13
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))
Exemplo n.º 14
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))
Exemplo n.º 15
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)
Exemplo n.º 16
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)],
     })
Exemplo n.º 17
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)],
     })
Exemplo n.º 18
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)],
     })
Exemplo n.º 19
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))
Exemplo n.º 20
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)],
     })
Exemplo n.º 21
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)
Exemplo n.º 22
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)
Exemplo n.º 23
0
Arquivo: models.py Projeto: jinz/YACS
 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())
Exemplo n.º 24
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))
Exemplo n.º 25
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),
         ]
     })
Exemplo n.º 26
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),
         ]
     })
Exemplo n.º 27
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)
Exemplo n.º 28
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),
         ]
     })
Exemplo n.º 29
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
Exemplo n.º 30
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),
         ]
     })
Exemplo n.º 31
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)
Exemplo n.º 32
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())
Exemplo n.º 33
0
    def setup(self):
        self.user = UserFactory.create()
        self.course = CourseFactory.create()

        LessonFactory.create(course=self.course,
                             name='L1',
                             date=datetime.datetime(2018,
                                                    6,
                                                    11,
                                                    21,
                                                    30,
                                                    tzinfo=pytz.UTC))
        LessonFactory.create(course=self.course,
                             name='L2',
                             date=datetime.datetime(2018,
                                                    6,
                                                    18,
                                                    21,
                                                    30,
                                                    tzinfo=pytz.UTC))

        self.test_lesson_scheduler = django_rq.get_scheduler(
            'lesson_reminder_test')
Exemplo n.º 34
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
Exemplo n.º 35
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)
Exemplo n.º 36
0
 def test_code(self):
     dept = DepartmentFactory.create(code='CSCI')
     course = CourseFactory.create(department=dept, number=1100)
     self.assertEqual('CSCI 1100', course.code)
Exemplo n.º 37
0
 def test_credits_display_for_equivalent_min_and_max_credits_as_one_credit(
         self):
     course = CourseFactory.create(min_credits=1, max_credits=1)
     self.assertEqual('1 credit', course.credits_display)
Exemplo n.º 38
0
 def test_credits_display_for_range(self):
     course = CourseFactory.create(min_credits=1, max_credits=8)
     self.assertEqual('1 - 8 credits', course.credits_display)
Exemplo n.º 39
0
 def test_available_sections(self):
     course = CourseFactory.create()
     queryset = models.Course.sections.by_availability = Mock(
         return_value='foobar')
     self.assertEqual('foobar', course.available_sections)
     queryset.assert_called_with()
Exemplo n.º 40
0
 def test_credits_display_for_range(self):
     course = CourseFactory.create(min_credits=1, max_credits=8)
     self.assertEqual('1 - 8 credits', course.credits_display)
Exemplo n.º 41
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),
            ]
        )
        cache_conflicts(semester=self.semester)
Exemplo n.º 42
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),
                                       ])
        cache_conflicts(semester=self.semester)
Exemplo n.º 43
0
 def test_available_sections(self):
     course = CourseFactory.create()
     queryset = models.Course.sections.by_availability = Mock(return_value='foobar')
     self.assertEqual('foobar', course.available_sections)
     queryset.assert_called_with()
Exemplo n.º 44
0
 def setup(self):
     self.user = UserFactory.create(password=32768)
     self.course = CourseFactory.create()
     client.login(username=self.user.username, password=32768)
Exemplo n.º 45
0
 def test_credits_display_for_equivalent_min_and_max_credits_as_one_credit(self):
     course = CourseFactory.create(min_credits=1, max_credits=1)
     self.assertEqual('1 credit', course.credits_display)
Exemplo n.º 46
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)
Exemplo n.º 47
0
 def test_credits_display_for_equivalent_min_and_max_credits(self):
     course = CourseFactory.create(min_credits=4, max_credits=4)
     self.assertEqual('4 credits', course.credits_display)
Exemplo n.º 48
0
 def test_credits_display_for_equivalent_min_and_max_credits(self):
     course = CourseFactory.create(min_credits=4, max_credits=4)
     self.assertEqual('4 credits', course.credits_display)
Exemplo n.º 49
0
 def test_code(self):
     dept = DepartmentFactory.create(code='CSCI')
     course = CourseFactory.create(department=dept, number=1100)
     self.assertEqual('CSCI 1100', course.code)