def test_get_with_executions(self, test_client, number_of_executions):
     response = test_client.get('/executions',
                                headers={"apiKey": standard_user().api_key})
     json_response = load_json_data(response)
     executions, error = ExecutionSchema(many=True).load(json_response)
     assert not error
     assert len(executions) == number_of_executions
 def test_get_exists_action(self, test_client):
     response = test_client.get('/path/{}/empty_dir?action=exists'.format(
         standard_user().username),
                                headers={"apiKey": standard_user().api_key})
     booleanResponse = BooleanResponseSchema().load(
         load_json_data(response)).data
     assert booleanResponse.exists is True
 def test_get_with_offset_greater_than_execution_count(
         self, test_client, number_of_executions):
     offset = 1000
     response = test_client.get('/executions?offset={}'.format(offset),
                                headers={"apiKey": standard_user().api_key})
     json_response = load_json_data(response)
     assert len(json_response) == 0
 def test_get_content_action_with_invalid_dir(self, test_client):
     response = test_client.get(
         '/path/{}/dir_that_does_not_exist?action=content'.format(
             standard_user().username),
         headers={"apiKey": standard_user().api_key})
     error = error_from_response(response)
     assert error == PATH_DOES_NOT_EXIST
 def test_get_properties_action_with_dir(self, test_client, dir_object):
     response = test_client.get(
         '/path/{}/subdirectory?action=properties'.format(
             standard_user().username),
         headers={"apiKey": standard_user().api_key})
     path = PathSchema().load(load_json_data(response)).data
     assert path == dir_object
Beispiel #6
0
 def test_get_pipeline_boutiques_descriptor_by_identifier_invalid_id(
         self, test_client):
     response = test_client.get('/pipelines/{}/boutiquesdescriptor'.format(
         "INVALID_{}".format(PipelineOne.identifier)),
                                headers={"apiKey": standard_user().api_key})
     error = error_from_response(response)
     assert error == INVALID_PIPELINE_IDENTIFIER
Beispiel #7
0
 def test_get_invalid_execution(self, test_client):
     execution_id = "invalid"
     response = test_client.get('/executions/{}'.format(execution_id),
                                headers={"apiKey": standard_user().api_key})
     error = error_from_response(response)
     expected_error_code_and_message = ErrorCodeAndMessageFormatter(
         EXECUTION_NOT_FOUND, execution_id)
     assert error == expected_error_code_and_message
 def test_get_md5_action_with_file(self, test_client):
     response = test_client.get('/path/{}/file.json?action=md5'.format(
         standard_user().username),
                                headers={"apiKey": standard_user().api_key})
     md5 = PathMD5Schema().load(load_json_data(response)).data
     assert md5 == generate_md5(
         os.path.join(app.config['DATA_DIRECTORY'],
                      "{}/file.json".format(standard_user().username)))
 def test_get_exists_action_with_invalid_file(self, test_client):
     response = test_client.get(
         '/path/{}/!invalid_F1l3?action=exists'.format(
             standard_user().username),
         headers={"apiKey": standard_user().api_key})
     booleanResponse = BooleanResponseSchema().load(
         load_json_data(response)).data
     assert booleanResponse.exists is False
Beispiel #10
0
 def test_get_content_action_empty(self, test_client):
     response = test_client.get('/pipelines',
                                headers={"apiKey": standard_user().api_key})
     pipeline = PipelineSchema(many=True).load(
         load_json_data(response)).data
     assert PipelineOne in pipeline
     assert PipelineTwo in pipeline
     assert PipelineThree in pipeline
 def test_get_list_action_with_dir(self, test_client):
     response = test_client.get('/path/{}/subdirectory?action=list'.format(
         standard_user().username),
                                headers={"apiKey": standard_user().api_key})
     paths = PathSchema(many=True).load(load_json_data(response)).data
     expected_paths_list = os.listdir(
         os.path.join(app.config['DATA_DIRECTORY'],
                      '{}/subdirectory'.format(standard_user().username)))
     assert len(expected_paths_list) == len(paths)
Beispiel #12
0
 def test_get_content_action_with_property(self, test_client):
     response = test_client.get(
         '/pipelines?property={}'.format(PropNameOne),
         headers={"apiKey": standard_user().api_key})
     pipeline = PipelineSchema(many=True).load(
         load_json_data(response)).data
     assert PipelineOne in pipeline
     assert PipelineTwo not in pipeline
     assert PipelineThree in pipeline
Beispiel #13
0
 def test_get_content_action_with_study_identifier(self, test_client):
     response = test_client.get(
         '/pipelines?studyIdentifier={}'.format(NameStudyOne),
         headers={"apiKey": standard_user().api_key})
     pipeline = PipelineSchema(many=True).load(
         load_json_data(response)).data
     assert PipelineOne in pipeline
     assert PipelineTwo in pipeline
     assert PipelineThree not in pipeline
Beispiel #14
0
    def test_get_pipeline_boutiques_descriptor_by_identifier(
            self, test_client):
        response = test_client.get('/pipelines/{}/boutiquesdescriptor'.format(
            PipelineOne.identifier),
                                   headers={"apiKey": standard_user().api_key})
        pipeline = load_json_data(response)
        original_pipeline = json.loads(
            PipelineSchema().dumps(PipelineOne).data)

        assert pipeline == original_pipeline
 def test_get_execution_std_err_invalid_execution_id(
         self, test_client, execution_id, write_std_err):
     invalid_execution_id = "NOT_{}".format(execution_id)
     response = test_client.get(
         '/executions/{}/stderr'.format(invalid_execution_id),
         headers={"apiKey": standard_user().api_key})
     error = error_from_response(response)
     expected_error_code_and_message = ErrorCodeAndMessageFormatter(
         EXECUTION_NOT_FOUND, invalid_execution_id)
     assert error == expected_error_code_and_message
    def test_put_execution_play_fast(self, test_client, test_config,
                                     post_execution_no_sleep):
        response = test_client.get('/executions',
                                   headers={"apiKey": standard_user().api_key})
        response = test_client.put(
            '/executions/{}/play'.format(post_execution_no_sleep),
            headers={
                "apiKey": standard_user().api_key,
            })
        assert response.status_code == 204

        output_path = os.path.join(app.config['DATA_DIRECTORY'],
                                   standard_user().username, 'executions',
                                   post_execution_no_sleep, 'greeting.txt')
        assert os.path.exists(output_path)

        with open(output_path) as f:
            assert f.read() == 'Welcome to CARMIN-Server, Jane Doe.\n'
 def test_get_invalid_action(self, test_client):
     response = test_client.get('/path/{}/file.json?action=invalid'.format(
         standard_user().username),
                                headers={"apiKey": standard_user().api_key})
     error = error_from_response(response)
     assert error == INVALID_ACTION
 def test_get_execution_std_err_not_found(self, test_client, execution_id):
     response = test_client.get(
         '/executions/{}/stderr'.format(execution_id),
         headers={"apiKey": standard_user().api_key})
     error = error_from_response(response)
     assert error == PATH_DOES_NOT_EXIST
 def test_get_content_action_with_file(self, test_client):
     response = test_client.get('/path/{}/file.json?action=content'.format(
         standard_user().username),
                                headers={"apiKey": standard_user().api_key})
     assert response.data == b'{"test": "json"}'
 def test_get_content_action_with_dir(self, test_client):
     response = test_client.get(
         '/path/{}/subdirectory?action=content'.format(
             standard_user().username),
         headers={"apiKey": standard_user().api_key})
     assert response.headers['Content-Type'] == 'application/gzip'
 def test_get_execution_std_err_by_identifier(self, test_client,
                                              execution_id, write_std_err):
     response = test_client.get(
         '/executions/{}/stderr'.format(execution_id),
         headers={"apiKey": standard_user().api_key})
     assert response.data.decode('utf8') == write_std_err
 def test_get_with_negative_limit(self, test_client, number_of_executions):
     limit = -10
     response = test_client.get('/executions?limit={}'.format(limit),
                                headers={"apiKey": standard_user().api_key})
     json_response = load_json_data(response)
     assert len(json_response) == number_of_executions
 def test_get_list_action_with_file(self, test_client):
     response = test_client.get('/path/{}/file.json?action=list'.format(
         standard_user().username),
                                headers={"apiKey": standard_user().api_key})
     error = error_from_response(response)
     assert error == LIST_ACTION_ON_FILE
 def test_get_with_invalid_offset(self, test_client, number_of_executions):
     offset = "invalid"
     response = test_client.get('/executions?offset={}'.format(offset),
                                headers={"apiKey": standard_user().api_key})
     json_response = load_json_data(response)
     assert len(json_response) == number_of_executions
 def test_get_md5_action_with_dir(self, test_client):
     response = test_client.get('/path/{}/subdirectory?action=md5'.format(
         standard_user().username),
                                headers={"apiKey": standard_user().api_key})
     error = error_from_response(response)
     assert error == MD5_ON_DIR
 def test_query_outside_authorized_directory(self, test_client):
     response = test_client.get('/path/../../test?action=properties',
                                headers={"apiKey": standard_user().api_key})
     error = error_from_response(response)
     assert error == INVALID_PATH
 def test_get_without_executions(self, test_client):
     response = test_client.get('/executions',
                                headers={"apiKey": standard_user().api_key})
     json_response = load_json_data(response)
     executions = ExecutionSchema(many=True).load(json_response).data
     assert not executions
Beispiel #28
0
 def test_get_0_executions(self, test_client):
     response = test_client.get('/executions/count',
                                headers={"apiKey": standard_user().api_key})
     json_response = load_json_data(response)
     assert json_response == 0
 def test_get_no_action(self, test_client):
     response = test_client.get('/path/{}/file.json'.format(
         standard_user().username),
                                headers={"apiKey": standard_user().api_key})
     error = error_from_response(response)
     assert error == ACTION_REQUIRED
Beispiel #30
0
 def test_get_execution(self, test_client, execution_id):
     response = test_client.get('/executions/{}'.format(execution_id),
                                headers={"apiKey": standard_user().api_key})
     json_response = load_json_data(response)
     execution = ExecutionSchema().load(json_response).data
     assert isinstance(execution, Execution)