def test_14(self, m='Deleted post should be deleted'): p = Post({"title": "Another original post", "contents":"This is the content", "tags":"music,guitar,test", "author":"*****@*****.**"}) p.validate() p.save() retrieved_post = Post.get(p.pk()) retrieved_post.delete() retrieved_post.is_deleted() |should| equal_to(True) Post.get(p.pk()) |should| equal_to(None)
def test_12(self, m="Post should be retrieved by it's pk"): p = Post({"title": "This is the second test", "contents":"This is the content", "tags":"music,guitar,test", "author":"*****@*****.**"}) p.validate() p.is_new() |should| equal_to(True) p.save() p.is_new() |should_not| equal_to(True) retrieved_post = Post.get(p.pk()) retrieved_post |should| equal_to(p) retrieved_post.is_new() |should| equal_to(False)
def add(self, **kvals): if len(kvals): post = Post(kvals) post.validate() if post.is_valid(): post.save() return self.redirect("/post/%s" % post.pk()) else: post = Post() return self.render("post/add", post=post)
def test_09(self, m="Validated Post should set it's pk to time uuid"): p = Post({"title": "What's the best answe' for 1969", "contents":"This is the content", "tags":"music,guitar,test", "author":"*****@*****.**"}) p.validate() len(p.pk()) |should| equal_to(36) p.pk() |should| be_like('^[\w\d]{8}\-[\w\d]{4}\-[\w\d]{4}\-[\w\d]{4}\-[\w\d]{12}$')