本文整理汇总了Python中courses.tests.factories.CourseFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python CourseFactory.create_batch方法的具体用法?Python CourseFactory.create_batch怎么用?Python CourseFactory.create_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类courses.tests.factories.CourseFactory
的用法示例。
在下文中一共展示了CourseFactory.create_batch方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_courses_by_number
# 需要导入模块: from courses.tests.factories import CourseFactory [as 别名]
# 或者: from courses.tests.factories.CourseFactory import create_batch [as 别名]
def test_get_courses_by_number(self):
c1, c2 = CourseFactory.create_batch(2, number=1337)
c3, c4 = CourseFactory.create_batch(2)
json = self.json_get('v4:courses', get='?number=1337', status_code=200)
self.assertEqual(json, {
u"version": 4,
u"success": True,
u"result": [
self.to_dict(c1),
self.to_dict(c2),
]
})
示例2: test_get_courses_by_dept_id
# 需要导入模块: from courses.tests.factories import CourseFactory [as 别名]
# 或者: from courses.tests.factories.CourseFactory import create_batch [as 别名]
def test_get_courses_by_dept_id(self):
d = DepartmentFactory.create(code='CSCI')
c1, c2 = CourseFactory.create_batch(2, department=d)
c3, c4 = CourseFactory.create_batch(2)
json = self.json_get(
'v4:courses', get='?department_id=%s' % d.id, status_code=200)
self.assertEqual(json, {
u"version": 4,
u"success": True,
u"result": [
self.to_dict(c1),
self.to_dict(c2),
]
})
示例3: test_search_department_name
# 需要导入模块: from courses.tests.factories import CourseFactory [as 别名]
# 或者: from courses.tests.factories.CourseFactory import create_batch [as 别名]
def test_search_department_name(self):
c1, c2 = CourseFactory.create_batch(2)
d = DepartmentFactory.create(name='Computer Science')
c3, c4 = CourseFactory.create_batch(2, department=d)
json = self.json_get(
'v4:courses', get='?search=Computer', status_code=200)
self.maxDiff = None
self.assertEqual(json, {
u"version": 4,
u"success": True,
u"result": [
self.to_dict(c3),
self.to_dict(c4),
],
})
示例4: test_get_course_by_id
# 需要导入模块: from courses.tests.factories import CourseFactory [as 别名]
# 或者: from courses.tests.factories.CourseFactory import create_batch [as 别名]
def test_get_course_by_id(self):
c1, c2 = CourseFactory.create_batch(2)
json = self.json_get('v4:courses', id=c1.id, status_code=200)
self.assertEqual(json, {
u"version": 4,
u"success": True,
u"result": self.to_dict(c1),
})
示例5: test_search_name
# 需要导入模块: from courses.tests.factories import CourseFactory [as 别名]
# 或者: from courses.tests.factories.CourseFactory import create_batch [as 别名]
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)],
})
示例6: test_search_department_code
# 需要导入模块: from courses.tests.factories import CourseFactory [as 别名]
# 或者: from courses.tests.factories.CourseFactory import create_batch [as 别名]
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)],
})
示例7: test_get_courses
# 需要导入模块: from courses.tests.factories import CourseFactory [as 别名]
# 或者: from courses.tests.factories.CourseFactory import create_batch [as 别名]
def test_get_courses(self):
c1, c2, c3 = CourseFactory.create_batch(3)
json = self.json_get('v4:courses', status_code=200)
self.maxDiff = None
self.assertEqual(json, {
u"version": 4,
u"success": True,
u"result": [
self.to_dict(c1),
self.to_dict(c2),
self.to_dict(c3),
]
})
示例8: test_get_courses_by_ids
# 需要导入模块: from courses.tests.factories import CourseFactory [as 别名]
# 或者: from courses.tests.factories.CourseFactory import create_batch [as 别名]
def test_get_courses_by_ids(self):
c1, c2, c3, c4 = CourseFactory.create_batch(4)
json = self.json_get(
'v4:courses',
get='?id=%d&id=%d' % (c1.id, c3.id),
status_code=200)
self.assertEqual(json, {
u"version": 4,
u"success": True,
u"result": [
self.to_dict(c1),
self.to_dict(c3),
]
})
示例9: test_search_instructor
# 需要导入模块: from courses.tests.factories import CourseFactory [as 别名]
# 或者: from courses.tests.factories.CourseFactory import create_batch [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_get_semester_by_course
# 需要导入模块: from courses.tests.factories import CourseFactory [as 别名]
# 或者: from courses.tests.factories.CourseFactory import create_batch [as 别名]
def test_get_semester_by_course(self):
c1, c2 = CourseFactory.create_batch(2)
OfferedForFactory.create(semester=self.s1, course=c1)
OfferedForFactory.create(semester=self.s2, course=c2)
json = self.json_get('v4:semesters', get='?course_id=%d' % c2.id)
# for some odd reason, accuracy is lost for datetimes.
for row in json['result']:
row['date_updated'] = row['date_updated'][:-7]
self.assertEqual(json, {
u"version": 4,
u"success": True,
u"result": [self.as_dict(self.s2)],
})