本文整理汇总了Python中courses.tests.factories.DepartmentFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python DepartmentFactory.create_batch方法的具体用法?Python DepartmentFactory.create_batch怎么用?Python DepartmentFactory.create_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类courses.tests.factories.DepartmentFactory
的用法示例。
在下文中一共展示了DepartmentFactory.create_batch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_department_by_id
# 需要导入模块: from courses.tests.factories import DepartmentFactory [as 别名]
# 或者: from courses.tests.factories.DepartmentFactory import create_batch [as 别名]
def test_get_department_by_id(self):
d1, d2, d3 = DepartmentFactory.create_batch(3)
json = self.json_get('v4:departments', id=d1.id, status_code=200)
self.assertEqual(json, {
u"version": 4,
u"success": True,
u"result": self.as_dict(d1)
})
示例2: test_get_departments_by_code
# 需要导入模块: from courses.tests.factories import DepartmentFactory [as 别名]
# 或者: from courses.tests.factories.DepartmentFactory import create_batch [as 别名]
def test_get_departments_by_code(self):
d1, d2, d3 = DepartmentFactory.create_batch(3)
d4 = DepartmentFactory.create(code='FOO')
json = self.json_get(
'v4:departments', get='?code=FOO', status_code=200)
self.assertEqual(json, {
u"version": 4,
u"success": True,
u"result": [self.as_dict(d4)]
})
示例3: test_get_departments
# 需要导入模块: from courses.tests.factories import DepartmentFactory [as 别名]
# 或者: from courses.tests.factories.DepartmentFactory import create_batch [as 别名]
def test_get_departments(self):
d1, d2, d3, d4 = DepartmentFactory.create_batch(4)
json = self.json_get('v4:departments', status_code=200)
self.assertEqual(json, {
u"version": 4,
u"success": True,
u"result": [
self.as_dict(d1),
self.as_dict(d2),
self.as_dict(d3),
self.as_dict(d4),
]
})
示例4: test_get_departments_by_ids
# 需要导入模块: from courses.tests.factories import DepartmentFactory [as 别名]
# 或者: from courses.tests.factories.DepartmentFactory import create_batch [as 别名]
def test_get_departments_by_ids(self):
d1, d2, d3 = DepartmentFactory.create_batch(3)
json = self.json_get(
'v4:departments', get='?id=%d&id=%d' % (d1.id, d2.id),
status_code=200)
self.assertEqual(json, {
u"version": 4,
u"success": True,
u"result": [
self.as_dict(d1),
self.as_dict(d2),
]
})
示例5: test_get_departments_by_courses
# 需要导入模块: from courses.tests.factories import DepartmentFactory [as 别名]
# 或者: from courses.tests.factories.DepartmentFactory import create_batch [as 别名]
def test_get_departments_by_courses(self):
d1, d2, d3 = DepartmentFactory.create_batch(3)
c1 = CourseFactory.create(department=d1)
c2 = CourseFactory.create(department=d2)
c3 = CourseFactory.create(department=d3)
json = self.json_get(
'v4:departments',
get='?course_id=%d&course_id=%d' % (c1.id, c2.id),
status_code=200)
self.assertEqual(json, {
u"version": 4,
u"success": True,
u"result": [
self.as_dict(d1),
self.as_dict(d2),
]
})
示例6: test_get_departments_by_semester
# 需要导入模块: from courses.tests.factories import DepartmentFactory [as 别名]
# 或者: from courses.tests.factories.DepartmentFactory import create_batch [as 别名]
def test_get_departments_by_semester(self):
s1, s2 = SemesterFactory.create_batch(2)
d1, d2, d3 = DepartmentFactory.create_batch(3)
SemesterDepartmentFactory.create(semester=s1, department=d1)
SemesterDepartmentFactory.create(semester=s1, department=d2)
SemesterDepartmentFactory.create(semester=s2, department=d3)
json = self.json_get(
'v4:departments',
get='?semester_id=%d' % s1.id,
status_code=200)
self.assertEqual(json, {
u"version": 4,
u"success": True,
u"result": [
self.as_dict(d1),
self.as_dict(d2),
]
})