mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 17:45:18 +02:00
Ensures federation urls can answer to application/ld+json, application/activity+json and application/json requests
This commit is contained in:
parent
c9e7eea65b
commit
12c9db3960
19 changed files with 1294 additions and 1001 deletions
32
api/tests/federation/test_contexts.py
Normal file
32
api/tests/federation/test_contexts.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
import pytest
|
||||
|
||||
from funkwhale_api.federation import contexts
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"ns, property, expected",
|
||||
[
|
||||
("AS", "followers", "https://www.w3.org/ns/activitystreams#followers"),
|
||||
("AS", "following", "https://www.w3.org/ns/activitystreams#following"),
|
||||
("SEC", "owner", "https://w3id.org/security#owner"),
|
||||
("SEC", "publicKey", "https://w3id.org/security#publicKey"),
|
||||
],
|
||||
)
|
||||
def test_context_ns(ns, property, expected):
|
||||
ns = getattr(contexts, ns)
|
||||
id = getattr(ns, property)
|
||||
assert id == expected
|
||||
|
||||
|
||||
def test_raise_on_wrong_attr():
|
||||
ns = contexts.AS
|
||||
with pytest.raises(AttributeError):
|
||||
ns.noop
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"property, expected",
|
||||
[("publicKey", "_:publicKey"), ("cover", "_:cover"), ("hello", "_:hello")],
|
||||
)
|
||||
def test_noop_context(property, expected):
|
||||
assert getattr(contexts.NOOP, property) == expected
|
Loading…
Add table
Add a link
Reference in a new issue