Skip to content
Snippets Groups Projects
Commit 7ba9ca37 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

adding data schema

parent 72562bc8
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -69,13 +69,3 @@ def get_all_data_state():
data_states = [get_data_by_id(data_id, wait)
for data_id in session['data_ids']]
return jsonify(data_states), 200
@data_blueprint.route('/<uuid:data_id>', methods=['DELETE'])
def delete_data(data_id):
session['data_ids'].remove(data_id)
@data_blueprint.route('', methods=['DELETE'])
def delete_all_data():
session['data_ids'] = []
create_data_schema = {
"type": "object",
"properties": {
"handler": {"type": "string"},
"server": {"type": "string"},
"token": {"type": "string"},
"descriptors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"data_type": {"type": "string"},
},
"minProperties": 2,
"required": ["data_type"]
}
}
},
"required": ["handler", "server", "token", "descriptors"]
}
......@@ -69,12 +69,77 @@ class TestData:
]
)))
# POST /
@pytest.fixture(scope='function', params=[
{
'handler': '',
'server': 'localhost',
'token': '1234567890',
'descriptors': '[{"data_type": "foo", "concept": "GSE1234"}]'
},
{
'handler': 'test',
'server': '',
'token': '1234567890',
'descriptors': '[{"data_type": "foo", "concept": "GSE1234"}]'
},
{
'handler': 'test',
'server': 'localhost',
'token': '',
'descriptors': '[{"data_type": "foo", "concept": "GSE1234"}]'
},
{
'handler': 'test',
'server': 'localhost',
'token': '1234567890',
'descriptors': ''
},
{
'handler': 'test',
'server': 'localhost',
'token': '1234567890',
'descriptors': '[{"data_type": "foo", "concept": "GSE1234"}]'
},
{
'handler': 'test',
'server': 'localhost',
'token': '1234567890',
'descriptors': '[{"concept": "GSE1234"}]'
},
{
'handler': 'test',
'server': 'localhost',
'token': '1234567890',
'descriptors': '[{"data_type": "foo"}]'
},
{
'handler': 'test',
'server': 'localhost',
'token': '1234567890',
'descriptors': '[{"data_type": "", "concept": "GSE1234"}]'
},
{
'handler': 'test',
'server': 'localhost',
'token': '1234567890',
'descriptors': '[]'
}
])
def bad_post(self, test_client, request):
return lambda: test_client.post('/data', data=flask.json.dumps(dict(
handler=request.param['handler'],
server=request.param['server'],
token=request.param['token'],
descriptors=request.param['descriptors']
)))
def test_bad_POST(self, bad_post):
assert bad_post().status_code == 400
def test_201_on_small_POST_and_valid_state(self, test_client, small_post):
rv = small_post(random=False)
assert rv.status_code == 201
body = flask.json.loads(rv.get_data())
assert rv.status_code == 201, body
assert len(body['data_ids']) == 1
test_client.head('/data?wait=1')
data_dir = os.path.join(app.config['FRACTALIS_TMP_DIR'], 'data')
......@@ -89,8 +154,8 @@ class TestData:
def test_201_on_big_POST_and_valid_state(self, test_client, big_post):
rv = big_post(random=False)
assert rv.status_code == 201
body = flask.json.loads(rv.get_data())
assert rv.status_code == 201, body
assert len(body['data_ids']) == 3
test_client.head('/data?wait=1')
data_dir = os.path.join(app.config['FRACTALIS_TMP_DIR'], 'data')
......@@ -162,8 +227,7 @@ class TestData:
assert data_obj['job_id']
assert data_obj['file_path']
def test_many_big_random_POST_and_valid_state(
self, test_client, big_post):
def test_many_big_random_POST_and_valid_state(self, test_client, big_post):
N = 10
data_dir = os.path.join(app.config['FRACTALIS_TMP_DIR'], 'data')
for i in range(N):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment