Exemplo n.º 1
0
    def test_post_api_list(self):
        '''It should fetch a post list from the API'''
        posts = PostFactory.create_batch(3)

        response = self.get(url_for('api.posts'))
        self.assert200(response)
        self.assertEqual(len(response.json['data']), len(posts))
Exemplo n.º 2
0
    def test_post_api_list(self, api):
        '''It should fetch a post list from the API'''
        posts = PostFactory.create_batch(3)

        response = api.get(url_for('api.posts'))
        assert200(response)
        assert len(response.json['data']) == len(posts)
Exemplo n.º 3
0
    def test_render_display_with_siblings(self, client, templates):
        '''It should render the post page with sibling links'''
        previous_date = faker.date_time_between(start_date='-3d',
                                                end_date='-2d')
        date = faker.date_time_between(start_date='-2d', end_date='-1d')
        next_date = faker.date_time_between(start_date='-1d', end_date='now')
        other_date = faker.date_time_between(start_date='-1y', end_date='-3d')

        previous_post = PostFactory(published=previous_date)
        post = PostFactory(published=date)
        next_post = PostFactory(published=next_date)
        PostFactory.create_batch(3, published=other_date)

        response = client.get(url_for('posts.show', post=post))

        assert200(response)
        assert templates.get_context_variable('previous_post') == previous_post
        assert templates.get_context_variable('next_post') == next_post
Exemplo n.º 4
0
    def test_render_list(self, client, templates):
        '''It should render the post list page'''
        posts = PostFactory.create_batch(3)

        response = client.get(url_for('posts.list'))

        assert200(response)
        rendered_posts = templates.get_context_variable('posts')
        assert len(rendered_posts) == len(posts)
Exemplo n.º 5
0
    def test_render_display_with_siblings(self, client, templates):
        '''It should render the post page with sibling links'''
        previous_date = faker.date_time_between(start_date='-3d',
                                                end_date='-2d')
        date = faker.date_time_between(start_date='-2d', end_date='-1d')
        next_date = faker.date_time_between(start_date='-1d', end_date='now')
        other_date = faker.date_time_between(start_date='-1y', end_date='-3d')

        previous_post = PostFactory(published=previous_date)
        post = PostFactory(published=date)
        next_post = PostFactory(published=next_date)
        PostFactory.create_batch(3, published=other_date)

        response = client.get(url_for('posts.show', post=post))

        assert200(response)
        assert templates.get_context_variable('previous_post') == previous_post
        assert templates.get_context_variable('next_post') == next_post
Exemplo n.º 6
0
    def test_render_list(self, client, templates):
        '''It should render the post list page'''
        posts = PostFactory.create_batch(3)

        response = client.get(url_for('posts.list'))

        assert200(response)
        rendered_posts = templates.get_context_variable('posts')
        assert len(rendered_posts) == len(posts)
Exemplo n.º 7
0
    def test_render_list(self):
        '''It should render the post list page'''
        posts = PostFactory.create_batch(3)

        response = self.get(url_for('posts.list'))

        self.assert200(response)
        rendered_posts = self.get_context_variable('posts')
        self.assertEqual(len(rendered_posts), len(posts))
Exemplo n.º 8
0
    def test_post_api_list(self, api):
        '''It should fetch a post list from the API'''
        posts = PostFactory.create_batch(3)
        posts.append(PostFactory(published=None))

        response = api.get(url_for('api.posts'))
        assert200(response)
        # Response should not contain the unpublished post
        assert len(response.json['data']) == 3
Exemplo n.º 9
0
    def test_render_display_with_siblings(self):
        '''It should render the post page with sibling links'''
        previous_date = faker.date_time_between(start_date='-3d',
                                                end_date='-2d')
        date = faker.date_time_between(start_date='-2d', end_date='-1d')
        next_date = faker.date_time_between(start_date='-1d', end_date='now')
        other_date = faker.date_time_between(start_date='-1y', end_date='-3d')

        previous_post = PostFactory(created_at=previous_date)
        post = PostFactory(created_at=date)
        next_post = PostFactory(created_at=next_date)
        PostFactory.create_batch(3, created_at=other_date)

        response = self.get(url_for('posts.show', post=post))

        self.assert200(response)
        self.assertEqual(self.get_context_variable('previous_post'),
                         previous_post)
        self.assertEqual(self.get_context_variable('next_post'), next_post)
Exemplo n.º 10
0
    def test_posts_within_sitemap(self, sitemap):
        '''It should return a post list from the sitemap.'''
        posts = PostFactory.create_batch(3)

        sitemap.fetch()

        for post in posts:
            url = sitemap.get_by_url('posts.show_redirect', post=post)
            assert url is not None
            sitemap.assert_url(url, 0.6, 'weekly')
Exemplo n.º 11
0
    def test_posts_within_sitemap(self):
        '''It should return a post list from the sitemap.'''
        posts = PostFactory.create_batch(3)

        self.get_sitemap_tree()

        for post in posts:
            url = self.get_by_url('posts.show_redirect', post=post)
            self.assertIsNotNone(url)
            self.assert_url(url, 0.6, 'weekly')
Exemplo n.º 12
0
    def test_posts_within_sitemap(self, sitemap):
        '''It should return a post list from the sitemap.'''
        posts = PostFactory.create_batch(3)

        sitemap.fetch()

        for post in posts:
            url = sitemap.get_by_url('posts.show_redirect', post=post)
            assert url is not None
            sitemap.assert_url(url, 0.6, 'weekly')