From 78472e82535da109f63e1b5c5ce8465016c2f8cc Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 15 Jan 2021 01:17:32 -0800 Subject: api: fix /search test, and mypy error on implementation --- tests/test_web.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_web.py b/tests/test_web.py index a5629e0..810f8e3 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -30,7 +30,7 @@ def test_main_view(client: Any) -> None: assert "我们是" in resp.content.decode("utf-8") -def test_basic_api(client: Any) -> None: +def test_basic_api(client: Any, mocker: Any) -> None: """ Simple check of GET routes with application/json support """ @@ -39,6 +39,16 @@ def test_basic_api(client: Any) -> None: assert resp.status_code == 200 assert resp.json() + with open("tests/files/elastic_fulltext_search.json") as f: + elastic_resp = json.loads(f.read()) + + es_raw = mocker.patch( + "elasticsearch.connection.Urllib3HttpConnection.perform_request" + ) + es_raw.side_effect = [ + (200, {}, json.dumps(elastic_resp)), + ] + resp = client.get("/search", headers=headers) assert resp.status_code == 200 assert resp.json() -- cgit v1.2.3