Skip to content
Snippets Groups Projects
Commit 7a669219 authored by Sabine Schröder's avatar Sabine Schröder
Browse files

added tests for data ingestion, version_numbers and searches with global metadata filters

parent a16f6b43
Branches
No related tags found
2 merge requests!224preparation for testing the (re-)integrated AAI; started strictly separating...,!220make "fields" argument available for endpoint data/timeseries on testing for performance speedup of the analysis service
Pipeline #235986 passed
......@@ -5,7 +5,7 @@
"min_topography_srtm_relative_alt_5km_year1994":-999.0,
"stddev_topography_srtm_relative_alt_5km_year1994":-999.0,
"climatic_zone_year2016": 6,
"htap_region_tier1_year2010":10,
"htap_region_tier1_year2010":11,
"dominant_landcover_year2012":10,
"landcover_description_25km_year2012":"11:30.7 %,12:25.0 %,210:16.9 %,130:8.6 %,190:5.8 %,100:3.5 %,40:2.6 %,10:2.0 %,30:1.9 %",
"dominant_ecoregion_year2017":-1,
......@@ -31,7 +31,7 @@
"min_topography_srtm_relative_alt_5km_year1994":-999.0,
"stddev_topography_srtm_relative_alt_5km_year1994":-999.0,
"climatic_zone_year2016": 6,
"htap_region_tier1_year2010":10,
"htap_region_tier1_year2010":11,
"dominant_landcover_year2012":10,
"landcover_description_25km_year2012":"",
"dominant_ecoregion_year2017":-1,
......
......@@ -539,6 +539,21 @@ class TestApps:
{'datetime': '2012-12-17T04:00:00+00:00', 'value': 19.62, 'flags': 'OK validated verified', 'timeseries_id': 2, 'version': '1.0'}]}
assert response.json() == expected_response
def test_create_data_record(self, client, db):
response = client.post("/data/timeseries/record/?series_id=2&datetime=2021-08-23%2015:00:00&value=67.3&flag=OK&version=000001.000001.00000000000000")
expected_status_code = 200
assert response.status_code == expected_status_code
expected_response = 'Data successfully inserted.'
assert response.json() == expected_response
patched_response = client.get("/timeseries/2")
assert patched_response.status_code == expected_status_code
patched_response_changelog = patched_response.json()["changelog"][-1]
patched_response_changelog["datetime"] = ""
expected_changelog = {'datetime': '', 'description': 'data record created', 'old_value': '', 'new_value': '',
'timeseries_id': 2, 'author_id': 1, 'type_of_change': 'created', 'period_start': '2021-08-23T15:00:00+00:00',
'period_end': '2021-08-23T15:00:00+00:00', 'version': '000001.000001.00000000000000'}
assert patched_response_changelog == expected_changelog
def test_patch_data(self, client, db):
response = client.patch("/data/timeseries/?description=test patch&version=000002.000000.00000000000000", files={"file": open("tests/fixtures/data/toluene_SDZ54421_2012_2012_v2-0.dat", "rb")})
......@@ -557,6 +572,17 @@ class TestApps:
def test_patch_bulk_data(self, client, db):
# show version of the original time series
version_response = client.get("/data/timeseries/next_version/1")
expected_status_code = 200
assert version_response.status_code == expected_status_code
expected_response = '000001.000001.00000000000000'
assert version_response.json() == expected_response
version_response = client.get("/data/timeseries/next_version/1?major=True")
expected_status_code = 200
assert version_response.status_code == expected_status_code
expected_response = '000002.000000.00000000000000'
assert version_response.json() == expected_response
response = client.patch("/data/timeseries/bulk/?description=test patch bulk data&version=000002.000000.00000000000000",
data='''[{"datetime": "2012-12-17T00:00:00+00:00", "value": 7.848, "flags": 0, "timeseries_id": 1, "version": "000002.000000.00000000000000"},
{"datetime": "2012-12-17T01:00:00+00:00", "value": 15.696, "flags": 0, "timeseries_id": 1, "version": "000002.000000.00000000000000"},
......@@ -662,6 +688,17 @@ class TestApps:
dindex = patched_response['metadata']['citation'].index(" on 2")
patched_response['metadata']['citation'] = patched_response['metadata']['citation'][:dindex]
assert patched_response == expected_response
# also show that next_version has changed by this patch
version_response = client.get("/data/timeseries/next_version/1")
expected_status_code = 200
assert version_response.status_code == expected_status_code
expected_response = '000002.000001.00000000000000'
assert version_response.json() == expected_response
version_response = client.get("/data/timeseries/next_version/1?major=True")
expected_status_code = 200
assert version_response.status_code == expected_status_code
expected_response = '000003.000000.00000000000000'
assert version_response.json() == expected_response
def test_patch_bulk_data2(self, client, db):
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment