Exemplo n.º 1
0
    def test_find_post_with_invalid_categories(self):

        try:
            Post.find_post_by_keyword("")
            self.fail("Expect InvalidFieldError")
        except InvalidFieldError:
            pass
Exemplo n.º 2
0
 def test_find_post_with_valid_info(self):
     posts = Post.find_post_by_keyword("orem", 1, 3)
     self.assertEqual(len(posts), 3)
Exemplo n.º 3
0
 def test_find_post_with_invalid_pagination_param(self):
     posts = Post.find_post_by_keyword("Lorem", 0, -2)
     self.assertEqual(len(posts), 10)
Exemplo n.º 4
0
 def test_find_post_with_out_of_range_index(self):
     posts = Post.find_post_by_keyword("Lorem", 4, 7)
     self.assertEqual(len(posts), 0)
Exemplo n.º 5
0
 def test_find_post_with_sql_injection(self):
     try:
         posts = Post.find_post_by_keyword("Lorem';select * from user;--", 1, 3)
         self.fail("Expect InvalidFieldError")
     except:
         pass