本文整理汇总了Python中courses.tests.factories.SectionFactory类的典型用法代码示例。如果您正苦于以下问题:Python SectionFactory类的具体用法?Python SectionFactory怎么用?Python SectionFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SectionFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_section_with_conflicting_periods
def test_conflicts_with_section_with_conflicting_periods(self):
def period():
m = Mock()
m.conflicts_with = Mock(return_value=True)
return m
section1, section2 = SectionFactory.create(), SectionFactory.create()
section1.get_periods = Mock(return_value=[period()])
section2.get_periods = Mock(return_value=[period()])
self.assertTrue(section1.conflicts_with(section2))
示例3: 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))
示例4: 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))
示例5: setUp
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
示例6: 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)
示例7: 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)
示例8: test_saving_and_loading
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)
示例9: 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),
]
})
示例10: test_to_json
def test_to_json(self):
section = SectionFactory.create(
number=1, crn=2, seats_taken=3, seats_total=4
)
expected = {
'number': 1,
'crn': 2,
'periods': [],
'seats_taken': 3,
'seats_total': 4,
'seats_left': 1,
'notes': [],
}
result = section.toJSON()
self.assertEqual(expected, result)
示例11: 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),
]
})
示例12: test_is_full
def test_is_full(self):
section = SectionFactory.build(seats_taken=2, seats_total=2)
self.assertTrue(section.is_full)
示例13: test_no_conflicts_using_cache
def test_no_conflicts_using_cache(self):
section1, section2 = SectionFactory.create(), SectionFactory.create()
section1.conflicts = set()
self.assertFalse(section1.conflicts_with(section2))
示例14: test_conflicts_with_using_cache
def test_conflicts_with_using_cache(self):
section1, section2 = SectionFactory.create(), SectionFactory.create()
section1.conflicts = set([section2.id])
self.assertTrue(section1.conflicts_with(section2))
示例15: test_conflicts_with_self
def test_conflicts_with_self(self):
section = SectionFactory.build()
self.assertTrue(section.conflicts_with(section))