当前位置: 首页>>代码示例>>Python>>正文


Python HttpRequest.course方法代码示例

本文整理汇总了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)
开发者ID:avorio,项目名称:mediathread,代码行数:10,代码来源:test_api.py

示例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)
开发者ID:avorio,项目名称:mediathread,代码行数:14,代码来源:test_api.py

示例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)
开发者ID:avorio,项目名称:mediathread,代码行数:19,代码来源:test_api.py

示例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)
开发者ID:coati-00,项目名称:mediathread,代码行数:20,代码来源:test_api.py

示例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)
开发者ID:avorio,项目名称:mediathread,代码行数:25,代码来源:test_api.py


注:本文中的django.http.request.HttpRequest.course方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。