Example #1
0
    def test_forums_filter_updated(self):
        """Filter for updated date."""
        post_updated_ds = datetime(2010, 5, 3, 12, 00)

        thread1 = ThreadFactory(title="t1 audio")
        PostFactory(thread=thread1, created=post_updated_ds)

        thread2 = ThreadFactory(title="t2 audio")
        PostFactory(thread=thread2,
                    created=(post_updated_ds + timedelta(days=2)))

        self.refresh()

        qs = {
            "a": 1,
            "w": 4,
            "format": "json",
            "sortby": 1,
            "updated_date": "05/04/2010"
        }

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

        qs["updated"] = constants.INTERVAL_AFTER
        response = self.client.get(reverse("search.advanced"), qs)
        results = json.loads(response.content)["results"]
        eq_([thread2.get_absolute_url()], [r["url"] for r in results])
Example #2
0
    def test_forums_filter_updated(self):
        """Filter for updated date."""
        post_updated_ds = datetime(2010, 5, 3, 12, 00)

        thread1 = ThreadFactory(title='t1 audio')
        PostFactory(thread=thread1, created=post_updated_ds)

        thread2 = ThreadFactory(title='t2 audio')
        PostFactory(thread=thread2,
                    created=(post_updated_ds + timedelta(days=2)))

        self.refresh()

        qs = {
            'a': 1,
            'w': 4,
            'format': 'json',
            'sortby': 1,
            'updated_date': '05/04/2010'
        }

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

        qs['updated'] = constants.INTERVAL_AFTER
        response = self.client.get(reverse('search.advanced'), qs)
        results = json.loads(response.content)['results']
        eq_([thread2.get_absolute_url()], [r['url'] for r in results])
Example #3
0
    def test_posts_thread_belongs_to_forum(self):
        """Posts view - redirect if thread does not belong to forum."""
        f = ForumFactory()
        t = ThreadFactory()  # Thread belongs to a different forum

        r = get(self.client, "forums.posts", args=[f.slug, t.id])
        eq_(200, r.status_code)
        u = r.redirect_chain[0][0]
        assert u.endswith(t.get_absolute_url())
Example #4
0
    def test_posts_thread_belongs_to_forum(self):
        """Posts view - redirect if thread does not belong to forum."""
        f = ForumFactory()
        t = ThreadFactory()  # Thread belongs to a different forum

        r = get(self.client, 'forums.posts', args=[f.slug, t.id])
        eq_(200, r.status_code)
        u = r.redirect_chain[0][0]
        assert u.endswith(t.get_absolute_url())
Example #5
0
    def test_discussion_filter_sticky_locked(self):
        """Filter for locked and sticky threads."""
        thread1 = ThreadFactory(title="audio", is_locked=True, is_sticky=True)
        PostFactory(thread=thread1)

        self.refresh()

        qs = {"a": 1, "w": 4, "format": "json", "thread_type": (1, 2)}
        response = self.client.get(reverse("search.advanced"), qs)
        result = json.loads(response.content)["results"][0]
        eq_(thread1.get_absolute_url(), result["url"])
Example #6
0
    def test_discussion_filter_sticky_locked(self):
        """Filter for locked and sticky threads."""
        thread1 = ThreadFactory(title=u'audio', is_locked=True, is_sticky=True)
        PostFactory(thread=thread1)

        self.refresh()

        qs = {'a': 1, 'w': 4, 'format': 'json', 'thread_type': (1, 2)}
        response = self.client.get(reverse('search.advanced'), qs)
        result = json.loads(response.content)['results'][0]
        eq_(thread1.get_absolute_url(), result['url'])
    def test_discussion_filter_sticky_locked(self):
        """Filter for locked and sticky threads."""
        thread1 = ThreadFactory(title=u"audio", is_locked=True, is_sticky=True)
        PostFactory(thread=thread1)

        self.refresh()

        qs = {"a": 1, "w": 4, "format": "json", "thread_type": (1, 2)}
        response = self.client.get(reverse("search.advanced"), qs)
        result = json.loads(response.content)["results"][0]
        eq_(thread1.get_absolute_url(), result["url"])
    def test_forums_filter_updated(self):
        """Filter for updated date."""
        post_updated_ds = datetime(2010, 5, 3, 12, 00)

        thread1 = ThreadFactory(title=u"t1 audio")
        PostFactory(thread=thread1, created=post_updated_ds)

        thread2 = ThreadFactory(title=u"t2 audio")
        PostFactory(thread=thread2, created=(post_updated_ds + timedelta(days=2)))

        self.refresh()

        qs = {"a": 1, "w": 4, "format": "json", "sortby": 1, "updated_date": "05/04/2010"}

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

        qs["updated"] = constants.INTERVAL_AFTER
        response = self.client.get(reverse("search.advanced"), qs)
        results = json.loads(response.content)["results"]
        eq_([thread2.get_absolute_url()], [r["url"] for r in results])
Example #9
0
    def test_thread_absolute_url(self):
        t = ThreadFactory()

        eq_('/forums/%s/%s' % (t.forum.slug, t.id),
            t.get_absolute_url())
Example #10
0
    def test_thread_absolute_url(self):
        t = ThreadFactory()

        eq_('/forums/%s/%s' % (t.forum.slug, t.id),
            t.get_absolute_url())