test_tag.py 715 B

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