本文整理汇总了Python中django.http.request.HttpRequest.course方法的典型用法代码示例。如果您正苦于以下问题:Python HttpRequest.course方法的具体用法?Python HttpRequest.course怎么用?Python HttpRequest.course使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.http.request.HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.course方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_vocabulary_render_one
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import course [as 别名]
def test_vocabulary_render_one(self):
request = HttpRequest()
request.course = self.sample_course
vocabulary = Vocabulary.objects.get(name="shapes")
detail = VocabularyResource().render_one(request, vocabulary)
self.assertEquals(detail['display_name'], "Shapes")
self.assertEquals(len(detail['term_set']), 2)
示例2: test_vocabulary_render_list
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import course [as 别名]
def test_vocabulary_render_list(self):
request = HttpRequest()
request.course = self.sample_course
lst = VocabularyResource().render_list(
request, Vocabulary.objects.get_for_object(request.course))
self.assertEquals(len(lst), 2)
self.assertEquals(lst[0]['display_name'], "Colors")
self.assertEquals(len(lst[0]['term_set']), 3)
self.assertEquals(lst[1]['display_name'], "Shapes")
self.assertEquals(len(lst[1]['term_set']), 2)
示例3: test_vocabulary_render_related_multiple
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import course [as 别名]
def test_vocabulary_render_related_multiple(self):
request = HttpRequest()
request.course = self.sample_course
notes = SherdNote.objects.filter(title__in=['Left Corner', 'Nice Tie'])
ctx = VocabularyResource().render_related(request, notes)
self.assertEquals(len(ctx), 2)
self.assertEquals(ctx[0]['display_name'], 'Colors')
self.assertEquals(len(ctx[0]['term_set']), 1)
self.assertEquals(ctx[0]['term_set'][0]['display_name'], 'Red')
self.assertEquals(ctx[0]['term_set'][0]['count'], 1)
self.assertEquals(ctx[1]['display_name'], 'Shapes')
self.assertEquals(len(ctx[1]['term_set']), 1)
self.assertEquals(ctx[1]['term_set'][0]['display_name'], 'Square')
self.assertEquals(ctx[1]['term_set'][0]['count'], 2)
示例4: test_vocabulary_render_related
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import course [as 别名]
def test_vocabulary_render_related(self):
course = Course.objects.get(title="Sample Course")
request = HttpRequest()
request.course = course
notes = SherdNote.objects.filter(title='Left Corner')
ctx = VocabularyResource().render_related(request, notes)
self.assertEquals(len(ctx), 2)
self.assertEquals(ctx[0]['display_name'], 'Colors')
self.assertEquals(len(ctx[0]['term_set']), 1)
self.assertEquals(ctx[0]['term_set'][0]['display_name'], 'Red')
self.assertEquals(ctx[0]['term_set'][0]['count'], 1)
self.assertEquals(ctx[1]['display_name'], 'Shapes')
self.assertEquals(len(ctx[1]['term_set']), 1)
self.assertEquals(ctx[1]['term_set'][0]['display_name'], 'Square')
self.assertEquals(ctx[1]['term_set'][0]['count'], 1)
示例5: test_vocabulary_render_for_course
# 需要导入模块: from django.http.request import HttpRequest [as 别名]
# 或者: from django.http.request.HttpRequest import course [as 别名]
def test_vocabulary_render_for_course(self):
request = HttpRequest()
request.course = self.sample_course
notes = SherdNote.objects.filter(title='Nice Tie')
ctx = VocabularyResource().render_for_course(request, notes)
self.assertEquals(len(ctx), 2)
self.assertEquals(ctx[0]['display_name'], 'Colors')
self.assertEquals(len(ctx[0]['term_set']), 3)
self.assertEquals(ctx[0]['term_set'][0]['display_name'], 'Blue')
self.assertEquals(ctx[0]['term_set'][0]['count'], 0)
self.assertEquals(ctx[0]['term_set'][1]['display_name'], 'Green')
self.assertEquals(ctx[0]['term_set'][1]['count'], 0)
self.assertEquals(ctx[0]['term_set'][2]['display_name'], 'Red')
self.assertEquals(ctx[0]['term_set'][2]['count'], 0)
self.assertEquals(ctx[1]['display_name'], 'Shapes')
self.assertEquals(len(ctx[1]['term_set']), 2)
self.assertEquals(ctx[1]['term_set'][0]['display_name'], 'Square')
self.assertEquals(ctx[1]['term_set'][0]['count'], 1)
self.assertEquals(ctx[1]['term_set'][1]['display_name'], 'Triangle')
self.assertEquals(ctx[1]['term_set'][1]['count'], 0)