From 7421c79b0cd73ea45aa517632766bed391dc2964 Mon Sep 17 00:00:00 2001 From: Lars Falk-Petersen Date: Wed, 3 Jan 2024 13:11:13 +0100 Subject: [PATCH] Add web test for other urls --- app/test_app.py | 24 +++++++++++++++++++----- environment-dev.yml | 1 + environment.yml | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/test_app.py b/app/test_app.py index 128318f..64ee192 100644 --- a/app/test_app.py +++ b/app/test_app.py @@ -1,8 +1,4 @@ import unittest -import os -from datetime import datetime -import uvicorn -from fastapi import FastAPI from fastapi.testclient import TestClient from app import app @@ -11,11 +7,29 @@ class TestApp(unittest.TestCase): - def test_read_main(self): + def test_landingpage(self): response = client.get("/") self.assertEqual(response.status_code, 200) self.assertIn("EDR isobaric from Grib", response.text) + def test_conformance(self): + response = client.get("/conformance") + self.assertEqual(response.status_code, 200) + self.assertIn('{"conformsTo":["http://www.opengis.net/spec/ogcapi-common-1/1.0/conf/core",', response.text) + + + def test_collections(self): + response = client.get("/collections") + self.assertEqual(response.status_code, 200) + self.assertIn('{"links":[{"href":"http://localhost:5000/","hreflang":"en","rel":"self","type":"aplication/json"}],"collections":[{"id":"isobaric","title":"', response.text) + + + def test_point(self): + response = client.get("/collections/position?coords=POINT(60.1699 11.9384)") + self.assertEqual(response.status_code, 200) + self.assertIn('"vertical":{"interval":[["850.0"],["100.0"]],"values":["850.0","750.0","700.0","600.0","500.0","450.0","400.0","350.0","300.0","275.0","250.0","225.0","200.0","150.0","100.0"],"vrs":"Vertical Reference System: PressureLevel"}},', response.text) + + if __name__ == "__main__": unittest.main() diff --git a/environment-dev.yml b/environment-dev.yml index 39e3c9e..861d36d 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -10,3 +10,4 @@ dependencies: - pylint - tox - bandit + - httpx diff --git a/environment.yml b/environment.yml index d3aef35..ef9e4d8 100644 --- a/environment.yml +++ b/environment.yml @@ -4,7 +4,7 @@ channels: dependencies: - fastapi[all]==0.105.0 - uvicorn[standard]==0.24.0.post1 - - eccodes + - eccodes==2.33.0 - cfgrib==0.9.10.4 - shapely==2.0.1 - xarray==2023.12.0