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)
Exemple #2
0
 def test_11(self, m="Validated Post should be able to save"):
     p = Post({"title": "This is the test", "contents":"This is the content", "tags":"music,guitar,test", "author":"*****@*****.**"})
     p.validate()
     p.is_valid() |should| equal_to(True)
     len(p.errors()) |should| equal_to(0)
     p.save() |should_not| throw(ModelNotValid)
Exemple #3
0
 def test_01(self, m="Post should not validate without title, contents, tags and author"):
     p = Post({"title": "", "contents":"", "tags":"", "author":""})
     p.validate()
     p.is_valid() |should| equal_to(False)
     len(p.errors()) |should| equal_to(4)
Exemple #4
0
 def test_06(self, m="Post should validate"):
     p = Post({"title": "This is the test", "contents":"This is the content", "tags":"music,guitar,test", "author":"*****@*****.**"})
     p.validate()
     p.is_valid() |should| equal_to(True)
     len(p.errors()) |should| equal_to(0)
Exemple #5
0
 def test_05(self, m="Post should not validate without author email"):
     p = Post({"title": "This is the test", "contents":"This is the content", "tags":"music,guitar,test", "author":"yanekk"})
     p.validate()
     p.is_valid() |should| equal_to(False)
     len(p.errors()) |should| equal_to(1)