Commits

dan mackinlay committed dc6c5e8

test for date_path flag to past creation

  • Participants
  • Parent commits 47f9a07

Comments (0)

Files changed (1)

File tinkertest/test_post.py

 import tinkerer
 from tinkertest import utils
 
-
 # test creating new post
 class TestPost(utils.BaseTinkererTest):
     # test create call
-    def test_create(self):
+    def test_create_with_date_path(self):
         # create post with current date
         new_post = post.create("My Post")
 
         self.assertTrue(os.path.exists(new_post.path))
         self.assertEquals("2010/10/01/date_post", new_post.docname)
 
+    def test_create_without_date_path(self):
+        # create post with current date, with no date path components
+        new_post = post.create("My Note", date_path=False)
+
+        year, month, day = tinkerer.utils.split_date()
+        self.assertEquals(year, new_post.year)
+        self.assertEquals(month, new_post.month)
+        self.assertEquals(day, new_post.day)
+
+        self.assertEquals(
+                os.path.abspath(os.path.join(
+                                    utils.TEST_ROOT, 
+                                    year, 
+                                    month, 
+                                    day, 
+                                    "my_note.rst")),
+                new_post.path)                                        
+
+        self.assertTrue(os.path.exists(new_post.path))
+        
+        # create post with given date
+        new_post = post.create("Dated Note", datetime.date(2010, 10, 1), date_path=False)
+        self.assertEquals("2010", new_post.year)
+        self.assertEquals("10", new_post.month)
+        self.assertEquals("01", new_post.day)
+
+        self.assertEquals(
+                os.path.abspath(os.path.join(
+                                    utils.TEST_ROOT,
+                                    "dated_note.rst")),
+                new_post.path)
+
+        self.assertTrue(os.path.exists(new_post.path))
+        self.assertEquals("dated_note", new_post.docname)
+
 
     # test moving existing file to post
     def test_move(self):