Beispiel #1
0
    def test_tags_change(self):
        tag = TagFactory()
        self.question.tags.add(tag)

        self.assertIn(tag.id, self.get_doc().question_tag_ids)

        self.question.tags.remove(tag)

        self.assertNotIn(tag.id, self.get_doc().question_tag_ids)
Beispiel #2
0
    def test_escalated(self):
        """Verify the escalated queryset."""
        t = TagFactory(name=config.ESCALATE_TAG_NAME,
                       slug=config.ESCALATE_TAG_NAME)
        q = QuestionFactory()

        # 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())
Beispiel #3
0
 def test_tagged_feed_link(self):
     """Make sure the tagged feed is discoverable on the questions page."""
     TagFactory(name="green", slug="green")
     url = urlparams(reverse("questions.list", args=["all"]),
                     tagged="green")
     response = self.client.get(url)
     eq_(200, response.status_code)
     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?product=all", 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"])
Beispiel #4
0
 def test_tagged_feed_link(self):
     """Make sure the tagged feed is discoverable on the questions page."""
     TagFactory(name='green', slug='green')
     url = urlparams(reverse('questions.list', args=['all']),
                     tagged='green')
     response = self.client.get(url)
     eq_(200, response.status_code)
     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?product=all', 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'])
Beispiel #5
0
    def test_tagged_feed(self):
        """Test the tagged feed."""
        t = TagFactory(name="green", slug="green")
        q = QuestionFactory()
        q.tags.add("green")
        items = TaggedQuestionsFeed().items(t)
        eq_(1, len(items))
        eq_(q.id, items[0].id)

        cache.clear()

        q = QuestionFactory()
        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)
Beispiel #6
0
    def test_auto_tagging(self):
        """Test that questions created via the API are auto-tagged."""
        TagFactory(name='desktop')
        q = QuestionFactory()
        self.client.force_authenticate(user=q.creator)
        tags_eq(q, [])

        res = self.client.post(
            reverse('question-set-metadata', args=[q.id]),
            content_type='application/json',
            data=json.dumps({'name': 'product', 'value': 'desktop'}))
        eq_(res.status_code, 200)
        tags_eq(q, [])

        res = self.client.post(
            reverse('question-auto-tag', args=[q.id]),
            content_type='application/json')
        eq_(res.status_code, 204)
        tags_eq(q, ['desktop'])
Beispiel #7
0
    def test_auto_tagging(self):
        """Test that questions created via the API are auto-tagged."""
        TagFactory(name="desktop")
        q = QuestionFactory()
        self.client.force_authenticate(user=q.creator)
        tags_eq(q, [])

        res = self.client.post(
            reverse("question-set-metadata", args=[q.id]),
            content_type="application/json",
            data=json.dumps({
                "name": "product",
                "value": "desktop"
            }),
        )
        eq_(res.status_code, 200)
        tags_eq(q, [])

        res = self.client.post(reverse("question-auto-tag", args=[q.id]),
                               content_type="application/json")
        eq_(res.status_code, 204)
        tags_eq(q, ["desktop"])
Beispiel #8
0
    def test_tag_delete(self):
        tag = TagFactory()
        self.question.tags.add(tag)
        tag.delete()

        self.assertEqual(self.get_doc().question_tag_ids, [])
Beispiel #9
0
 def test_add_existing_case_insensitive(self):
     """Assert add_existing_tag works case-insensitively."""
     TagFactory(name='lemon', slug='lemon')
     add_existing_tag('LEMON', self.untagged_question.tags)
     tags_eq(self.untagged_question, ['lemon'])
Beispiel #10
0
 def test_add_existing_case_insensitive(self):
     """Assert add_existing_tag works case-insensitively."""
     TagFactory(name="lemon", slug="lemon")
     add_existing_tag("LEMON", self.untagged_question.tags)
     tags_eq(self.untagged_question, [u"lemon"])