Browse Source

add tests and fixture

Oz N Tiram 9 years ago
parent
commit
8537b58b84
4 changed files with 30 additions and 4 deletions
  1. 12 0
      tests/page.md
  2. 13 0
      tests/test_blogit.py
  3. 0 3
      tests/test_post.py
  4. 5 1
      tests/test_tag.py

+ 12 - 0
tests/page.md

@@ -0,0 +1,12 @@
+title: about
+public: yes
+kind: page
+
+
+# some heading
+
+bla bla
+
+## heading 2
+
+blue blue blue

+ 13 - 0
tests/test_blogit.py

@@ -3,6 +3,7 @@ import shutil
 from tinydb import Query
 from blogit.blogit import find_new_items, DataBase, Entry, Tag
 from blogit.blogit import CONFIG, new_build
+from blogit.blogit import find_new_posts_and_pages
 
 
 post_dummy = """title: Blog post{}
@@ -86,6 +87,18 @@ def test_new_build():
     create_posts()
     new_build()
 
+
+def test_find_posts_and_pages():
+    import shutil
+    shutil.copy('tests/page.md', 'content/page.md')
+    DB = DataBase(os.path.join(CONFIG['content_root'], 'blogit2.db'))
+    DB._db.purge_tables()
+    pp = list(find_new_posts_and_pages(DB))
+    pp2 = list(find_new_posts_and_pages(DB))
+    assert len(pp) != len(pp2)
+    assert len(pp2) == 0
+
+
 post_dummy = """title: Blog post {}
 author: Famous author
 published: 2015-01-1{}

+ 0 - 3
tests/test_post.py

@@ -51,9 +51,6 @@ def create_posts():
     os.chdir('..')
 
 
-def test_tag():
-find_new_items
-
 import pytest
 
 def test_raises():

+ 5 - 1
tests/test_tag.py

@@ -52,7 +52,11 @@ def create_posts():
 
 
 def test_tag():
-find_new_items
+    new =  list(find_new_items(DB.posts))
+    t = Tag('python')
+    t.posts = [1,2,3]
+    t.render()
+
 
 import pytest