def test_created(self):
        """Basic functionality of created filter."""
        created_ds = datetime(2010, 6, 19, 12, 00)

        # on 6/19/2010
        q1 = QuestionFactory(title=u"q1 audio", created=created_ds)
        q1.tags.add(u"desktop")
        ans = AnswerFactory(question=q1)
        AnswerVoteFactory(answer=ans, helpful=True)

        # on 6/21/2010
        q2 = QuestionFactory(title=u"q2 audio", created=(created_ds + timedelta(days=2)), tags=[u"desktop"])
        ans = AnswerFactory(question=q2)
        AnswerVoteFactory(answer=ans, helpful=True)

        self.refresh()

        qs = {"a": 1, "w": 2, "format": "json", "sortby": 2, "created_date": "06/20/2010"}

        qs["created"] = constants.INTERVAL_BEFORE
        response = self.client.get(reverse("search.advanced"), qs)
        results = json.loads(response.content)["results"]
        eq_([q1.get_absolute_url()], [r["url"] for r in results])

        qs["created"] = constants.INTERVAL_AFTER
        response = self.client.get(reverse("search.advanced"), qs)
        results = json.loads(response.content)["results"]
        eq_([q2.get_absolute_url()], [r["url"] for r in results])
    def test_created(self):
        """Basic functionality of created filter."""
        created_ds = datetime(2010, 6, 19, 12, 00)

        # on 6/19/2010
        q1 = QuestionFactory(title=u'q1 audio', created=created_ds)
        q1.tags.add(u'desktop')
        ans = AnswerFactory(question=q1)
        AnswerVoteFactory(answer=ans, helpful=True)

        # on 6/21/2010
        q2 = QuestionFactory(
            title=u'q2 audio',
            created=(created_ds + timedelta(days=2)),
            tags=[u'desktop'])
        ans = AnswerFactory(question=q2)
        AnswerVoteFactory(answer=ans, helpful=True)

        self.refresh()

        qs = {'a': 1, 'w': 2, 'format': 'json',
              'sortby': 2, 'created_date': '06/20/2010'}

        qs['created'] = constants.INTERVAL_BEFORE
        response = self.client.get(reverse('search.advanced'), qs)
        results = json.loads(response.content)['results']
        eq_([q1.get_absolute_url()], [r['url'] for r in results])

        qs['created'] = constants.INTERVAL_AFTER
        response = self.client.get(reverse('search.advanced'), qs)
        results = json.loads(response.content)['results']
        eq_([q2.get_absolute_url()], [r['url'] for r in results])
Beispiel #3
0
class FlagTestCase(TestCaseBase):
    """Test the flag view."""
    def setUp(self):
        super(FlagTestCase, self).setUp()
        self.user = UserFactory()
        self.question = QuestionFactory(creator=self.user)

        self.client.login(username=self.user.username, password='******')

    def tearDown(self):
        super(FlagTestCase, self).tearDown()
        self.client.logout()

    def test_flag(self):
        """Flag a question."""
        d = {'content_type': ContentType.objects.get_for_model(Question).id,
             'object_id': self.question.id,
             'reason': 'spam',
             'next': self.question.get_absolute_url()}
        post(self.client, 'flagit.flag', d)
        eq_(1, FlaggedObject.objects.count())

        flag = FlaggedObject.objects.all()[0]
        eq_(self.user.username, flag.creator.username)
        eq_('spam', flag.reason)
        eq_(self.question, flag.content_object)
Beispiel #4
0
class FlagTestCase(TestCaseBase):
    """Test the flag view."""
    def setUp(self):
        super(FlagTestCase, self).setUp()
        self.user = UserFactory()
        self.question = QuestionFactory(creator=self.user)

        self.client.login(username=self.user.username, password="******")

    def tearDown(self):
        super(FlagTestCase, self).tearDown()
        self.client.logout()

    def test_flag(self):
        """Flag a question."""
        d = {
            "content_type": ContentType.objects.get_for_model(Question).id,
            "object_id": self.question.id,
            "reason": "spam",
            "next": self.question.get_absolute_url(),
        }
        post(self.client, "flagit.flag", d)
        eq_(1, FlaggedObject.objects.count())

        flag = FlaggedObject.objects.all()[0]
        eq_(self.user.username, flag.creator.username)
        eq_("spam", flag.reason)
        eq_(self.question, flag.content_object)
Beispiel #5
0
    def test_created(self):
        """Basic functionality of created filter."""
        created_ds = datetime(2010, 6, 19, 12, 00)

        # on 6/19/2010
        q1 = QuestionFactory(title="q1 audio", created=created_ds)
        q1.tags.add("desktop")
        ans = AnswerFactory(question=q1)
        AnswerVoteFactory(answer=ans, helpful=True)

        # on 6/21/2010
        q2 = QuestionFactory(title="q2 audio",
                             created=(created_ds + timedelta(days=2)),
                             tags=["desktop"])
        ans = AnswerFactory(question=q2)
        AnswerVoteFactory(answer=ans, helpful=True)

        self.refresh()

        qs = {
            "a": 1,
            "w": 2,
            "format": "json",
            "sortby": 2,
            "created_date": "06/20/2010"
        }

        qs["created"] = constants.INTERVAL_BEFORE
        response = self.client.get(reverse("search.advanced"), qs)
        results = json.loads(response.content)["results"]
        eq_([q1.get_absolute_url()], [r["url"] for r in results])

        qs["created"] = constants.INTERVAL_AFTER
        response = self.client.get(reverse("search.advanced"), qs)
        results = json.loads(response.content)["results"]
        eq_([q2.get_absolute_url()], [r["url"] for r in results])