From abc84cdbf799fa8a7f6a0b572a74dadbad89c8ff Mon Sep 17 00:00:00 2001 From: Alex Kerney Date: Tue, 3 Nov 2020 10:41:38 -0500 Subject: [PATCH] Add test and tweak comparison for actual range error --- Changelog.md | 2 + app/deployments/tasks.py | 2 +- .../cassettes/500_no_rows_actual_range.yaml | 54 +++++++++++++++++++ app/deployments/tests/test_tasks.py | 25 +++++++++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 app/deployments/tests/cassettes/500_no_rows_actual_range.yaml diff --git a/Changelog.md b/Changelog.md index 4aafb62f..7d286ecc 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,8 @@ Changes: Fixes: +- Add test and tweak comparison for actual range error. + ## 0.1.12 - 11/3/2020 Changes: diff --git a/app/deployments/tasks.py b/app/deployments/tasks.py index 876a8ee7..16124207 100644 --- a/app/deployments/tasks.py +++ b/app/deployments/tasks.py @@ -141,7 +141,7 @@ def handle_500_variable_actual_range_error(timeseries_group, compare_text: str) """ if ( "Your query produced no matching results" in compare_text - and "is outside of the variable's actual_range" in compare_text + and "is outside of the variable's actual_range" in compare_text ): logger.info( f"{timeseries_group[0].dataset.name} with constraints {timeseries_group[0].constraints} had a constraint outside of normal range" diff --git a/app/deployments/tests/cassettes/500_no_rows_actual_range.yaml b/app/deployments/tests/cassettes/500_no_rows_actual_range.yaml new file mode 100644 index 00000000..1723c1bd --- /dev/null +++ b/app/deployments/tests/cassettes/500_no_rows_actual_range.yaml @@ -0,0 +1,54 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - python-requests/2.22.0 + method: GET + uri: http://www.neracoos.org/erddap/tabledap/A01_waves_mstrain_all.csvp?time,maximum_wave_height_3&maximum_wave_height_3_qc=0&time%3E=1604331173.10337 + response: + body: + string: !!binary | + H4sIAAAAAAAAA7WU22rbQBCGX2XqQGkhtnyoUyrLgkAK7UWhNLrplRmtRtbS1a6yO3LshkDeoW/Y + J+lISonpARpobgQ7M/vNP4dV8qxwig8NQcW1SZPuCwbtdj0iO5IzYZEmrNlQ+i7LPsIlI7cBltMp + fL/7Bu8tk7do4JL8jjy89d75JBouJIEPhqDDr0dMe45UCKO0msFN6SyPS6y1OcQZVq7G03Ov0ZwG + tGEcyOtypZxxPr6uNNMqR/Vl611ri/FgPlnOlxevz1Y9KOivFM/nzX51C9X8Seizs4G+eBr6q56e + u+LwGH5uBP07f0gruP+o9Raaf6M9EO6Rx1KPKh6mhXBz7BfDxGJNv1onRlsxVqS3FcczufpXobnz + BfnYOistSKJ+BdMkGha5a7As9ewxuyzRSeVBGQxhPeqEjCBKk0ZoaSarnUR5+hP1iRrnOYmae/8H + CgG3Q8hn13q4askfoPGuaBUVYB3UyKrSdgueQms4TOBFjXtdt/XmGne0GWreLDZXaj0FHcC1HHRB + 4ErgimCHMoHc0POTxZtVAFTcotl4ecIUwxzYwfzlg6ALCsrrhrWzvahMCGEol6ySdkoLRBdaaC3t + G1IsJ+VsobsrkhBZ1NOObOfQDKV3NZStKbUxXRWdJE9SZuBJn/YPrasW6XmDSiIzVyuUfolF5PTD + ifof0Q9E3dMSmAQAAA== + headers: + Access-Control-Allow-Origin: + - '*' + Connection: + - close + Content-Encoding: + - gzip + Content-Language: + - en + Content-Length: + - '526' + Content-Type: + - text/html;charset=utf-8 + Date: + - Tue, 03 Nov 2020 15:32:53 GMT + Last-Modified: + - Tue, 03 Nov 2020 15:32:53 GMT + Vary: + - Accept-Encoding,User-Agent + erddap-server: + - '1.82' + xdods-server: + - dods/3.7 + status: + code: 500 + message: Internal Server Error +version: 1 diff --git a/app/deployments/tests/test_tasks.py b/app/deployments/tests/test_tasks.py index a39935f4..b99c4bcb 100644 --- a/app/deployments/tests/test_tasks.py +++ b/app/deployments/tests/test_tasks.py @@ -199,3 +199,28 @@ def test_500_no_rows(self): ts.refresh_from_db() assert ts.value is None + + @my_vcr.use_cassette("500_no_rows_actual_range.yaml") + def test_500_actual_range(self): + a01 = Platform.objects.get(name="A01") + dataset = ErddapDataset.objects.create( + name="A01_waves_mstrain_all", server=self.erddap + ) + ts = TimeSeries.objects.create( + platform=a01, + data_type=DataType.objects.get(standard_name="max_wave_height"), + variable="maximum_wave_height_3", + constraints={"maximum_wave_height_3_qc=": 0}, + start_time="2019-05-29T19:06:07", + dataset=dataset, + ) + + ts.refresh_from_db() + + assert ts.value is None + + tasks.update_values_for_timeseries([ts]) + + ts.refresh_from_db() + + assert ts.value is None