def test_user_dict(runner: CliRunner): default_dict = {'default_key': 'default_value'} # normal operation with runner.isolation('key1\nvalue1'): result = read_user_dict('prompt', default=default_dict) assert result == {'key1': 'value1'} # read default with runner.isolation('\n'): result = read_user_dict('prompt', default=default_dict) assert result == default_dict # reject keywords with runner.isolation('is\nnotis\n1\n'): result = read_user_dict('prompt', default=default_dict) assert result == {'notis': 1} # replace values with runner.isolation('key\n1\nkey\n2'): result = read_user_dict('prompt', default=default_dict) assert result == {'key': 2}
def test_workflows_sorting(): """Test workflows sorting.""" response = [{ "status": "running", "created": "2018-06-13T09:47:35.66097", "user": "******", "name": "mytest.1", "id": "256b25f4-4cfb-4684-b7a8-73872ef455a1", }, { "status": "running", "created": "2018-06-13T09:55:35.66097", "user": "******", "name": "mytest.2", "id": "256b25f4-4cfb-4684-b7a8-73872ef455a2", }] status_code = 200 mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response env = {'REANA_SERVER_URL': 'localhost', 'REANA_WORKON': 'mytest.1'} reana_token = '000000' runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client('reana-server')(mock_response, mock_http_response)): result = runner.invoke( cli, ['list', '-t', reana_token, '--sort', 'run_number']) message = ( 'mytest 2 2018-06-13T09:55:35.66097 running\n' 'mytest 1 2018-06-13T09:47:35.66097 running') assert result.exit_code == 0 assert message in result.output
def test_open_interactive_session(interactive_session_type): """Test opening an interactive session.""" status_code = 200 workflow_id = "d9304bdf-0d19-45d9-ae87-d5fd18059193" response = {"path": "/{}".format(workflow_id)} reana_server_url = "http://localhost" env = {"REANA_SERVER_URL": reana_server_url} mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response reana_token = "000000" runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client("reana-server")(mock_response, mock_http_response), ): expected_message = "{reana_server_url}/{workflow_id}".format( reana_server_url=reana_server_url, workflow_id=workflow_id) result = runner.invoke( cli, [ "open", "-t", reana_token, "-w", workflow_id, interactive_session_type, ], ) assert expected_message in result.output
def test_workflow_create_successful(create_yaml_workflow_schema): """Test workflow create when creation is successfull.""" status_code = 201 response = { "message": "The workflow has been successfully created.", "workflow_id": "cdcf48b1-c2f3-4693-8230-b066e088c6ac", "workflow_name": "mytest.1", } env = {"REANA_SERVER_URL": "localhost"} reana_token = "000000" mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client("reana-server")(mock_response, mock_http_response), ): with runner.isolated_filesystem(): with open("reana.yaml", "w") as f: f.write(create_yaml_workflow_schema) result = runner.invoke( cli, ["create", "-t", reana_token, "--skip-validation"]) assert result.exit_code == 0 assert response["workflow_name"] in result.output
def test_workflows_valid_json(): """Test workflows command with --json and -v flags.""" response = { "items": [{ "status": "running", "created": "2018-06-13T09:47:35.66097", "user": "******", "name": "mytest.1", "id": "256b25f4-4cfb-4684-b7a8-73872ef455a1", "size": { "raw": 0, "human_readable": "0 Bytes" }, }] } status_code = 200 mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response env = {"REANA_SERVER_URL": "localhost"} reana_token = "000000" runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client("reana-server")(mock_response, mock_http_response), ): result = runner.invoke(cli, ["list", "-v", "-t", reana_token, "--json"]) assert result.exit_code == 0
def test_workflows_sessions(): """Test list command for getting interactive sessions.""" response = [{ 'created': '2019-03-19T14:37:58', 'id': '29136cd0-b259-4d48-8c1e-afe3572df408', 'name': 'workflow.1', 'session_type': 'jupyter', 'session_uri': '/29136cd0-b259-4d48-8c1e-afe3572df408', 'size': '0', 'status': 'created', 'user': '******' }] status_code = 200 mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response env = {'REANA_SERVER_URL': 'localhost', 'REANA_WORKON': 'mytest.1'} reana_token = '000000' runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client('reana-server')(mock_response, mock_http_response)): result = runner.invoke(cli, ['list', '-at', reana_token, '--sessions']) message = 'RUN_NUMBER' assert result.exit_code == 0 assert message in result.output
def test_workflow_input_parameters(): """Test if not existing input parameters from CLI are applied.""" status_code = 200 response = { 'id': 'd9304bdf-0d19-45d9-ae87-d5fd18059193', 'name': 'workflow.19', 'type': 'serial', 'parameters': { 'helloworld': 'code/helloworld.py', 'inputfile': 'data/names.txt', 'outputfile': 'results/greetings.txt', 'sleeptime': 2 } } env = {'REANA_SERVER_URL': 'localhost'} mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response reana_token = '000000' runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client('reana-server')(mock_response, mock_http_response)): parameter = "Debug" expected_message = '{0}, is not in reana.yaml'.format(parameter) result = runner.invoke(cli, [ 'start', '-at', reana_token, '-w workflow.19', '-p {0}=True'.format(parameter) ]) assert expected_message in result.output
def test_secrets_add(secret): """Test secrets add.""" status_code = 201 reana_token = '000000' secret_file = 'file.txt' response = [secret_file] env = {'REANA_SERVER_URL': 'localhost'} message = 'were successfully uploaded.' mock_http_response = Mock() mock_http_response.status_code = status_code mock_http_response.raw_bytes = str(response).encode() mock_response = response runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client('reana-server')(mock_response, mock_http_response)): with runner.isolated_filesystem(): with open(secret_file, 'w') as f: f.write('test') result = runner.invoke(cli, [ 'secrets-add', '-t', reana_token, '--file', secret_file, '--env', secret ]) assert result.exit_code == 0 assert message in result.output
def test_delete_non_existing_file(): """Test delete non existing file.""" status_code = 200 reana_token = '000000' filename = 'file11' response = {'deleted': {}, 'failed': {}} message = '{} did not match any existing file.'.format(filename) mock_http_response = Mock() mock_http_response.status_code = status_code mock_http_response.raw_bytes = str(response).encode() mock_response = response env = {'REANA_SERVER_URL': 'localhost'} runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client('reana-server')(mock_response, mock_http_response)): with runner.isolated_filesystem(): result = runner.invoke(cli, [ 'rm', '-at', reana_token, '--workflow', 'mytest.1', filename ]) assert result.exit_code == 0 assert message in result.output
def test_ping_ok(): """Test ping server is set and reachable.""" reana_token = "000000" env = {"REANA_SERVER_URL": "localhost"} status_code = 200 response = { "email": "*****@*****.**", "reana_token": "000000", "full_name": "John Doe", "username": "******", } mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client("reana-server")(mock_response, mock_http_response), ): result = runner.invoke(cli, ["ping", "-t", reana_token]) message = "Authenticated as: John Doe <*****@*****.**>" assert message in result.output message = "Connected" assert message in result.output
def test_list_files_url(): """Test list workflow workspace files' urls.""" status_code = 200 response = [ { "last-modified": "string", "name": "string", "size": 0 } ] env = {'REANA_SERVER_URL': 'localhost'} mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response workflow_name = 'mytest' reana_token = '000000' runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client('reana-server')(mock_response, mock_http_response)): result = runner.invoke( cli, ['ls', '-t', reana_token, '--workflow', workflow_name, '--url']) assert result.exit_code == 0 assert workflow_name in result.output assert response[0]['name'] in result.output
def test_list_files_ok(): """Test list workflow workspace files successfull.""" status_code = 200 response = [ { "last-modified": "string", "name": "string", "size": 0 } ] env = {'REANA_SERVER_URL': 'localhost'} mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response reana_token = '000000' runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client('reana-server')(mock_response, mock_http_response)): result = runner.invoke( cli, ['ls', '-t', reana_token, '--workflow', 'mytest.1', '--json']) json_response = json.loads(result.output) assert result.exit_code == 0 assert isinstance(json_response, list) assert len(json_response) == 1 assert json_response[0]['name'] in response[0]['name']
def test_delete_file(): """Test delete file.""" status_code = 200 reana_token = '000000' filename1 = 'file1' filename2 = 'problematic_file' filename2_error_message = '{} could not be deleted.'.format(filename2) response = {'deleted': {filename1: {'size': 19}}, 'failed': {filename2: {'error': filename2_error_message}}} message1 = 'file1 was successfully deleted' mock_http_response = Mock() mock_http_response.status_code = status_code mock_http_response.raw_bytes = str(response).encode() mock_response = response env = {'REANA_SERVER_URL': 'localhost'} runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client('reana-server')(mock_response, mock_http_response)): with runner.isolated_filesystem(): result = runner.invoke( cli, ['rm', '-t', reana_token, '--workflow', 'mytest.1', filename1] ) assert result.exit_code == 0 assert message1 in result.output assert filename2_error_message in result.output
def test_secrets_list_ok(): """Test list secrets successfull.""" status_code = 200 response = [ { "name": "password", "type": "env" } ] env = {'REANA_SERVER_URL': 'localhost'} mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response reana_token = '000000' runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client('reana-server')(mock_response, mock_http_response)): result = runner.invoke( cli, ['secrets-list', '-t', reana_token]) assert result.exit_code == 0 assert "password" in result.output assert "env" in result.output
def test_secrets_add_already_exist(): """Test adding secrets when they already exist.""" status_code = 409 reana_token = '000000' env = {'REANA_SERVER_URL': 'localhost'} message = 'One of the secrets already exists. No secrets were added.' mock_http_response = Mock( status_code=status_code, reason='Conflict', json=Mock(return_value={'message': 'Conflict'})) rs_api_client_mock = Mock() rs_api_client_mock.api.add_secrets = Mock( side_effect=HTTPError(mock_http_response)) runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", rs_api_client_mock): result = runner.invoke( cli, ['secrets-add', '-t', reana_token, '--from-literal', 'USER=reanauser'] ) assert message in result.output assert result.exit_code == 1
def test_list_files_ok(): """Test list workflow workspace files successfull.""" status_code = 200 response = { "items": [{ "last-modified": "string", "name": "string", "size": { "raw": 0, "human_readable": "0 Bytes" }, }] } env = {"REANA_SERVER_URL": "localhost"} mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response reana_token = "000000" runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client("reana-server")(mock_response, mock_http_response), ): result = runner.invoke( cli, ["ls", "-t", reana_token, "--workflow", "mytest.1", "--json"]) json_response = json.loads(result.output) assert result.exit_code == 0 assert isinstance(json_response, list) assert len(json_response) == 1 assert json_response[0]["name"] in response["items"][0]["name"]
def test_list_files_url(): """Test list workflow workspace files' urls.""" status_code = 200 response = { "items": [{ "last-modified": "string", "name": "string", "size": { "raw": 0, "human_readable": "0 Bytes" }, }] } env = {"REANA_SERVER_URL": "localhost"} mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response workflow_name = "mytest" reana_token = "000000" runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client("reana-server")(mock_response, mock_http_response), ): result = runner.invoke(cli, [ "ls", "-t", reana_token, "--workflow", workflow_name, "--url" ]) assert result.exit_code == 0 assert workflow_name in result.output assert response["items"][0]["name"] in result.output
def test_upload_file(create_yaml_workflow_schema): """Test upload file.""" status_code = 200 reana_token = '000000' file = 'file.txt' response = [file] env = {'REANA_SERVER_URL': 'localhost'} message = 'was successfully uploaded.' mock_http_response = Mock() mock_http_response.status_code = status_code mock_http_response.raw_bytes = str(response).encode() mock_response = response runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client('reana-server')(mock_response, mock_http_response)): with runner.isolated_filesystem(): with open(file, 'w') as f: f.write('test') with open('reana.yaml', 'w') as reana_schema: reana_schema.write(create_yaml_workflow_schema) result = runner.invoke(cli, [ 'upload', '-at', reana_token, '--workflow', 'mytest.1', file ]) assert result.exit_code == 0 assert message in result.output
def test_workflows_valid_json(): """Test workflows command with --json and -v flags.""" response = [{ "status": "running", "created": "2018-06-13T09:47:35.66097", "user": "******", "name": "mytest.1", "id": "256b25f4-4cfb-4684-b7a8-73872ef455a1", "size": "0K" }] status_code = 200 mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response env = {'REANA_SERVER_URL': 'localhost'} reana_token = '000000' runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client('reana-server')(mock_response, mock_http_response)): result = runner.invoke( cli, ['list', '-v', '-at', reana_token, '--json']) json_response = json.loads(result.output) assert result.exit_code == 0 assert isinstance(json_response, list) assert len(json_response) == 1 assert 'name' in json_response[0] assert 'run_number' in json_response[0] assert 'created' in json_response[0] assert 'status' in json_response[0] assert 'id' in json_response[0] assert 'user' in json_response[0]
def test_move_file_running_workflow(): """Test move files when workflow is running.""" status_code = 200 reana_token = '000000' src_file = 'file11' target = 'file2' response = {"status": "running", "logs": "", "name": "mytest.1"} message = 'File(s) could not be moved for running workflow' mock_http_response = Mock() mock_http_response.status_code = status_code mock_http_response.raw_bytes = str(response).encode() mock_response = response env = {'REANA_SERVER_URL': 'localhost'} runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client('reana-server')(mock_response, mock_http_response)): result = runner.invoke(cli, [ 'mv', '-t', reana_token, '--workflow', 'mytest.1', src_file, target ]) assert result.exit_code == 1 assert message in result.output
def test_workflows_server_ok(): """Test workflows command when server is reachable.""" response = [{ "status": "running", "created": "2018-06-13T09:47:35.66097", "user": "******", "name": "mytest.1", "id": "256b25f4-4cfb-4684-b7a8-73872ef455a1", }] status_code = 200 mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response env = {'REANA_SERVER_URL': 'localhost', 'REANA_WORKON': 'mytest.1'} reana_token = '000000' runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client('reana-server')(mock_response, mock_http_response)): result = runner.invoke(cli, ['list', '-at', reana_token]) message = 'RUN_NUMBER' assert result.exit_code == 0 assert message in result.output
def test_download_file(): """Test file downloading.""" status_code = 200 response = 'Content of file to download' env = {'REANA_SERVER_URL': 'localhost'} mock_http_response = Mock() mock_http_response.status_code = status_code mock_http_response.raw_bytes = str(response).encode() mock_response = response reana_token = '000000' response_md5 = hashlib.md5(mock_response.encode('utf-8')).hexdigest() file = 'dummy_file.txt' message = 'File {0} downloaded to'.format(file) runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client('reana-server')(mock_response, mock_http_response)): result = runner.invoke(cli, [ 'download', '-t', reana_token, '--workflow', 'mytest.1', file ]) assert result.exit_code == 0 assert os.path.isfile(file) is True file_md5 = hashlib.md5(open(file, 'rb').read()).hexdigest() assert file_md5 == response_md5 assert message in result.output os.remove(file)
def test_workflows_sessions(): """Test list command for getting interactive sessions.""" response = { "items": [{ "created": "2019-03-19T14:37:58", "id": "29136cd0-b259-4d48-8c1e-afe3572df408", "name": "workflow.1", "session_type": "jupyter", "session_uri": "/29136cd0-b259-4d48-8c1e-afe3572df408", "size": { "raw": 0, "human_readable": "0 Bytes" }, "status": "created", "user": "******", }] } status_code = 200 mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response env = {"REANA_SERVER_URL": "localhost", "REANA_WORKON": "mytest.1"} reana_token = "000000" runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client("reana-server")(mock_response, mock_http_response), ): result = runner.invoke(cli, ["list", "-t", reana_token, "--sessions"]) message = "RUN_NUMBER" assert result.exit_code == 0 assert message in result.output
def test_download_file(): """Test file downloading.""" status_code = 200 response = "Content of file to download" env = {"REANA_SERVER_URL": "localhost"} file = "dummy_file.txt" mock_http_response = Mock() mock_http_response.status_code = status_code mock_http_response.content = str(response).encode() mock_http_response.headers = { "Content-Disposition": "attachment; filename={}".format(file) } mock_requests = Mock() mock_requests.get = Mock(return_value=mock_http_response) reana_token = "000000" response_md5 = hashlib.md5(response.encode("utf-8")).hexdigest() message = "File {0} downloaded to".format(file) runner = CliRunner(env=env) with runner.isolation(): with patch("reana_client.api.client.requests", mock_requests): result = runner.invoke(cli, [ "download", "-t", reana_token, "--workflow", "mytest.1", file ]) assert result.exit_code == 0 assert os.path.isfile(file) is True file_md5 = hashlib.md5(open(file, "rb").read()).hexdigest() assert file_md5 == response_md5 assert message in result.output os.remove(file)
def test_workflows_without_include_workspace_size(): """Test workflows command without --include-workspace-size flag.""" response = { "items": [{ "status": "running", "created": "2018-06-13T09:47:35.66097", "user": "******", "name": "mytest.1", "id": "256b25f4-4cfb-4684-b7a8-73872ef455a1", "size": { "human_readable": "", "raw": -1 }, }] } status_code = 200 mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response env = {"REANA_SERVER_URL": "localhost"} reana_token = "000000" runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client("reana-server")(mock_response, mock_http_response), ): result = runner.invoke(cli, ["list", "-t", reana_token]) assert result.exit_code == 0 assert "SIZE" not in result.output
def test_delete_non_existing_file(): """Test delete non existing file.""" status_code = 200 reana_token = "000000" filename = "file11" response = {"deleted": {}, "failed": {}} message = "{} did not match any existing file.".format(filename) mock_http_response = Mock() mock_http_response.status_code = status_code mock_http_response.raw_bytes = str(response).encode() mock_response = response env = {"REANA_SERVER_URL": "localhost"} runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client("reana-server")(mock_response, mock_http_response), ): with runner.isolated_filesystem(): result = runner.invoke(cli, [ "rm", "-t", reana_token, "--workflow", "mytest.1", filename ]) assert result.exit_code == 0 assert message in result.output
def test_workflow_start_successful(status): """Test workflow start when creation is successfull.""" workflow_name = "mytest.1" response = { "status": status, "message": "Server message", "id": "256b25f4-4cfb-4684-b7a8-73872ef455a1", "workflow_name": workflow_name, "user": "******", } status_code = 200 reana_token = "000000" expected_message = get_workflow_status_change_msg(workflow_name, status) mock_http_response = Mock() mock_http_response.status_code = status_code mock_response = response env = {"REANA_SERVER_URL": "localhost"} runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client("reana-server")(mock_response, mock_http_response), ): result = runner.invoke( cli, ["start", "-t", reana_token, "-w", response["workflow_name"]]) assert result.exit_code == 0 assert expected_message in result.output
def test_move_file_running_workflow(): """Test move files when workflow is running.""" status_code = 200 reana_token = "000000" src_file = "file11" target = "file2" response = {"status": "running", "logs": "", "name": "mytest.1"} message = "File(s) could not be moved for running workflow" mock_http_response = Mock() mock_http_response.status_code = status_code mock_http_response.raw_bytes = str(response).encode() mock_response = response env = {"REANA_SERVER_URL": "localhost"} runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client("reana-server")(mock_response, mock_http_response), ): result = runner.invoke( cli, [ "mv", "-t", reana_token, "--workflow", "mytest.1", src_file, target ], ) assert result.exit_code == 1 assert message in result.output
def test_secrets_add(secret): """Test secrets add.""" status_code = 201 reana_token = "000000" secret_file = "file.txt" response = [secret_file] env = {"REANA_SERVER_URL": "localhost"} message = "were successfully uploaded." mock_http_response = Mock() mock_http_response.status_code = status_code mock_http_response.raw_bytes = str(response).encode() mock_response = response runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client("reana-server")(mock_response, mock_http_response), ): with runner.isolated_filesystem(): with open(secret_file, "w") as f: f.write("test") result = runner.invoke( cli, [ "secrets-add", "-t", reana_token, "--file", secret_file, "--env", secret, ], ) assert result.exit_code == 0 assert message in result.output
def test_list_disk_usage_with_invalid_filter(): """Test list disk usage info with invalid filter.""" status_code = 200 response = { "disk_usage_info": [], "user": "******", "workflow_id": "7767678-766787", "workflow_name": "workflow", } env = {"REANA_SERVER_URL": "localhost"} mock_http_response, mock_response = Mock(), Mock() mock_http_response.status_code = status_code mock_response = response reana_token = "000000" runner = CliRunner(env=env) with runner.isolation(): with patch( "reana_client.api.client.current_rs_api_client", make_mock_api_client("reana-server")(mock_response, mock_http_response), ): result = runner.invoke( cli, [ "du", "-t", reana_token, "--workflow", "workflow.1", "--filter", "name=not_valid", ], ) assert result.exit_code == 1 assert "No files matching filter criteria." in result.output
def get_runner(): runner = CliRunner() runner.isolation(env={}) return runner