コード例 #1
0
    def test_find_post_with_invalid_author_id(self):

        try:
            Post.find_post_by_author_pagination("abc")
            self.fail("Expect InvalidFieldError")
        except InvalidFieldError:
            pass
コード例 #2
0
    def test_find_post_with_not_exist_author(self):

        try:
            Post.find_post_by_author_pagination(10, 4, 7)
            self.fail("Expect UserNotFoundError")
        except UserNotFoundError:
            pass
コード例 #3
0
ファイル: post_controller.py プロジェクト: roseviet/ice-wolf
def filter_by_user(user_id, page):
    try:
        pagination, author = Post.find_post_by_author_pagination(user_id,page)
        return render_template("search_result.html", pagination=pagination, author=author, menu_items=default.categories)
    except Exception as e:
        abort(400)
コード例 #4
0
 def test_find_post_with_valid_info(self):
     pagination, author = Post.find_post_by_author_pagination(3, 1, 3)
     self.assertEqual(len(pagination.items), 3)
コード例 #5
0
 def test_find_post_with_out_of_range_index(self):
     pagination, author = Post.find_post_by_author_pagination(3, 4, 7)
     self.assertEqual(len(pagination.items), 0)
コード例 #6
0
 def test_find_post_with_invalid_pagination_param(self):
     pagination, author = Post.find_post_by_author_pagination(3, 0, -2)
     self.assertEqual(len(pagination.items), 6)