X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/7c66fef63f5066674e0e76d378c8ace2754ee54c..2171b385519841af0e175d88e51741c5322fba25:/test/python/api/test_server_glue_v1.py diff --git a/test/python/api/test_server_glue_v1.py b/test/python/api/test_server_glue_v1.py index a731e720..26e6517e 100644 --- a/test/python/api/test_server_glue_v1.py +++ b/test/python/api/test_server_glue_v1.py @@ -7,56 +7,18 @@ """ Tests for the Python web frameworks adaptor, v1 API. """ -from collections import namedtuple import json import xml.etree.ElementTree as ET from pathlib import Path import pytest -from nominatim.config import Configuration +from fake_adaptor import FakeAdaptor, FakeError, FakeResponse + import nominatim.api.v1.server_glue as glue import nominatim.api as napi import nominatim.api.logging as loglib -class FakeError(BaseException): - - def __init__(self, msg, status): - self.msg = msg - self.status = status - - def __str__(self): - return f'{self.status} -- {self.msg}' - -FakeResponse = namedtuple('FakeResponse', ['status', 'output', 'content_type']) - -class FakeAdaptor(glue.ASGIAdaptor): - - def __init__(self, params=None, headers=None, config=None): - self.params = params or {} - self.headers = headers or {} - self._config = config or Configuration(None) - - - def get(self, name, default=None): - return self.params.get(name, default) - - - def get_header(self, name, default=None): - return self.headers.get(name, default) - - - def error(self, msg, status=400): - return FakeError(msg, status) - - - def create_response(self, status, output): - return FakeResponse(status, output, self.content_type) - - - def config(self): - return self._config - # ASGIAdaptor.get_int/bool()