示例#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
示例#2
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))
示例#3
0
文件: models.py 项目: Lucky1313/YACS
    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))
示例#4
0
    def test_days_of_week(self):
        section = SectionFactory.create()
        period1 = PeriodFactory.create(days_of_week_flag=models.Period.TUESDAY)
        period2 = PeriodFactory.create(days_of_week_flag=models.Period.MONDAY)
        SectionPeriodFactory.create(period=period1, section=section)
        SectionPeriodFactory.create(period=period2, section=section)

        expected = ['Monday', 'Tuesday']
        self.assertEqual(expected, section.days_of_week)
示例#5
0
文件: models.py 项目: Lucky1313/YACS
    def test_days_of_week(self):
        section = SectionFactory.create()
        period1 = PeriodFactory.create(days_of_week_flag=models.Period.TUESDAY)
        period2 = PeriodFactory.create(days_of_week_flag=models.Period.MONDAY)
        SectionPeriodFactory.create(period=period1, section=section)
        SectionPeriodFactory.create(period=period2, section=section)

        expected = ['Monday', 'Tuesday']
        self.assertEqual(expected, section.days_of_week)
示例#6
0
文件: models.py 项目: Lucky1313/YACS
    def test_conflicts_with_uses_period_conflict(self):
        period1 = PeriodFactory.build()
        period1.conflicts_with = Mock(return_value=False)
        period2 = PeriodFactory.build()
        sp1 = SectionPeriodFactory.build(period=period1)
        sp2 = SectionPeriodFactory.build(period=period2)

        self.assertFalse(sp1.conflicts_with(sp2))
        period1.conflicts_with.assert_called_with(period2)
示例#7
0
    def test_conflicts_with_uses_period_conflict(self):
        period1 = PeriodFactory.build()
        period1.conflicts_with = Mock(return_value=False)
        period2 = PeriodFactory.build()
        sp1 = SectionPeriodFactory.build(period=period1)
        sp2 = SectionPeriodFactory.build(period=period2)

        self.assertFalse(sp1.conflicts_with(sp2))
        period1.conflicts_with.assert_called_with(period2)
示例#8
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)
示例#9
0
文件: models.py 项目: Lucky1313/YACS
    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))
示例#10
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)
示例#11
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))
示例#12
0
 def test_get_sections_by_semester(self):
     sem = SemesterFactory.create()
     s1, s2 = SectionPeriodFactory.create_batch(2, semester=sem)
     s3, s4 = SectionPeriodFactory.create_batch(2)
     json = self.json_get(
         'v4:sections', get='?semester_id=%d' % sem.id, status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(s1),
             self.to_dict(s2),
         ]
     })
示例#13
0
文件: tests.py 项目: Radzell/YACS
 def test_get_sections_by_semester(self):
     sem = SemesterFactory.create()
     s1, s2 = SectionPeriodFactory.create_batch(2, semester=sem)
     s3, s4 = SectionPeriodFactory.create_batch(2)
     json = self.json_get(
         'v4:sections', get='?semester_id=%d' % sem.id, status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(s1),
             self.to_dict(s2),
         ]
     })
示例#14
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),
         ]
     })
示例#15
0
文件: tests.py 项目: Radzell/YACS
 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),
         ]
     })
示例#16
0
文件: smokes.py 项目: Radzell/YACS
    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
示例#17
0
文件: models.py 项目: Lucky1313/YACS
    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))
示例#18
0
文件: tests.py 项目: Radzell/YACS
 def test_get_section_by_id(self):
     s1, s2 = SectionPeriodFactory.create_batch(2)
     json = self.json_get('v4:sections', id=s1.id, status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": self.to_dict(s1),
     })
示例#19
0
 def test_get_section_by_id(self):
     s1, s2 = SectionPeriodFactory.create_batch(2)
     json = self.json_get('v4:sections', id=s1.id, status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": self.to_dict(s1),
     })
示例#20
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))
示例#21
0
 def test_get_sections(self):
     s1, s2, s3, s4 = SectionPeriodFactory.create_batch(4)
     json = self.json_get('v4:sections', status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(s1),
             self.to_dict(s2),
             self.to_dict(s3),
             self.to_dict(s4),
         ]
     })
示例#22
0
文件: tests.py 项目: Radzell/YACS
 def test_get_sections(self):
     s1, s2, s3, s4 = SectionPeriodFactory.create_batch(4)
     json = self.json_get('v4:sections', status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(s1),
             self.to_dict(s2),
             self.to_dict(s3),
             self.to_dict(s4),
         ]
     })
示例#23
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),
         ]
     })
示例#24
0
文件: tests.py 项目: Radzell/YACS
 def test_get_sections_by_crn(self):
     s1, s2, s3, s4 = SectionPeriodFactory.create_batch(4)
     json = self.json_get(
         'v4:sections',
         get='?crn=%d&crn=%d' % (s1.section.crn, s3.section.crn),
         status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(s1),
             self.to_dict(s3),
         ]
     })
示例#25
0
文件: tests.py 项目: Radzell/YACS
 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),
         ]
     })
示例#26
0
 def test_get_sections_by_crn(self):
     s1, s2, s3, s4 = SectionPeriodFactory.create_batch(4)
     json = self.json_get(
         'v4:sections',
         get='?crn=%d&crn=%d' % (s1.section.crn, s3.section.crn),
         status_code=200)
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(s1),
             self.to_dict(s3),
         ]
     })
示例#27
0
 def test_to_json(self):
     period = PeriodFactory.create()
     period.toJSON = Mock(return_value={'lol': 1})
     sp = SectionPeriodFactory.create(
         instructor='foo',
         location='bar',
         kind='fizz',
         period=period,
     )
     expected = {
         'instructor': 'foo',
         'location': 'bar',
         'kind': 'fizz',
         'lol': 1,
         'id': sp.id,
     }
     self.assertEqual(expected, sp.toJSON())
示例#28
0
文件: test_models.py 项目: jeffh/YACS
 def test_to_json(self):
     period = PeriodFactory.create()
     period.toJSON = Mock(return_value={'lol': 1})
     sp = SectionPeriodFactory.create(
         instructor='foo',
         location='bar',
         kind='fizz',
         period=period,
     )
     expected = {
         'instructor': 'foo',
         'location': 'bar',
         'kind': 'fizz',
         'lol': 1,
         'id': sp.id,
     }
     self.assertEqual(expected, sp.toJSON())