示例#1
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
示例#4
0
    def test_get_one_wrong_params(self):
        usecase = CommentUsecases(CommentDBRepo())

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

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