def test_run_pytest(self, mocker, linter_obj: Linter, exp_container_exit_code: int, exp_exit_code: int): exp_test_json = mocker.MagicMock() if exp_container_exit_code in [ 0, 1, 2, 5 ] else {} # 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 } # Docker related mocking mocker.patch.object(linter, 'json') linter.json.loads.return_value = exp_test_json mocker.patch.object(linter, 'get_file_from_container') act_container_exit_code, act_output, act_test_json = linter_obj._docker_run_pytest( test_image='test-image', keep_container=False, test_xml="", no_coverage=True) assert exp_exit_code == act_container_exit_code assert exp_test_json == act_test_json
def test_run_pytest(self, mocker, linter_obj: Linter, exp_container_exit_code: int, exp_exit_code: int): exp_test_json = mocker.MagicMock() # Docker client mocking mocker.patch.object(linter_obj, '_docker_client') linter_obj._docker_client.containers.run().wait.return_value = {"StatusCode": exp_container_exit_code} # Docker related mocking mocker.patch.object(linter, 'json') linter.json.loads.return_value = exp_test_json mocker.patch.object(linter, 'get_file_from_container') act_container_exit_code, act_output, act_test_json = linter_obj._docker_run_pytest(test_image='test-image', keep_container=False, test_xml="") assert exp_exit_code == act_container_exit_code assert exp_test_json == act_test_json