diff --git a/tests/test_api.py b/tests/test_api.py index bee464a3..c4a8f80b 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,9 +1,9 @@ import json -from typing import Dict, Optional, Tuple, List, Any +from typing import Dict, Optional, Any from unittest import TestCase import optuna -from .wsgi_utils import create_wsgi_env, send_request +from .wsgi_utils import create_wsgi_env, send_request, WSGIEnv from optuna_dashboard.app import create_app @@ -13,7 +13,7 @@ def create_json_api_wsgi_env( json_body: Optional[Dict[str, Any]] = None, content_type: str = "application/json", headers: Optional[Dict[str, str]] = None, -): +) -> WSGIEnv: body = json.dumps(json_body) if json_body else "" return create_wsgi_env( path, method, body, content_type=content_type, headers=headers @@ -21,7 +21,7 @@ def create_json_api_wsgi_env( class APITestCase(TestCase): - def test_create_study(self): + def test_create_study(self) -> None: storage = optuna.storages.InMemoryStorage() self.assertEqual(len(storage.get_all_study_summaries()), 0) @@ -38,7 +38,7 @@ class APITestCase(TestCase): self.assertEqual(status, "201 Created") self.assertEqual(len(storage.get_all_study_summaries()), 1) - def test_create_study_duplicated(self): + def test_create_study_duplicated(self) -> None: storage = optuna.storages.InMemoryStorage() storage.create_new_study("foo") self.assertEqual(len(storage.get_all_study_summaries()), 1) @@ -56,7 +56,7 @@ class APITestCase(TestCase): self.assertEqual(status, "400 Bad Request") self.assertEqual(len(storage.get_all_study_summaries()), 1) - def test_delete_study(self): + def test_delete_study(self) -> None: storage = optuna.storages.InMemoryStorage() storage.create_new_study("foo1") storage.create_new_study("foo2") @@ -71,7 +71,7 @@ class APITestCase(TestCase): self.assertEqual(status, "204 No Content") self.assertEqual(len(storage.get_all_study_summaries()), 1) - def test_delete_study_not_found(self): + def test_delete_study_not_found(self) -> None: storage = optuna.storages.InMemoryStorage() app = create_app(storage) env = create_json_api_wsgi_env( diff --git a/tests/wsgi_utils.py b/tests/wsgi_utils.py index a3a8e53f..6e911320 100644 --- a/tests/wsgi_utils.py +++ b/tests/wsgi_utils.py @@ -2,7 +2,7 @@ import io from typing import Dict, Optional, Union, Any, Tuple, List, Callable, Iterable WSGIEnv = Dict[str, Any] -StartResponse = Callable[[bytes, List[Tuple[str, str]]], None] +StartResponse = Callable[[str, List[Tuple[str, str]]], None] WSGIApp = Callable[[WSGIEnv, StartResponse], Iterable[bytes]]