mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Implemented actor_from_request with tests, refs #699
Also added datasette argument to permission_allowed hook
This commit is contained in:
parent
060a56735c
commit
461c82838d
6 changed files with 80 additions and 2 deletions
|
|
@ -503,3 +503,27 @@ def test_register_facet_classes(app_client):
|
|||
"toggle_url": "http://localhost/fixtures/compound_three_primary_keys.json?_dummy_facet=1&_facet=pk3",
|
||||
},
|
||||
] == data["suggested_facets"]
|
||||
|
||||
|
||||
def test_actor_from_request(app_client):
|
||||
app_client.get("/")
|
||||
# Should have no actor
|
||||
assert None == app_client.ds._last_request.scope["actor"]
|
||||
app_client.get("/?_bot=1")
|
||||
# Should have bot actor
|
||||
assert {"id": "bot"} == app_client.ds._last_request.scope["actor"]
|
||||
|
||||
|
||||
def test_actor_from_request_async(app_client):
|
||||
app_client.get("/")
|
||||
# Should have no actor
|
||||
assert None == app_client.ds._last_request.scope["actor"]
|
||||
app_client.get("/?_bot2=1")
|
||||
# Should have bot2 actor
|
||||
assert {"id": "bot2", "1+1": 2} == app_client.ds._last_request.scope["actor"]
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_permission_allowed(app_client):
|
||||
# TODO
|
||||
assert False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue