コード例 #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
コード例 #2
0
    def test_get_one_my_mock(self):
        # arrange
        usecase = CommentUsecases(CommentDBRepoMock())
        test_id = 1
        expected_comment = CommentMother.one().build()

        # act
        result_comments = usecase.get_comment(test_id)

        # assert
        assert result_comments.text == expected_comment.text
コード例 #3
0
    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
コード例 #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