Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/gnu/tests/__init__.py
# Copyright (C) 2019 The Software Heritage developers | |||||
# See the AUTHORS file at the top-level directory of this distribution | |||||
# License: GNU General Public License version 3, or any later version | |||||
# See top-level LICENSE file for more information | |||||
from os.path import join, dirname, isfile | |||||
from urllib.parse import urlparse | |||||
DATADIR = join(dirname(__file__), 'data') | |||||
def get_response_cb(request, context): | |||||
"""Mock the http request to send back the on-disk file handler | |||||
""" | |||||
url = urlparse(request.url) | |||||
dirname = url.hostname | |||||
filename = url.path[1:].replace('/', '_') | |||||
filepath = join(DATADIR, dirname, filename) | |||||
if not isfile(filepath): | |||||
context.status_code = 404 | |||||
return None | |||||
return open(filepath, 'rb') | |||||
ardumont: D2082 defines the generic fixture for this btw. | |||||
Done Inline ActionsThis needs to go away, on it. ardumont: This needs to go away, on it. |
D2082 defines the generic fixture for this btw.