def test_run_pylint_with_errors(self, mocker, linter_obj: Linter, exp_container_exit_code: int, exp_container_log: str,
                                    exp_exit_code: int, exp_output: str):
        # Docker client mocking
        mocker.patch.object(linter_obj, '_docker_client')
        linter_obj._docker_client.containers.run().wait.return_value = {"StatusCode": exp_container_exit_code}
        linter_obj._docker_client.containers.run().logs.return_value = exp_container_log.encode('utf-8')
        act_exit_code, act_output = linter_obj._docker_run_pylint(test_image='test-image',
                                                                  keep_container=False)

        assert act_exit_code == exp_exit_code
        assert act_output == exp_output
    def test_run_pylint_no_errors(self, mocker, linter_obj: Linter):
        # Expected values
        exp_container_exit_code = 0
        exp_container_log = ""

        # Docker client mocking
        mocker.patch.object(linter_obj, '_docker_client')
        linter_obj._docker_client.containers.run().wait.return_value = {"StatusCode": exp_container_exit_code}
        linter_obj._docker_client.containers.run().logs.return_value = exp_container_log.encode('utf-8')
        act_container_exit_code, act_container_log = linter_obj._docker_run_pylint(test_image='test-image',
                                                                                   keep_container=False)

        assert exp_container_exit_code == act_container_exit_code
        assert exp_container_log == act_container_log
Exemple #3
0
    def test_run_pylint_with_errors(self, mocker, linter_obj: Linter,
                                    exp_container_exit_code: int,
                                    exp_container_log: str, exp_exit_code: int,
                                    exp_output: str):
        # Docker client mocking
        mocker.patch(
            'demisto_sdk.commands.lint.docker_helper.Docker.create_container')
        linter.Docker.create_container().wait.return_value = {
            "StatusCode": exp_container_exit_code
        }
        linter.Docker.create_container(
        ).logs.return_value = exp_container_log.encode('utf-8')
        act_exit_code, act_output = linter_obj._docker_run_pylint(
            test_image='test-image', keep_container=False)

        assert act_exit_code == exp_exit_code
        assert act_output == exp_output