Exemple #1
0
def test_render_archive():

    entries = [Entry.entry_from_db(
        os.path.join(CONFIG['content_root'], e.get('filename')), e.doc_id) for e in
        DB.posts.all()]

    render_archive(entries[ARCHIVE_SIZE:])
    # pages should not be in the archive
    with open(os.path.join(CONFIG['output_to'], 'archive', 'index.html')) as html_index:
        soup = BeautifulSoup(html_index.read(), 'html.parser')
        assert len(soup.find_all(class_='post')) == 12
Exemple #2
0
def test_tag_render():
    p = DB.posts.get(doc_id=1)
    entry = Entry.entry_from_db(
        os.path.join(CONFIG['content_root'], p.get('filename')), 1)

    tags = entry.tags

    assert list(map(str, tags)) == ['buf', 'foo', 'bar', 'baz']
    # the entries are wrongly sorted, need to look at that
    assert tags[0].render()
    assert len(list(tags[0].entries))

    assert len(DB.posts.all()) == 22
Exemple #3
0
def test_tag_render():
    p = DB.posts.get(doc_id=1)
    entry = Entry.entry_from_db(
        os.path.join(CONFIG['content_root'], p.get('filename')), 1)

    tags = entry.tags

    assert list(map(str, tags)) == ['buf', 'foo', 'bar', 'baz']
    # the entries are wrongly sorted, need to look at that
    assert tags[0].render()
    assert len(list(tags[0].entries))

    assert len(DB.posts.all()) == 22
Exemple #4
0
def test_render_archive():

    entries = [
        Entry.entry_from_db(
            os.path.join(CONFIG['content_root'], e.get('filename')), e.doc_id)
        for e in DB.posts.all()
    ]

    render_archive(entries[ARCHIVE_SIZE:])
    # pages should not be in the archive
    with open(os.path.join(CONFIG['output_to'], 'archive',
                           'index.html')) as html_index:
        soup = BeautifulSoup(html_index.read(), 'html.parser')
        assert len(soup.find_all(class_='post')) == 12
Exemple #5
0
def test_tags():
    entries = [
        Entry.entry_from_db(os.path.join(CONFIG['content_root'],
                                         e.get('filename')), e.doc_id)
        for e in DB.posts.all()]
    tags = DB.tags.all()  # noqa

    t = entries[0].tags

    assert len(t) == 4
    assert t[0].name == 'buf'

    new_tag = Tag('buggg')
    new_tag.posts = [100, 100]
    with pytest.raises(ValueError):
        new_tag.posts = "This should not work"
    with pytest.raises(ValueError):
        new_tag.posts = 1  # This should not either

    new_tag.posts = [100]
    with pytest.raises(ValueError):
        list(new_tag.entries)
Exemple #6
0
def test_tags():
    entries = [
        Entry.entry_from_db(
            os.path.join(CONFIG['content_root'], e.get('filename')), e.doc_id)
        for e in DB.posts.all()
    ]
    tags = DB.tags.all()  # noqa

    t = entries[0].tags

    assert len(t) == 4
    assert t[0].name == 'buf'

    new_tag = Tag('buggg')
    new_tag.posts = [100, 100]
    with pytest.raises(ValueError):
        new_tag.posts = "This should not work"
    with pytest.raises(ValueError):
        new_tag.posts = 1  # This should not either

    new_tag.posts = [100]
    with pytest.raises(ValueError):
        list(new_tag.entries)