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


Python tests.topic函数代码示例

本文整理汇总了Python中topics.tests.topic函数的典型用法代码示例。如果您正苦于以下问题:Python topic函数的具体用法?Python topic怎么用?Python topic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_search_suggestion_questions_locale

    def test_search_suggestion_questions_locale(self):
        """Verifies the right languages show up in search suggestions."""
        topic(title="Fix problems", slug="fix-problems", save=True)
        p = product(slug=u"firefox", save=True)

        q1 = question(title="question cupcakes?", save=True, locale="en-US")
        q1.products.add(p)
        q2 = question(title="question donuts?", save=True, locale="en-US")
        q2.products.add(p)
        q3 = question(title="question pies?", save=True, locale="pt-BR")
        q3.products.add(p)
        q4 = question(title="question pastries?", save=True, locale="de")
        q4.products.add(p)

        self.refresh()

        def sub_test(locale, *titles):
            url = urlparams(
                reverse("questions.aaq_step4", args=["desktop", "fix-problems"], locale=locale), search="question"
            )
            response = self.client.get(url, follow=True)
            doc = pq(response.content)
            eq_msg(len(doc(".result.question")), len(titles), "Wrong number of results for {0}".format(locale))
            for substr in titles:
                assert substr in doc(".result.question h3 a").text()

        sub_test("en-US", "cupcakes?", "donuts?")
        sub_test("pt-BR", "cupcakes?", "donuts?", "pies?")
        sub_test("de", "cupcakes?", "donuts?", "pastries?")
开发者ID:atopal,项目名称:kitsune,代码行数:29,代码来源:test_views.py

示例2: test_subtopics

    def test_subtopics(self):
        """Verifies subtopics appear on document listing page."""
        # Create a topic and product.
        t = topic(save=True)
        p = product(save=True)

        # Create a documents with the topic and product
        doc = revision(is_approved=True, save=True).document
        doc.topics.add(t)
        doc.products.add(p)

        self.refresh()

        # GET the page and verify no subtopics yet.
        url = reverse('products.documents', args=[p.slug, t.slug])
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)
        doc = pq(r.content)
        eq_(0, len(doc('ul.subtopics')))

        # Create a subtopic and verify it is listed
        topic(parent=t, save=True)
        url = reverse('products.documents', args=[p.slug, t.slug])
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)
        doc = pq(r.content)
        eq_(1, len(doc('ul.subtopics')))
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:27,代码来源:test_templates.py

示例3: test_locale_filter

    def test_locale_filter(self):
        """Only questions for the current locale should be shown on the
        questions front page for AAQ locales."""

        eq_(Question.objects.count(), 0)
        topic(title="Fix problems", slug="fix-problems", save=True)
        p = product(slug=u"firefox", save=True)

        q1 = question(title="question cupcakes?", save=True, locale="en-US")
        q1.products.add(p)
        q2 = question(title="question donuts?", save=True, locale="en-US")
        q2.products.add(p)
        q3 = question(title="question pies?", save=True, locale="pt-BR")
        q3.products.add(p)
        q4 = question(title="question pastries?", save=True, locale="de")
        q4.products.add(p)

        def sub_test(locale, *titles):
            url = urlparams(reverse("questions.questions", locale=locale))
            response = self.client.get(url, follow=True)
            doc = pq(response.content)
            eq_msg(len(doc("section[id^=question]")), len(titles), "Wrong number of results for {0}".format(locale))
            for substr in titles:
                assert substr in doc(".questions section .content h2 a").text()

        # en-US and pt-BR are both in AAQ_LOCALES, so should be filtered.
        sub_test("en-US", "cupcakes?", "donuts?")
        sub_test("pt-BR", "pies?")
        # de is not in AAQ_LOCALES, so should show en-US, but not pt-BR
        sub_test("de", "cupcakes?", "donuts?", "pastries?")
开发者ID:atopal,项目名称:kitsune,代码行数:30,代码来源:test_views.py

示例4: test_question_topics

    def test_question_topics(self):
        """Search questions for topics."""
        t1 = topic(slug='doesnotexist', save=True)
        t2 = topic(slug='cookies', save=True)
        t3 = topic(slug='sync', save=True)

        q = question(save=True)
        q.topics.add(t2)
        q = question(save=True)
        q.topics.add(t2)
        q.topics.add(t3)

        self.refresh()

        topic_vals = (
            (t1.slug, 0),
            (t2.slug, 2),
            (t3.slug, 1),
            ([t2.slug, t3.slug], 1),
        )

        qs = {'a': 1, 'w': 2, 'format': 'json'}
        for topics, number in topic_vals:
            qs.update({'topics': topics})
            response = self.client.get(reverse('search'), qs)
            eq_(number, json.loads(response.content)['total'])
开发者ID:LASarkar,项目名称:kitsune,代码行数:26,代码来源:test_es.py

示例5: _new_question

 def _new_question(self, post_it=False):
     """Post a new question and return the response."""
     topic(title="Fix problems", slug="fix-problems", save=True)
     url = urlparams(reverse("questions.aaq_step5", args=["desktop", "fix-problems"]), search="A test question")
     if post_it:
         return self.client.post(url, self.data, follow=True)
     return self.client.get(url, follow=True)
开发者ID:atopal,项目名称:kitsune,代码行数:7,代码来源:test_views.py

示例6: test_wiki_topics

    def test_wiki_topics(self):
        """Search wiki for topics, includes multiple."""
        t1 = topic(slug='doesnotexist', save=True)
        t2 = topic(slug='extant', save=True)
        t3 = topic(slug='tagged', save=True)

        doc = document(locale=u'en-US', category=10, save=True)
        doc.topics.add(t2)
        revision(document=doc, is_approved=True, save=True)

        doc = document(locale=u'en-US', category=10, save=True)
        doc.topics.add(t2)
        doc.topics.add(t3)
        revision(document=doc, is_approved=True, save=True)

        self.refresh()

        topic_vals = (
            (t1.slug, 0),
            (t2.slug, 2),
            (t3.slug, 1),
            ([t2.slug, t3.slug], 1),
        )

        qs = {'a': 1, 'w': 1, 'format': 'json'}
        for topics, number in topic_vals:
            qs.update({'topics': topics})
            response = self.client.get(reverse('search'), qs)
            eq_(number, json.loads(response.content)['total'])
开发者ID:LASarkar,项目名称:kitsune,代码行数:29,代码来源:test_es.py

示例7: setUp

    def setUp(self):
        super(TestFacetHelpers, self).setUp()

        # Create topics
        self.general = topic(slug='general', save=True)
        self.bookmarks = topic(slug='bookmarks', save=True)
        self.sync = topic(slug='sync', save=True)

        # Create products
        self.desktop = product(slug='firefox', save=True)
        self.mobile = product(slug='mobile', save=True)

        # Set up documents.
        doc1 = revision(is_approved=True, save=True).document
        doc1.topics.add(self.general)
        doc1.topics.add(self.bookmarks)
        doc1.products.add(self.desktop)

        doc2 = revision(is_approved=True, save=True).document
        doc2.topics.add(self.bookmarks)
        doc2.topics.add(self.sync)
        doc2.products.add(self.desktop)
        doc2.products.add(self.mobile)

        self.refresh()
开发者ID:Owen66,项目名称:kitsune,代码行数:25,代码来源:test_facets.py

示例8: test_search_suggestions_archived_articles

    def test_search_suggestions_archived_articles(self):
        """Verifies that archived articles aren't shown."""
        topic(title='Fix problems', slug='fix-problems', save=True)
        p = product(slug=u'firefox', save=True)

        d1 = document(title=u'document donut', category=10, save=True)
        d1.products.add(p)
        revision(document=d1, is_approved=True, save=True)

        d2 = document(title=u'document cupcake', category=10, is_archived=True,
                      save=True)
        d2.products.add(p)
        revision(document=d1, is_approved=True, save=True)

        self.refresh()

        url = urlparams(
            reverse('questions.aaq_step4', args=['desktop', 'fix-problems']),
            search='document')

        response = self.client.get(url, follow=True)
        eq_(200, response.status_code)

        doc = pq(response.content)
        eq_(len(doc('.result.document')), 1)
        assert 'donut' in doc('.result.document h3 a').text()
        assert 'cupcake' not in doc('.result.document h3 a').text()
开发者ID:bajubullet,项目名称:kitsune,代码行数:27,代码来源:test_views.py

示例9: test_search_suggestions

    def test_search_suggestions(self):
        """Verifies the view doesn't kick up an HTTP 500"""
        topic(title='Fix problems', slug='fix-problems', save=True)

        q = question(title=u'CupcakesQuestion cupcakes', save=True)
        q.tags.add(u'desktop')
        q.save()

        d = document(title=u'CupcakesKB cupcakes', category=10, save=True)
        d.products.add(product(slug=u'firefox', save=True))
        d.save()

        rev = revision(document=d, is_approved=True, save=True)

        self.refresh()

        url = urlparams(
            reverse('questions.aaq_step4', args=['desktop', 'fix-problems']),
            search='cupcakes')

        response = self.client.get(url, follow=True)
        eq_(200, response.status_code)

        assert 'CupcakesQuestion' in response.content
        assert 'CupcakesKB' in response.content
开发者ID:victorneo,项目名称:kitsune,代码行数:25,代码来源:test_views.py

示例10: test_product_landing

    def test_product_landing(self, flag_is_active):
        """Verify that /products/<slug> page renders topics."""
        flag_is_active.return_value = True

        # Create a product.
        p = product(save=True)

        # Create some topics.
        topic(slug=HOT_TOPIC_SLUG, save=True)
        topics = []
        for i in range(11):
            topics.append(topic(save=True))

        # Create a document and assign the product and 10 topics.
        doc = revision(is_approved=True, save=True).document
        doc.products.add(p)
        for i in range(10):
            doc.topics.add(topics[i])

        self.refresh()

        # GET the product landing page and verify the content.
        url = reverse('products.product', args=[p.slug])
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)
        doc = pq(r.content)
        eq_(10, len(doc('#help-topics li')))
开发者ID:Hugh-McCurdy,项目名称:kitsune,代码行数:27,代码来源:test_templates.py

示例11: test_search_suggestion_question_age

    def test_search_suggestion_question_age(self):
        """Verifies the view doesn't return old questions."""
        topic(title='Fix problems', slug='fix-problems', save=True)
        p = product(slug=u'firefox', save=True)

        q1 = question(title='Fresh Cupcakes', save=True)
        q1.products.add(p)

        max_age = settings.SEARCH_DEFAULT_MAX_QUESTION_AGE
        too_old = datetime.now() - timedelta(seconds=max_age * 2)
        q2 = question(title='Stale Cupcakes', created=too_old, updated=too_old,
                      save=True)
        q2.products.add(p)

        self.refresh()

        url = urlparams(
            reverse('questions.aaq_step4', args=['desktop', 'fix-problems']),
                    search='cupcakes')

        response = self.client.get(url, follow=True)
        eq_(200, response.status_code)

        self.assertContains(response, q1.title)
        self.assertNotContains(response, q2.title)
开发者ID:bajubullet,项目名称:kitsune,代码行数:25,代码来源:test_views.py

示例12: test_locale_filter

    def test_locale_filter(self):
        """Only questions for the current locale should be shown on the
        questions front page for AAQ locales."""

        eq_(Question.objects.count(), 0)
        topic(title='Fix problems', slug='fix-problems', save=True)
        p = product(slug=u'firefox', save=True)

        q1 = question(title='question cupcakes?', save=True, locale='en-US')
        q1.products.add(p)
        q2 = question(title='question donuts?', save=True, locale='en-US')
        q2.products.add(p)
        q3 = question(title='question pies?', save=True, locale='pt-BR')
        q3.products.add(p)
        q4 = question(title='question pastries?', save=True, locale='de')
        q4.products.add(p)

        def sub_test(locale, *titles):
            url = urlparams(reverse('questions.questions', locale=locale))
            response = self.client.get(url, follow=True)
            doc = pq(response.content)
            eq_msg(len(doc('section[id^=question]')), len(titles),
                   'Wrong number of results for {0}'.format(locale))
            for substr in titles:
                assert substr in doc('.questions section .content h2 a').text()

        # en-US and pt-BR are both in AAQ_LOCALES, so should be filtered.
        sub_test('en-US', 'cupcakes?', 'donuts?')
        sub_test('pt-BR', 'pies?')
        # de is not in AAQ_LOCALES, so should show en-US, but not pt-BR
        sub_test('de', 'cupcakes?', 'donuts?', 'pastries?')
开发者ID:bajubullet,项目名称:kitsune,代码行数:31,代码来源:test_views.py

示例13: test_document_listing

    def test_document_listing(self, flag_is_active):
        """Verify /products/<product slug>/<topic slug> renders articles."""
        flag_is_active.return_value = True

        # Create a topic and product.
        t1 = topic(save=True)
        t2 = topic(save=True)
        p = product(save=True)

        # Create 3 documents with the topic and product and one without.
        for i in range(3):
            doc = revision(is_approved=True, save=True).document
            doc.topics.add(t1)
            doc.products.add(p)
            if i == 1:  # Only one document with t2
                doc.topics.add(t2)

        doc = revision(is_approved=True, save=True).document

        self.refresh()

        # GET the page and verify the content.
        url = reverse('products.documents', args=[p.slug, t1.slug])
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)
        doc = pq(r.content)
        eq_(3, len(doc('#document-list > ul > li')))

        # GET the page with refine topic and verify the content.
        url = reverse('products.documents', args=[p.slug, t1.slug])
        url = urlparams(url, refine=t2.slug)
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)
        doc = pq(r.content)
        eq_(1, len(doc('#document-list > ul > li')))
开发者ID:Uwanja,项目名称:kitsune,代码行数:35,代码来源:test_templates.py

示例14: test_search_suggestion_questions_locale

    def test_search_suggestion_questions_locale(self):
        """Verifies the right languages show up in search suggestions."""
        topic(title='Fix problems', slug='fix-problems', save=True)
        p = product(slug=u'firefox', save=True)

        q1 = question(title='question cupcakes?', save=True, locale='en-US')
        q1.products.add(p)
        q2 = question(title='question donuts?', save=True, locale='en-US')
        q2.products.add(p)
        q3 = question(title='question pies?', save=True, locale='pt-BR')
        q3.products.add(p)
        q4 = question(title='question pastries?', save=True, locale='de')
        q4.products.add(p)

        self.refresh()

        def sub_test(locale, *titles):
            url = urlparams(reverse('questions.aaq_step4',
                                    args=['desktop', 'fix-problems'],
                                    locale=locale),
                            search='question')
            response = self.client.get(url, follow=True)
            doc = pq(response.content)
            eq_msg(len(doc('.result.question')), len(titles),
                   'Wrong number of results for {0}'.format(locale))
            for substr in titles:
                assert substr in doc('.result.question h3 a').text()

        sub_test('en-US', 'cupcakes?', 'donuts?')
        sub_test('pt-BR', 'cupcakes?', 'donuts?', 'pies?')
        sub_test('de', 'cupcakes?', 'donuts?', 'pastries?')
开发者ID:bajubullet,项目名称:kitsune,代码行数:31,代码来源:test_views.py

示例15: _new_question

 def _new_question(self, post_it=False):
     """Post a new question and return the response."""
     topic(title='Fix problems', slug='fix-problems', save=True)
     url = urlparams(
         reverse('questions.aaq_step5', args=['desktop', 'fix-problems']),
         search='A test question')
     if post_it:
         return self.client.post(url, self.data, follow=True)
     return self.client.get(url, follow=True)
开发者ID:bajubullet,项目名称:kitsune,代码行数:9,代码来源:test_views.py


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