From 8310ad2336c17ae043a5686eaec0d466e8218701 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 18 Apr 2019 07:55:56 -0700 Subject: [PATCH] Moved MockRequest to tests/utils.py --- tests/test_facets.py | 10 +--------- tests/utils.py | 7 +++++++ 2 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 tests/utils.py diff --git a/tests/test_facets.py b/tests/test_facets.py index 9046ecae..d6444342 100644 --- a/tests/test_facets.py +++ b/tests/test_facets.py @@ -1,18 +1,10 @@ from datasette.facets import ColumnFacet from .fixtures import app_client # noqa +from .utils import MockRequest from collections import namedtuple import pytest -class MockRequest: - def __init__(self, url): - self.url = url - self.path = "/" + url.split("://")[1].split("/", 1)[1] - self.query_string = "" - if "?" in url: - self.query_string = url.split("?", 1)[1] - - @pytest.mark.asyncio async def test_column_facet_suggest(app_client): facet = ColumnFacet( diff --git a/tests/utils.py b/tests/utils.py new file mode 100644 index 00000000..419d60d1 --- /dev/null +++ b/tests/utils.py @@ -0,0 +1,7 @@ +class MockRequest: + def __init__(self, url): + self.url = url + self.path = "/" + url.split("://")[1].split("/", 1)[1] + self.query_string = "" + if "?" in url: + self.query_string = url.split("?", 1)[1]