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


Python QuestionFactory.solution方法代码示例

本文整理汇总了Python中kitsune.questions.tests.QuestionFactory.solution方法的典型用法代码示例。如果您正苦于以下问题:Python QuestionFactory.solution方法的具体用法?Python QuestionFactory.solution怎么用?Python QuestionFactory.solution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kitsune.questions.tests.QuestionFactory的用法示例。


在下文中一共展示了QuestionFactory.solution方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _make_question

# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import solution [as 别名]
    def _make_question(self, solved=True, **kwargs):
        defaults = {
            'title': 'Login to website comments disabled ' + str(time.time()),
            'content': """
                readersupportednews.org, sends me emails with a list of
                articles to read.

                The links to the articles work as normal, except that I
                cannot login from the linked article - as required - to
                send my comments.

                I see a javascript activity statement at the bottom left
                corner of my screen while the left button is depressed
                on the Login button. it is gone when I release the left
                button, but no results.

                I have the latest (7) version of java enabled, on an XP
                box.

                Why this inability to login to this website commentary?
                """,
        }
        defaults.update(kwargs)
        q = QuestionFactory(**defaults)
        if solved:
            a = AnswerFactory(question=q)
            q.solution = a
        # Trigger a reindex for the question.
        q.save()
        return q
开发者ID:1234-,项目名称:kitsune,代码行数:32,代码来源:test_api.py

示例2: test_data_in_index

# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import solution [as 别名]
    def test_data_in_index(self):
        """Verify the data we are indexing."""
        p = ProductFactory()
        q = QuestionFactory(locale='pt-BR', product=p)
        a = AnswerFactory(question=q)

        self.refresh()

        eq_(AnswerMetricsMappingType.search().count(), 1)
        data = AnswerMetricsMappingType.search()[0]
        eq_(data['locale'], q.locale)
        eq_(data['product'], [p.slug])
        eq_(data['creator_id'], a.creator_id)
        eq_(data['is_solution'], False)
        eq_(data['by_asker'], False)

        # Mark as solution and verify
        q.solution = a
        q.save()

        self.refresh()
        data = AnswerMetricsMappingType.search()[0]
        eq_(data['is_solution'], True)

        # Make the answer creator to be the question creator and verify.
        a.creator = q.creator
        a.save()

        self.refresh()
        data = AnswerMetricsMappingType.search()[0]
        eq_(data['by_asker'], True)
开发者ID:1234-,项目名称:kitsune,代码行数:33,代码来源:test_es.py

示例3: test_responded

# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import solution [as 别名]
    def test_responded(self):
        """Verify the responded queryset."""
        # Create a question, there shouldn't be any responded yet.
        q = QuestionFactory()
        eq_(0, Question.objects.responded().count())

        # Add an answer, there should be one responded.
        a = AnswerFactory(question=q)
        eq_(1, Question.objects.responded().count())

        # Add an answer by the creator, there should be none responded.
        a = AnswerFactory(creator=q.creator, question=q)
        eq_(0, Question.objects.responded().count())

        # Add another answer, there should be one responded.
        a = AnswerFactory(question=q)
        eq_(1, Question.objects.responded().count())

        # Lock it, there should be none responded.
        q.is_locked = True
        q.save()
        eq_(0, Question.objects.responded().count())

        # Unlock it and mark solved, there should be none responded.
        q.is_locked = False
        q.solution = a
        q.save()
        eq_(0, Question.objects.responded().count())
开发者ID:1234-,项目名称:kitsune,代码行数:30,代码来源:test_managers.py

示例4: test_filter_solved_by

# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import solution [as 别名]
    def test_filter_solved_by(self):
        q1 = QuestionFactory()
        a1 = AnswerFactory(question=q1)
        q1.solution = a1
        q1.save()
        q2 = QuestionFactory()
        AnswerFactory(question=q2, creator=a1.creator)
        q3 = QuestionFactory()
        a3 = AnswerFactory(question=q3)
        q3.solution = a3
        q3.save()

        qs = self.filter_instance.filter_solved_by(self.queryset, a1.creator.username)
        eq_(list(qs), [q1])

        qs = self.filter_instance.filter_solved_by(self.queryset, a3.creator.username)
        eq_(list(qs), [q3])
开发者ID:Andisutra80,项目名称:kitsune,代码行数:19,代码来源:test_api.py

示例5: test_counts

# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import solution [as 别名]
    def test_counts(self):
        u = UserFactory()
        p = u.profile
        q = QuestionFactory(creator=u)
        AnswerFactory(creator=u)
        q.solution = AnswerFactory(question=q, creator=u)
        q.save()

        serializer = api.ProfileSerializer(instance=p)
        eq_(serializer.data['question_count'], 1)
        eq_(serializer.data['answer_count'], 2)
        eq_(serializer.data['solution_count'], 1)
开发者ID:1234-,项目名称:kitsune,代码行数:14,代码来源:test_api.py

示例6: test_filter_is_solved

# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import solution [as 别名]
    def test_filter_is_solved(self):
        q1 = QuestionFactory()
        a1 = AnswerFactory(question=q1)
        q1.solution = a1
        q1.save()
        q2 = QuestionFactory()

        qs = self.filter_instance.filter_is_solved(self.queryset, True)
        eq_(list(qs), [q1])

        qs = self.filter_instance.filter_is_solved(self.queryset, False)
        eq_(list(qs), [q2])
开发者ID:Andisutra80,项目名称:kitsune,代码行数:14,代码来源:test_api.py

示例7: test_num_solutions

# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import solution [as 别名]
    def test_num_solutions(self):
        u = UserFactory()
        q1 = QuestionFactory()
        q2 = QuestionFactory()
        a1 = AnswerFactory(creator=u, question=q1)
        a2 = AnswerFactory(creator=u, question=q2)
        eq_(num_solutions(u), 0)

        q1.solution = a1
        q1.save()
        eq_(num_solutions(u), 1)

        q2.solution = a2
        q2.save()
        eq_(num_solutions(u), 2)

        q1.solution = None
        q1.save()
        eq_(num_solutions(u), 1)

        a2.delete()
        eq_(num_solutions(u), 0)
开发者ID:1234-,项目名称:kitsune,代码行数:24,代码来源:test_utils.py

示例8: test_done

# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import solution [as 别名]
    def test_done(self):
        """Verify the done queryset."""
        # Create a question, there shouldn't be any done yet.
        q = QuestionFactory()
        eq_(0, Question.objects.done().count())

        # Add an answer, there shouldn't be any done yet.
        a = AnswerFactory(question=q)
        eq_(0, Question.objects.done().count())

        # Make it the solution, there should be one done.
        q.solution = a
        q.save()
        eq_(1, Question.objects.done().count())

        # Create a locked questions, there should be two done.
        QuestionFactory(is_locked=True)
        eq_(2, Question.objects.done().count())
开发者ID:1234-,项目名称:kitsune,代码行数:20,代码来源:test_managers.py

示例9: test_questions_by_product

# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import solution [as 别名]
    def test_questions_by_product(self):
        """Test product filtering of questions API call."""
        firefox_os = ProductFactory(slug='firefox-os')
        firefox = ProductFactory(slug='firefox')

        # A Firefox OS question with a solution:
        q = QuestionFactory(product=firefox_os)
        a = AnswerFactory(question=q)
        q.solution = a
        q.save()

        # A Firefox OS question with an answer:
        q = QuestionFactory(product=firefox_os)
        AnswerFactory(question=q)

        # A Firefox OS question without answers:
        q = QuestionFactory(product=firefox_os)

        # A Firefox question without answers:
        q = QuestionFactory(product=firefox, locale='pt-BR')

        # Verify no product filtering:
        r = self._get_api_result('api.kpi.questions')
        eq_(r['objects'][0]['solved'], 1)
        eq_(r['objects'][0]['responded_24'], 2)
        eq_(r['objects'][0]['responded_72'], 2)
        eq_(r['objects'][0]['questions'], 4)

        # Verify product=firefox-os
        r = self._get_api_result('api.kpi.questions', product='firefox-os')
        eq_(r['objects'][0]['solved'], 1)
        eq_(r['objects'][0]['responded_24'], 2)
        eq_(r['objects'][0]['responded_72'], 2)
        eq_(r['objects'][0]['questions'], 3)

        # Verify product=firefox
        r = self._get_api_result('api.kpi.questions', product='firefox')
        eq_(r['objects'][0]['questions'], 1)
        assert 'solved' not in r['objects'][0]
        assert 'responded_24' not in r['objects'][0]
        assert 'responded_72' not in r['objects'][0]
开发者ID:1234-,项目名称:kitsune,代码行数:43,代码来源:test_api.py

示例10: test_questions_by_locale

# 需要导入模块: from kitsune.questions.tests import QuestionFactory [as 别名]
# 或者: from kitsune.questions.tests.QuestionFactory import solution [as 别名]
    def test_questions_by_locale(self):
        """Test locale filtering of questions API call."""
        # An en-US question with a solution:
        q = QuestionFactory(locale='en-US')
        a = AnswerFactory(question=q)
        q.solution = a
        q.save()
        # An en-US question with an answer:
        q = QuestionFactory(locale='en-US')
        AnswerFactory(question=q)
        # An en-US question without answers:
        QuestionFactory(locale='en-US')

        # A pt-BR question without answers:
        QuestionFactory(locale='pt-BR')

        # Verify no locale filtering:
        r = self._get_api_result('api.kpi.questions')
        eq_(r['objects'][0]['solved'], 1)
        eq_(r['objects'][0]['responded_24'], 2)
        eq_(r['objects'][0]['responded_72'], 2)
        eq_(r['objects'][0]['questions'], 4)

        # Verify locale=en-US
        r = self._get_api_result('api.kpi.questions', locale='en-US')
        eq_(r['objects'][0]['solved'], 1)
        eq_(r['objects'][0]['responded_24'], 2)
        eq_(r['objects'][0]['responded_72'], 2)
        eq_(r['objects'][0]['questions'], 3)

        # Verify locale=pt-BR
        r = self._get_api_result('api.kpi.questions', locale='pt-BR')
        eq_(r['objects'][0]['questions'], 1)
        assert 'solved' not in r['objects'][0]
        assert 'responded_24' not in r['objects'][0]
        assert 'responded_72' not in r['objects'][0]
开发者ID:1234-,项目名称:kitsune,代码行数:38,代码来源:test_api.py


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