Ported app_client to ds_client where possible in test_auth.py, refs #1959

This commit is contained in:
Simon Willison 2022-12-15 14:18:40 -08:00
commit 425ac4357f
6 changed files with 91 additions and 67 deletions

View file

@ -1718,6 +1718,10 @@ class DatasetteClient:
self.ds = ds
self.app = ds.app()
def actor_cookie(self, actor):
# Utility method, mainly for tests
return self.ds.sign({"a": actor}, "actor")
def _fix(self, path, avoid_path_rewrites=False):
if not isinstance(path, PrefixedUrlString) and not avoid_path_rewrites:
path = self.ds.urls.path(path)

View file

@ -28,13 +28,6 @@ class TestResponse:
def cookies(self):
return dict(self.httpx_response.cookies)
def cookie_was_deleted(self, cookie):
return any(
h
for h in self.httpx_response.headers.get_list("set-cookie")
if h.startswith(f'{cookie}="";')
)
@property
def json(self):
return json.loads(self.text)