コード例 #1
0
ファイル: test_feeds.py プロジェクト: psbots/kitsune
 def test_tagged_feed_link(self):
     """Make sure the tagged feed is discoverable on the questions page."""
     tag(name='green', slug='green', save=True)
     url = urlparams(reverse('questions.questions'), tagged='green')
     response = self.client.get(url)
     doc = pq(response.content)
     feed_links = doc('link[type="application/atom+xml"]')
     eq_(2, len(feed_links))
     eq_('Recently updated questions', feed_links[0].attrib['title'])
     eq_('/en-US/questions/feed', feed_links[0].attrib['href'])
     eq_('Recently updated questions tagged green',
         feed_links[1].attrib['title'])
     eq_('/en-US/questions/tagged/green/feed', feed_links[1].attrib['href'])
コード例 #2
0
    def test_escalated(self):
        """Verify the escalated queryset."""
        t = tag(name=config.ESCALATE_TAG_NAME,
                slug=config.ESCALATE_TAG_NAME,
                save=True)
        q = question(save=True)

        # There should be no escalated questions yet.
        eq_(0, Question.objects.escalated().count())

        # Tag a question and there should be one escalated question.
        q.tags.add(t)
        eq_(1, Question.objects.escalated().count())
コード例 #3
0
ファイル: test_feeds.py プロジェクト: thelegend6420/kitsune
    def test_tagged_feed(self):
        """Test the tagged feed."""
        t = tag(name='green', slug='green', save=True)
        q = question(save=True)
        q.tags.add('green')
        items = TaggedQuestionsFeed().items(t)
        eq_(1, len(items))
        eq_(q.id, items[0].id)

        cache.clear()

        q = question(save=True)
        q.tags.add('green')
        q.updated = datetime.now() + timedelta(days=1)
        q.save()
        items = TaggedQuestionsFeed().items(t)
        eq_(2, len(items))
        eq_(q.id, items[0].id)
コード例 #4
0
    def test_hot_questions(self):
        """Verifies that hot questions show up in the hot topics section."""

        # Create a product and the hot topics topic.
        p = product(save=True)
        hot_tag = tag(name='hot', slug=HOT_TOPIC_SLUG, save=True)
        # Create a flag, since this code is flagged off by default.
        Flag.objects.create(name='hot_questions', everyone=True)

        # Create 4 hot questions.
        titles = ['apple', 'banana', 'cherry', 'date']
        timestamp = datetime.now() - timedelta(days=7)
        for i in range(4):
            q = question(title=titles[i], created=timestamp, save=True)
            q.products.add(p)
            q.tags.add(hot_tag)
            timestamp += timedelta(days=1)

        # Create a non-hot document.
        q = question(title='elderberry', save=True)
        q.products.add(p)

        # 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_(3, len(doc('#hot-topics li.question')))

        # Only the 3 newest hot topics should show up.
        assert 'apple' not in r.content
        assert 'banana' in r.content
        assert 'cherry' in r.content
        assert 'date' in r.content
        # Non-hot topics should not show up.
        assert 'elderberry' not in r.content
コード例 #5
0
ファイル: test_models.py プロジェクト: plounze/kitsune
 def test_add_existing_case_insensitive(self):
     """Assert add_existing_tag works case-insensitively."""
     tag(name='lemon', slug='lemon', save=True)
     add_existing_tag('LEMON', self.untagged_question.tags)
     tags_eq(self.untagged_question, [u'lemon'])