Skip to content

Commit

Permalink
Add web test for /
Browse files Browse the repository at this point in the history
  • Loading branch information
ways committed Jan 3, 2024
1 parent 6e471ca commit 50101e4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
3 changes: 1 addition & 2 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import AsyncGenerator
import uvicorn
from fastapi import FastAPI
from routes.routes import routes


app = FastAPI(openapi_url="/openapi.json", docs_url="/api")
Expand All @@ -25,8 +26,6 @@ async def lifespan() -> AsyncGenerator[None, None]:
yield


from routes.routes import routes

app.include_router(routes)


Expand Down
21 changes: 21 additions & 0 deletions app/test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import unittest
import os
from datetime import datetime
import uvicorn
from fastapi import FastAPI
from fastapi.testclient import TestClient

from app import app

client = TestClient(app)


class TestApp(unittest.TestCase):
def test_read_main(self):
response = client.get("/")
self.assertEqual(response.status_code, 200)
self.assertIn("EDR isobaric from Grib", response.text)


if __name__ == "__main__":
unittest.main()
11 changes: 10 additions & 1 deletion app/test_initialize.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import unittest
import os
from datetime import datetime
from initialize import build_gribfile_name
from initialize import build_gribfile_name, download_gribfile

datafile = ""


class TestInitialize(unittest.TestCase):
Expand All @@ -18,6 +20,13 @@ def test_build_gribfile_name2(self):
actual = build_gribfile_name(data_path, datetime(2023, 1, 1, 13))
self.assertEqual(expected, actual)

def test_download_gribfile(self):
global datafile
datafile = download_gribfile(data_path="/tmp")
print(datafile)
self.assertTrue(os.path.isfile(datafile))
os.remove(datafile)


if __name__ == "__main__":
unittest.main()

0 comments on commit 50101e4

Please sign in to comment.