mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-10 12:23:22 +08:00
Add type hints to tests
This commit is contained in:
+7
-7
@@ -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(
|
||||
|
||||
+1
-1
@@ -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]]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user