def test_pages_filter_by_tag_based_on_debug(test_app, debug, tag, pages_count): test_app.debug = debug with test_app.test_request_context(): pages = pages_filter(lambda p: p.has_tag(tag)) assert len(pages) == pages_count,\ 'Incorrect tag count for {} with debug={}'.format(tag, debug) test_app.debug = True
def test_pages_filter_selects_posts_based_on_debug(request, test_app, debug, pages_count): test_app.debug = debug with test_app.test_request_context(): pages = pages_filter() assert len( pages ) == pages_count, 'Pages count incorrect when debug={}'.format(debug) test_app.debug = True
def test_pages_filter_by_missing_tag_returns_empty(test_app): test_app.debug = True with test_app.test_request_context(): assert pages_filter(lambda p: p.has_tag('not present')) == []
def test_pages_filter_by_missing_year(test_app, post_date): with test_app.test_request_context(): year = post_date.year + 10 assert len(pages_filter(lambda p: p.from_year(year))) == 0,\ 'Incorrect number of posts for missing year: {}'.format(year)
def test_pages_filter_by_existing_year(test_app, post_date): with test_app.test_request_context(): expected_count = 1 year = post_date.year assert len(pages_filter(lambda p: p.from_year(year))) == 2,\ 'Incorrect number of posts for existing year, {}'.format(year)
def test_pages_filter_selects_posts_based_on_debug(test_app, debug, pages_count): test_app.debug = debug with test_app.test_request_context(): pages = pages_filter() assert len(pages) == pages_count, 'Pages count incorrect when debug={}'.format(debug)
def test_pages_filter_by_missing_tag_returns_empty(test_app): test_app.debug = True with test_app.test_request_context(): assert pages_filter(tag='not present') == []
def test_pages_filter_by_tag_based_on_debug(test_app, debug, tag, pages_count): test_app.debug = debug with test_app.test_request_context(): pages = pages_filter(tag=tag) assert len(pages) == pages_count, 'Incorrect tag count for {} with debug={}'.format(tag, debug)
def test_pages_filter_by_missing_year(test_app): with test_app.test_request_context(): year = datetime.now().year + 10 assert len(pages_filter(year=year)) == 0, 'Incorrect number of posts for missing year: {}'.format(year)
def test_pages_filter_by_existing_year(test_app): with test_app.test_request_context(): year = datetime.now().year assert len(pages_filter(year=year)) == 2, 'Incorrect number of posts for existing year, {}'.format(year)
def test_get_tag_counts_based_on_debug(test_app, debug, expected_tags): test_app.debug = debug with test_app.test_request_context(): tags = get_tag_counts(pages_filter()) assert tags == expected_tags, 'Tag counts are incorrect'