test_tag.py 739 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import os
  2. import shutil
  3. from tinydb import Query
  4. from blogit2 import find_new_posts, DB, Entry, Tag
  5. from blogit2 import CONFIG, new_build
  6. from conf import db
  7. post_dummy = """title: Blog post {}
  8. author: Famous author
  9. published: 2015-01-1{}
  10. tags: [python, git, bash, linux]
  11. public: yes
  12. chronological: yes
  13. kind: writing
  14. summary: |
  15. This is a summry of post {}
  16. ...
  17. This is the body of post {}
  18. """
  19. def create_posts():
  20. os.mkdir('content')
  21. os.chdir('content')
  22. for p in range(1,4):
  23. with open('post'+str(p)+'.md', 'a') as f:
  24. f.write(post_dummy.format(p,p,p))
  25. os.chdir('..')
  26. def test_tag():
  27. new = list(find_new_posts(DB['posts']))
  28. t = Tag('python')
  29. t.posts = [1,2,3]
  30. t.render()