本文整理汇总了Python中courses.models.Course.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Course.delete方法的具体用法?Python Course.delete怎么用?Python Course.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类courses.models.Course
的用法示例。
在下文中一共展示了Course.delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ResourceTest
# 需要导入模块: from courses.models import Course [as 别名]
# 或者: from courses.models.Course import delete [as 别名]
class ResourceTest(test_utils.AuthenticatedTest):
def setUp(self):
super(ResourceTest, self).setUp()
self.semester = Semester(name='Spring', year = '2012', start = datetime.date(2012, 1, 1), end = datetime.date(2012, 5, 1))
self.semester.save()
self.course = Course(title='Test Course', number = '101', section = '001', description = 'Test description of a course', semester = self.semester)
self.course.save()
def tearDown(self):
super(ResourceTest, self).tearDown()
self.course.delete()
self.semester.delete()
def test_create(self):
# Add client user as faculty member
self.course.faculty.add(self.user)
self.course.save()
# Test we get the form
response = self.c.get(reverse('courses:resource_create', kwargs = {'pk':self.course.id}))
self.assertEquals(response.status_code, 200)
response = self.c.post(reverse('courses:resource_create', kwargs = {'pk':self.course.id}), {'course':self.course.id,
'title':'Test Resource',
'description':'Test of the description <b>HERE</b>',
'due_date': (datetime.date.today() + one_week).isoformat()})
self.assertEquals(response.status_code, 302)
# Remove user
self.course.faculty.remove(self.user)
def test_list(self):
resource = Resource(course = self.course, title = "Test Resource", description = 'Test of the description <b>HERE</b>', link = 'http://example.com')
resource.save()
# Add client user as faculty member
self.course.faculty.add(self.user)
self.course.save()
response = self.c.get(reverse('courses:resources', kwargs = {'pk':self.course.id}))
self.assertEquals(response.status_code, 200)
self.assertEquals(response.context['resources'][0], resource)
# Remove user
self.course.faculty.remove(self.user)
def test_delete_resource(self):
# We overrode the delete, so we should be testing it
self.course.faculty.add(self.user)
resource = Resource(course = self.course, title = "Test Resource", description = 'Test of the description <b>HERE</b>', link = 'http://example.com')
resource.save()
resource_id = resource.id
response = self.c.post(reverse('courses:delete_resource'), {'id': resource.id})
self.assertRaises(Resource.DoesNotExist, Resource.objects.get, pk = resource_id)
示例2: CoursesTest
# 需要导入模块: from courses.models import Course [as 别名]
# 或者: from courses.models.Course import delete [as 别名]
class CoursesTest(test_utils.AuthenticatedTest):
def setUp(self):
super(CoursesTest, self).setUp()
self.semester = Semester(name='Spring', year = '2012', start = datetime.date(2012, 1, 1), end = datetime.date(2012, 5, 1))
self.semester.save()
self.course = Course(title='Test Course', number = '101', section = '001', description = 'Test description of a course', semester = self.semester)
self.course.save()
def tearDown(self):
self.course.delete()
self.semester.delete()
def test_create(self):
self.assertEquals(self.course.title, 'Test Course')
self.assertEquals(self.course.number, '101')
self.assertEquals(self.course.section, '001')
self.assertEquals(self.course.description, 'Test description of a course')
def test_view(self):
response = self.c.get(reverse('courses:overview', args = [self.course.id]))
self.assertEquals(response.context['course'].title, 'Test Course')
self.assertEquals(response.context['course'].number, '101')
self.assertEquals(response.context['course'].section, '001')
self.assertEquals(response.context['course'].description, 'Test description of a course')
def test_access(self):
self.course.private = True
self.course.save()
response = self.c.get(reverse('courses:overview', args = [self.course.id]))
self.assertEquals(response.status_code, 403)
# Test membership
self.course.members.add(self.user)
response = self.c.get(reverse('courses:overview', args = [self.course.id]))
self.assertEquals(response.status_code, 200)
self.course.members.remove(self.user)
# Test Faculty
self.course.faculty.add(self.user)
response = self.c.get(reverse('courses:overview', args = [self.course.id]))
self.assertEquals(response.status_code, 200)
self.course.faculty.remove(self.user)
self.course.private = False
self.course.save()
示例3: AssignmentTest
# 需要导入模块: from courses.models import Course [as 别名]
# 或者: from courses.models.Course import delete [as 别名]
class AssignmentTest(test_utils.AuthenticatedTest):
def setUp(self):
super(AssignmentTest, self).setUp()
self.semester = Semester(name='Spring', year = '2012', start = datetime.date(2012, 1, 1), end = datetime.date(2012, 5, 1))
self.semester.save()
self.course = Course(title='Test Course', number = '101', section = '001', description = 'Test description of a course', semester = self.semester)
self.course.save()
def tearDown(self):
super(AssignmentTest, self).tearDown()
self.course.delete()
self.semester.delete()
def test_create(self):
# Add client user as faculty member
self.course.faculty.add(self.user)
self.course.save()
# Test we get the form
response = self.c.get(reverse('courses:new_assignment', kwargs = {'pk':self.course.id}))
self.assertEquals(response.status_code, 200)
response = self.c.post(reverse('courses:new_assignment', kwargs = {'pk':self.course.id}), {'course':self.course.id,
'title':'Test Assignment',
'description':'Test of the description <b>HERE</b>',
'due_date': (datetime.date.today() + one_week).isoformat()})
self.assertEquals(response.status_code, 302)
# Remove user
self.course.faculty.remove(self.user)
def test_list(self):
assignment = Assignment(course = self.course, title = "Test Assignment", description = 'Test of the description <b>HERE</b>', due_date = (datetime.date.today() + one_week).isoformat())
assignment.save()
# Add client user as faculty member
self.course.faculty.add(self.user)
self.course.save()
response = self.c.get(reverse('courses:assignments', kwargs = {'pk':self.course.id}))
self.assertEquals(response.status_code, 200)
self.assertEquals(response.context['assignments'][0], assignment)
# Remove user
self.course.faculty.remove(self.user)
def test_submit(self):
# Add client user as faculty member
self.course.faculty.add(self.user)
self.course.save()
response = self.c.post(reverse('courses:new_assignment', kwargs = {'pk':self.course.id}), {'course':self.course.id,
'title':'Test Assignment',
'description':'Test of the description <b>HERE</b>',
'due_date': (datetime.date.today() + one_week).isoformat()})
# Remove user
self.course.faculty.remove(self.user)
self.course.members.add(self.user)
self.course.save()
assignment = Assignment.objects.get(course = self.course, title = 'Test Assignment')
# Test submitting solution
response = self.c.post(reverse('courses:submit_assignment', kwargs = {'pk':assignment.id}), {'link':'http://www.example.com',
'notes':'Test notes.',})
self.assertEquals(response.status_code, 302)
self.course.members.remove(self.user)
def test_faculty_see_submissions(self):
if not self.users:
self.extra_users()
# Create an assignment
self.assignment = Assignment(course = self.course,
title = 'Test Assignment',
description = 'Test',
due_date = (datetime.date.today() - one_week).isoformat()
)
self.assignment.save()
# Submit it
self.submission = AssignmentSubmission(assignment = self.assignment,
link = 'http://example.com',
)
self.submission.save()
self.submission.users.add(self.users[0])
# Set myself as the faculty for the course.
self.course.faculty.add(self.user)
self.course.save()
response = self.c.get(reverse('courses:assignment_overview', args = [self.assignment.id]))
#.........这里部分代码省略.........