Skip to content

Commit 18b8884

Browse files
committed
integration test for providing extra profile for validation
1 parent ce29cde commit 18b8884

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

tests/test_integration.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,80 @@ def test_directory_rocrate_validation():
350350
assert response_result["passed"] is False
351351

352352

353+
def test_extra_profile_rocrate_validation():
354+
ro_crate = "ro_crate_2"
355+
profile_name = "alpha-crate-0.1"
356+
url_post = f"http://localhost:5001/v1/ro_crates/{ro_crate}/validation"
357+
url_get = f"http://localhost:5001/v1/ro_crates/{ro_crate}/validation"
358+
headers = {
359+
"accept": "application/json",
360+
"Content-Type": "application/json"
361+
}
362+
363+
# The API expects the JSON to be passed as a string
364+
post_payload = {
365+
"minio_config": {
366+
"endpoint": "minio:9000",
367+
"accesskey": "minioadmin",
368+
"secret": "minioadmin",
369+
"ssl": False,
370+
"bucket": "ro-crates"
371+
},
372+
"profile_name": profile_name
373+
}
374+
get_payload = {
375+
"minio_config": {
376+
"endpoint": "minio:9000",
377+
"accesskey": "minioadmin",
378+
"secret": "minioadmin",
379+
"ssl": False,
380+
"bucket": "ro-crates"
381+
}
382+
}
383+
384+
# POST action and tests
385+
response = requests.post(url_post, json=post_payload, headers=headers)
386+
response_result = response.json()['message']
387+
388+
# Print response for debugging
389+
print("Status Code:", response.status_code)
390+
print("Response JSON:", response_result)
391+
392+
# Assertions
393+
assert response.status_code == 202
394+
assert response_result == "Validation in progress"
395+
396+
# wait for ro-crate to be validated
397+
time.sleep(10)
398+
399+
# GET action and tests
400+
response = requests.get(url_get, json=get_payload, headers=headers)
401+
response_result = response.json()
402+
403+
# Print response for debugging
404+
print("Status Code:", response.status_code)
405+
print("Response JSON:", response_result)
406+
407+
start_time = time.time()
408+
while response.status_code == 400:
409+
time.sleep(10)
410+
# GET action and tests
411+
response = requests.get(url_get, json=get_payload, headers=headers)
412+
response_result = response.json()
413+
# Print response for debugging
414+
print("Status Code:", response.status_code)
415+
print("Response JSON:", response_result)
416+
417+
elapsed = time.time() - start_time
418+
if elapsed > 60:
419+
print("60 seconds passed. Exiting loop")
420+
break
421+
422+
# Assertions
423+
assert response.status_code == 200
424+
assert response_result["passed"] is False
425+
426+
353427
def test_ignore_rocrates_not_on_basepath():
354428
ro_crate = "ro_crate_4"
355429
url_post = f"http://localhost:5001/v1/ro_crates/{ro_crate}/validation"

0 commit comments

Comments
 (0)