def test_tag_post_ids(): m = """\ --- title: Blog post {} author: Famous author published: 2015-01-{} tags: tag1, tag2 public: yes chronological: yes kind: writing summary: This is a summary --- """ assert len(DB.posts.all()) == 20 with open(os.path.join(CONFIG['content_root'], 'e.md'), 'w') as f: f.write(m.format(25, 25)) with open(os.path.join(CONFIG['content_root'], 'f.md'), 'w') as f: f.write(m.format(27, 27)) e1 = Entry(os.path.join(CONFIG['content_root'], 'e.md')) e1.tags e2 = Entry(os.path.join(CONFIG['content_root'], 'f.md')) e2.tags assert len(DB.posts.all()) == 22 #assert e1.tags[0].posts == e2.tags[0].posts e1.render() [t.render() for t in e1.tags] assert len(DB.posts.all()) == 22
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
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
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
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)
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)