Use our real-world context

This commit is contained in:
Eliot Berriot 2020-03-11 16:01:41 +01:00
parent 5654aaa2f7
commit 4f06a4330a
No known key found for this signature in database
GPG Key ID: 6B501DFD73514E14
3 changed files with 16 additions and 21 deletions

View File

@ -220,16 +220,11 @@ def get_default_context():
return [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{"manuallyApprovesFollowers": "as:manuallyApprovesFollowers"},
]
def get_default_context_fw():
return [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{"manuallyApprovesFollowers": "as:manuallyApprovesFollowers"},
"https://funkwhale.audio/ns",
{
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
"Hashtag": "as:Hashtag",
},
]

View File

@ -21,7 +21,7 @@ def test_actor_serializer_from_ap(db):
private, public = keys.get_key_pair()
actor_url = "https://test.federation/actor"
payload = {
"@context": jsonld.get_default_context_fw(),
"@context": jsonld.get_default_context(),
"id": actor_url,
"type": "Person",
"outbox": "https://test.com/outbox",
@ -76,7 +76,7 @@ def test_actor_serializer_from_ap_no_icon_mediaType(db):
private, public = keys.get_key_pair()
actor_url = "https://test.federation/actor"
payload = {
"@context": jsonld.get_default_context_fw(),
"@context": jsonld.get_default_context(),
"id": actor_url,
"type": "Person",
"inbox": "https://test.com/inbox",
@ -281,7 +281,7 @@ def test_accept_follow_serializer_save(factories):
follow = factories["federation.Follow"](approved=None)
data = {
"@context": jsonld.get_default_context_fw(),
"@context": jsonld.get_default_context(),
"id": follow.get_federation_id() + "/accept",
"type": "Accept",
"actor": follow.target.fid,
@ -301,7 +301,7 @@ def test_accept_follow_serializer_validates_on_context(factories):
follow = factories["federation.Follow"](approved=None)
impostor = factories["federation.Actor"]()
data = {
"@context": jsonld.get_default_context_fw(),
"@context": jsonld.get_default_context(),
"id": follow.get_federation_id() + "/accept",
"type": "Accept",
"actor": impostor.url,
@ -337,7 +337,7 @@ def test_undo_follow_serializer_save(factories):
follow = factories["federation.Follow"](approved=True)
data = {
"@context": jsonld.get_default_context_fw(),
"@context": jsonld.get_default_context(),
"id": follow.get_federation_id() + "/undo",
"type": "Undo",
"actor": follow.actor.fid,
@ -356,7 +356,7 @@ def test_undo_follow_serializer_validates_on_context(factories):
follow = factories["federation.Follow"](approved=True)
impostor = factories["federation.Actor"]()
data = {
"@context": jsonld.get_default_context_fw(),
"@context": jsonld.get_default_context(),
"id": follow.get_federation_id() + "/undo",
"type": "Undo",
"actor": impostor.url,
@ -402,7 +402,7 @@ def test_paginated_collection_serializer(factories):
def test_paginated_collection_serializer_validation():
data = {
"@context": jsonld.get_default_context_fw(),
"@context": jsonld.get_default_context(),
"type": "Collection",
"id": "https://test.federation/test",
"totalItems": 5,
@ -579,7 +579,7 @@ def test_music_library_serializer_from_private(factories, mocker):
"funkwhale_api.federation.utils.retrieve_ap_object", return_value=actor
)
data = {
"@context": jsonld.get_default_context_fw(),
"@context": jsonld.get_default_context(),
"audience": "",
"name": "Hello",
"summary": "World",

View File

@ -389,7 +389,7 @@ def test_fetch_success(factories, r_mock, mocker):
tasks.fetch(fetch_id=fetch.pk)
fetch.refresh_from_db()
payload["@context"].append("https://funkwhale.audio/ns")
assert fetch.status == "finished"
assert init.call_count == 1
assert init.call_args[0][1] == artist
@ -421,7 +421,7 @@ def test_fetch_webfinger(factories, r_mock, mocker):
tasks.fetch(fetch_id=fetch.pk)
fetch.refresh_from_db()
payload["@context"].append("https://funkwhale.audio/ns")
assert fetch.status == "finished"
assert fetch.object == actor
assert init.call_count == 1
@ -451,7 +451,7 @@ def test_fetch_rel_alternate(factories, r_mock, mocker):
tasks.fetch(fetch_id=fetch.pk)
fetch.refresh_from_db()
ap_payload["@context"].append("https://funkwhale.audio/ns")
assert fetch.status == "finished"
assert fetch.object == actor
assert init.call_count == 1
@ -482,7 +482,7 @@ def test_fetch_url(factory_name, serializer_class, factories, r_mock, mocker):
tasks.fetch(fetch_id=fetch.pk)
fetch.refresh_from_db()
payload["@context"].append("https://funkwhale.audio/ns")
assert fetch.status == "finished"
assert fetch.object == obj
assert init.call_count == 1