Skip to content

Commit

Permalink
Add tests for build_gribfile_name
Browse files Browse the repository at this point in the history
  • Loading branch information
ways committed Jan 3, 2024
1 parent 7438031 commit 6e471ca
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
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 @@ -26,6 +25,8 @@ async def lifespan() -> AsyncGenerator[None, None]:
yield


from routes.routes import routes

app.include_router(routes)


Expand Down
1 change: 0 additions & 1 deletion app/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def parse_args() -> argparse.Namespace:
default="http://localhost:5000/",
required=False,
)

return parser.parse_args()


Expand Down
23 changes: 23 additions & 0 deletions app/test_initialize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import unittest
import os
from datetime import datetime
from initialize import build_gribfile_name


class TestInitialize(unittest.TestCase):
def test_build_gribfile_name(self):
data_path = "test_data"
time = datetime(2023, 1, 1, 6)
expected = os.path.join(data_path, "T_YTNE85_C_ENMI_20230101060000.bin")
actual = build_gribfile_name(data_path, time)
self.assertEqual(expected, actual)

def test_build_gribfile_name2(self):
data_path = "test_data"
expected = os.path.join(data_path, "T_YTNE85_C_ENMI_20230101120000.bin")
actual = build_gribfile_name(data_path, datetime(2023, 1, 1, 13))
self.assertEqual(expected, actual)


if __name__ == "__main__":
unittest.main()
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
envlist = py310, black, prospector, bandit, mypy

[testenv]
change_dir = app
commands = python3 -m unittest
deps = -rrequirements-dev.txt

Expand Down

0 comments on commit 6e471ca

Please sign in to comment.