本文整理汇总了Python中courses.tests.factories.SectionPeriodFactory类的典型用法代码示例。如果您正苦于以下问题:Python SectionPeriodFactory类的具体用法?Python SectionPeriodFactory怎么用?Python SectionPeriodFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SectionPeriodFactory类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_crns
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))
示例2: test_conflicts_with_uses_period_conflict
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)
示例3: test_days_of_week
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)
示例4: test_full_crns
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))
示例5: setUp
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)
示例6: test_get_sections_by_semester
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),
]
})
示例7: test_get_sections_by_course
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),
]
})
示例8: setUp
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
示例9: test_kinds
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))
示例10: test_get_section_by_id
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),
})
示例11: test_get_sections
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),
]
})
示例12: test_get_sections_by_crn
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),
]
})
示例13: test_search_instructor
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),
]
})
示例14: test_to_json
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())