本文整理匯總了Python中courses.tests.factories.SectionPeriodFactory.create方法的典型用法代碼示例。如果您正苦於以下問題:Python SectionPeriodFactory.create方法的具體用法?Python SectionPeriodFactory.create怎麽用?Python SectionPeriodFactory.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類courses.tests.factories.SectionPeriodFactory
的用法示例。
在下文中一共展示了SectionPeriodFactory.create方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_crns
# 需要導入模塊: from courses.tests.factories import SectionPeriodFactory [as 別名]
# 或者: from courses.tests.factories.SectionPeriodFactory import create [as 別名]
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
# 需要導入模塊: from courses.tests.factories import SectionPeriodFactory [as 別名]
# 或者: from courses.tests.factories.SectionPeriodFactory import create [as 別名]
def test_conflicts_with_uses_period_conflict(self):
period1 = PeriodFactory.create()
period1.conflicts_with = Mock(return_value=False)
period2 = PeriodFactory.create()
sp1 = SectionPeriodFactory.create(period=period1)
sp2 = SectionPeriodFactory.create(period=period2)
self.assertFalse(sp1.conflicts_with(sp2))
period1.conflicts_with.assert_called_with(period2)
示例3: test_days_of_week
# 需要導入模塊: from courses.tests.factories import SectionPeriodFactory [as 別名]
# 或者: from courses.tests.factories.SectionPeriodFactory import create [as 別名]
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
# 需要導入模塊: from courses.tests.factories import SectionPeriodFactory [as 別名]
# 或者: from courses.tests.factories.SectionPeriodFactory import create [as 別名]
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
# 需要導入模塊: from courses.tests.factories import SectionPeriodFactory [as 別名]
# 或者: from courses.tests.factories.SectionPeriodFactory import create [as 別名]
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_course
# 需要導入模塊: from courses.tests.factories import SectionPeriodFactory [as 別名]
# 或者: from courses.tests.factories.SectionPeriodFactory import create [as 別名]
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),
]
})
示例7: setUp
# 需要導入模塊: from courses.tests.factories import SectionPeriodFactory [as 別名]
# 或者: from courses.tests.factories.SectionPeriodFactory import create [as 別名]
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
示例8: test_kinds
# 需要導入模塊: from courses.tests.factories import SectionPeriodFactory [as 別名]
# 或者: from courses.tests.factories.SectionPeriodFactory import create [as 別名]
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))
示例9: test_search_instructor
# 需要導入模塊: from courses.tests.factories import SectionPeriodFactory [as 別名]
# 或者: from courses.tests.factories.SectionPeriodFactory import create [as 別名]
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
# 需要導入模塊: from courses.tests.factories import SectionPeriodFactory [as 別名]
# 或者: from courses.tests.factories.SectionPeriodFactory import create [as 別名]
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())