本文整理汇总了Python中courses.tests.factories.DepartmentFactory类的典型用法代码示例。如果您正苦于以下问题:Python DepartmentFactory类的具体用法?Python DepartmentFactory怎么用?Python DepartmentFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DepartmentFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_departments_by_code
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)]
})
示例2: setUp
def setUp(self):
self.sem = SemesterFactory.create()
self.dept1 = DepartmentFactory.create(code='CSCI')
self.dept2 = DepartmentFactory.create()
self.course1 = CourseFactory.create(department=self.dept1, name='the course')
OfferedForFactory.create(course=self.course1, semester=self.sem)
self.course2 = CourseFactory.create(department=self.dept2)
OfferedForFactory.create(course=self.course2, semester=self.sem)
self.course3 = CourseFactory.create(department=self.dept1, name='another course')
OfferedForFactory.create(course=self.course3, semester=self.sem)
示例3: test_get_semester_by_dept
def test_get_semester_by_dept(self):
d1 = DepartmentFactory.create()
d2 = DepartmentFactory.create()
SemesterDepartmentFactory.create(semester=self.s1, department=d1)
SemesterDepartmentFactory.create(semester=self.s2, department=d2)
json = self.json_get('v4:semesters', get='?department_id=%d' % d1.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.s1)],
})
示例4: 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
示例5: test_get_department_by_id
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)
})
示例6: test_search_department_code
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_by_dept_id
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),
]
})
示例8: test_get_departments
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),
]
})
示例9: test_get_departments_by_ids
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),
]
})
示例10: test_search_department_name
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),
],
})
示例11: test_get_departments_by_courses
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),
]
})
示例12: test_get_departments_by_semester
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),
]
})
示例13: setUp
def setUp(self):
self.s = SemesterFactory.create(year=2012)
self.d = DepartmentFactory.create()
SemesterDepartmentFactory(department=self.d, semester=self.s)
示例14: test_code
def test_code(self):
dept = DepartmentFactory.build(code='CSCI')
course = CourseFactory.build(department=dept, number=1100)
self.assertEqual('CSCI 1100', course.code)
示例15: setUp
def setUp(self):
self.dept = DepartmentFactory.create(name='foo', code='CSCI')