Esempio n. 1
0
class ThreadDatePagination(TestCase):
    def setUp(self):
        last_year = DateFactory.last_year()
        self.board = BoardFactory()
        self.thread = ThreadFactory(time_made=last_year,
                                    board=self.board,
                                    archived=True)
        self.threads = ThreadFactory.create_batch(50,
                                                  time_made=last_year,
                                                  board=self.board,
                                                  archived=True)
        self.first_page = self.client.get(self.thread.get_archive_year_url())
        self.second_page = self.client.get('{}?page=2'.format(
            self.thread.get_archive_year_url()))

    def test_first_page(self):
        for thread in self.threads:
            self.assertContains(self.first_page, thread.post)

    def test_first_page_not_contains(self):
        self.assertNotContains(self.first_page, self.thread.post)

    def test_second_page(self):
        self.assertContains(self.second_page, self.thread.post)

    def test_second_page_not_contains(self):
        for thread in self.threads:
            self.assertNotContains(self.second_page, thread.post)

    def test_page_url(self):
        self.assertContains(self.first_page, '?page=2')
Esempio n. 2
0
class ArchiveSearchFormPost(TestCase):
    def setUp(self):
        self.board = BoardFactory()
        self.thread = ThreadFactory(time_made=DateFactory.last_year(),
                                    archived=True,
                                    board=self.board)
        self.time = self.thread.time_made

    def test_board_url(self):
        resp = self.client.post(reverse('archive_search_form'),
                                {'board': self.board.name})
        self.assertRedirects(resp, expected_url=self.board.get_archive_url())

    def test_year_url(self):
        resp = self.client.post(reverse('archive_search_form'), {
            'board': self.board.name,
            'year': self.time.year
        })
        self.assertRedirects(resp,
                             expected_url=self.thread.get_archive_year_url())

    def test_month_url(self):
        resp = self.client.post(
            reverse('archive_search_form'), {
                'board': self.board.name,
                'year': self.time.year,
                'month': self.time.month
            })
        self.assertRedirects(resp,
                             expected_url=self.thread.get_archive_month_url())

    def test_day_url(self):
        resp = self.client.post(
            reverse('archive_search_form'), {
                'board': self.board.name,
                'year': self.time.year,
                'month': self.time.month,
                'day': self.time.day
            })
        self.assertRedirects(resp,
                             expected_url=self.thread.get_archive_day_url())