예제 #1
0
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
예제 #2
0
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
예제 #3
0
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')) == []
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
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)
예제 #7
0
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') == []
예제 #8
0
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)
예제 #9
0
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)
예제 #10
0
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)
예제 #11
0
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'