Skip to content

Commit

Permalink
Fix e2e tests cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallmcdonnell committed Aug 16, 2024
1 parent 69129ba commit c822a60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tests/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ def base_url(request):
def collection_service(base_url):
collection_service = CollectionService(hostname=base_url)
yield collection_service
#for collection in collection_service.get_collections():
# collection_service.delete_by_title(collection)
for collection in collection_service.get_collections():
collection_service.delete_by_title(collection)


@pytest.fixture
def ssm_rester(base_url):
ssm_rester = SSMRester(hostname=base_url)
yield ssm_rester
#for collection in ssm_rester.collection.get_collections():
# ssm_rester.collection.delete_by_title(collection)
for collection in ssm_rester.collection.get_collections():
ssm_rester.collection.delete_by_title(collection)
6 changes: 5 additions & 1 deletion tests/e2e/test_ssm_rester.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,25 @@ def test_metazeunerite_dataset_ssm_json_create(ssm_rester, metazeunerite_jsonld,


def test_metazeunerite_dataset_ssm_json_update(ssm_rester, metazeunerite_jsonld):
# Create collection and upload metazeunerite scidata JSON-LD
collection = ssm_rester.collection.create("foo-collection-ssm-json")
ssm_rester.initialize_dataset_for_collection(collection)
dataset = ssm_rester.dataset.create(metazeunerite_jsonld)

# Pull down the metazeuneriate data from catalog in SSM JSON format
dataset_ssm_json = ssm_rester.dataset.get_by_uuid(dataset.uuid, format="json")

# Modify the 51st data entry for y-axis
dataseries = dataset_ssm_json.dataset.get("scidata").get("dataseries")
# x = 0, y = 1
y = dataseries[1].get("y-axis").get("parameter").get("numericValueArray")[0].get("numberArray")
y[50] -= 100.0

# Write out the modified SSM JSON metazeunerite data to file
ssm_json_filename = "temporary.json"
with open(ssm_json_filename, "w") as f:
json.dump(dataset_ssm_json.dataset, f)

# Upload the modified metazeunerite SSM JSON file to converter for SciData JSON-LD format output
with open(ssm_json_filename, "r") as f:
file_args = {"upload_file": (ssm_json_filename, f)}
response = requests.post("http://localhost:8000/convert/jsonld", files=file_args)
Expand Down

0 comments on commit c822a60

Please sign in to comment.