From c5bbb0064b8ab9d0477b2322c8d1413c8c273fad Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 15 Feb 2024 19:52:20 -0600 Subject: [PATCH] Fix test util typings (#437) --- jupyterlab_server/test_utils.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/jupyterlab_server/test_utils.py b/jupyterlab_server/test_utils.py index 4435ce3..c1d8956 100644 --- a/jupyterlab_server/test_utils.py +++ b/jupyterlab_server/test_utils.py @@ -60,6 +60,10 @@ def __init__(self, request: HTTPRequest, spec: Spec): path=path, ) + @property + def content_type(self) -> str: + return "application/json" + @property def host_url(self) -> str: url = self.request.url @@ -95,13 +99,13 @@ def method(self) -> str: return method and method.lower() or "" @property - def body(self) -> str | None: + def body(self) -> bytes | None: if self.request.body is None: return None # type:ignore[unreachable] if not isinstance(self.request.body, bytes): msg = "Request body is invalid" # type:ignore[unreachable] raise AssertionError(msg) - return self.request.body.decode("utf-8") + return self.request.body @property def mimetype(self) -> str: @@ -123,16 +127,20 @@ def __init__(self, response: HTTPResponse): self.response = response @property - def data(self) -> str: + def data(self) -> bytes | None: if not isinstance(self.response.body, bytes): msg = "Response body is invalid" # type:ignore[unreachable] raise AssertionError(msg) - return self.response.body.decode("utf-8") + return self.response.body @property def status_code(self) -> int: return int(self.response.code) + @property + def content_type(self) -> str: + return "application/json" + @property def mimetype(self) -> str: return str(self.response.headers.get("Content-Type", "application/json"))