示例#1
0
    def test_get_success(self, simple_comment):
        # arrange
        expected_comment = CommentDBRepo.decode_orm_comment(simple_comment)
        test_id = simple_comment.id

        # act
        result_comment = CommentDBRepo.get(comment_id=test_id)

        # assert
        assert result_comment.text == expected_comment.text
示例#2
0
    def test_get_all_success(self, comments_20):
        # arrange
        expected_comments = []
        for g in comments_20:
            expected_comments.append(CommentDBRepo.decode_orm_comment(g))

        # act
        result_comments = CommentDBRepo.get_all(expected_comments[0].film)

        # assert
        for i in range(10):
            assert result_comments[i].text == expected_comments[i].text
示例#3
0
    def test_get_all_no_results(self):
        # arrange
        expected_comments = []

        # act
        result_comments = CommentDBRepo.get_all(1)

        # accert
        assert result_comments == expected_comments
示例#4
0
    def test_get_fail_not_normal(self):
        # arrange
        test_id = -100

        # act
        result_comment = CommentDBRepo.get(comment_id=-test_id)

        # assert
        assert result_comment is None
示例#5
0
    def test_get_fail_not_found(self):
        # arrange
        test_id = 1

        # act
        result_comment = CommentDBRepo.get(comment_id=test_id)

        # assert
        assert result_comment is None
示例#6
0
    def test_get_one_success(self, simple_comment):
        # arrange
        usecase = CommentUsecases(CommentDBRepo())
        test_id = simple_comment.id
        expected_comment = simple_comment

        # act
        result_comments = usecase.get_comment(test_id)

        # assert
        assert result_comments.text == expected_comment.text
    def test_get_one_success_london(self, mocker):
        # arrange
        usecase = CommentUsecases(CommentDBRepo())
        test_id = 1
        expected_comment = CommentMother.one().build()
        mocker.patch('modules.DBRepo.CommentDBRepo.CommentDBRepo.get', return_value=expected_comment)

        # act
        result_comments = usecase.get_comment(test_id)

        # assert
        assert result_comments.text == expected_comment.text
    def test_get_success(self, mocker):
        # arrange
        expected_comments = [CommentMother.one().build(), CommentMother.two().build()]
        mocker.patch('modules.DBRepo.CommentDBRepo.CommentDBRepo.get_all', return_value=expected_comments)
        usecase = CommentUsecases(CommentDBRepo())
        film_id = 1

        # act
        result_comments = usecase.get_all_comments(film_id, 0, len(expected_comments))

        # assert
        for i in range(len(expected_comments)):
            assert result_comments[i].text == expected_comments[i].text
示例#9
0
    def test_get_one_wrong_params(self):
        usecase = CommentUsecases(CommentDBRepo())

        result_comments = usecase.get_comment(-100)
        assert result_comments is None
示例#10
0
    def test_get_one_no_result(self):
        usecase = CommentUsecases(CommentDBRepo())

        result_comments = usecase.get_comment(1)
        assert result_comments is None
示例#11
0
 def get_comment_usecase() -> CommentUsecases:
     return CommentUsecases(CommentDBRepo())