Moved MockRequest to tests/utils.py

This commit is contained in:
Simon Willison 2019-04-18 07:55:56 -07:00
commit 8310ad2336
2 changed files with 8 additions and 9 deletions

View file

@ -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(

7
tests/utils.py Normal file
View file

@ -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]