datasette.client internal requests mechanism

Closes #943

* Datasette now requires httpx>=0.15
* Support OPTIONS without 500, closes #1001
* Added internals tests for datasette.client methods
* Datasette's own test mechanism now uses httpx to simulate requests
* Tests simulate HTTP 1.1 now
* Added base_url in a bunch more places
* Mark some tests as xfail - will remove that when new httpx release ships: #1005
This commit is contained in:
Simon Willison 2020-10-09 09:11:24 -07:00 committed by GitHub
commit 8f97b9b58e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 163 additions and 100 deletions

View file

@ -76,9 +76,7 @@ def config_dir_client(tmp_path_factory):
)
ds = Datasette([], config_dir=config_dir)
client = _TestClient(ds.app())
client.ds = ds
yield client
yield _TestClient(ds)
def test_metadata(config_dir_client):
@ -137,8 +135,7 @@ def test_metadata_yaml(tmp_path_factory, filename):
config_dir = tmp_path_factory.mktemp("yaml-config-dir")
(config_dir / filename).write_text("title: Title from metadata", "utf-8")
ds = Datasette([], config_dir=config_dir)
client = _TestClient(ds.app())
client.ds = ds
client = _TestClient(ds)
response = client.get("/-/metadata.json")
assert 200 == response.status
assert {"title": "Title from metadata"} == response.json