kopia lustrzana https://gitlab.com/jaywink/federation
Move test settings and utils for Django to tests root
Fix first AS2 view decorator test.merge-requests/132/head
rodzic
2db416c38d
commit
251f558428
|
@ -23,6 +23,7 @@ def activitypub_object_view(request, *args, **kwargs):
|
||||||
if not obj:
|
if not obj:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
return JsonResponse(obj.to_as2())
|
as2_obj = obj.as_protocol('activitypub')
|
||||||
|
return JsonResponse(as2_obj.to_as2())
|
||||||
return inner
|
return inner
|
||||||
return decorator
|
return decorator
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
|
@ -0,0 +1,10 @@
|
||||||
|
SECRET_KEY = "foobar"
|
||||||
|
|
||||||
|
INSTALLED_APPS = tuple()
|
||||||
|
|
||||||
|
FEDERATION = {
|
||||||
|
"base_url": "https://example.com",
|
||||||
|
"get_object_function": "federation.tests.django.utils.get_object_function",
|
||||||
|
"get_profile_function": "federation.tests.django.utils.get_profile",
|
||||||
|
"search_path": "/search?q=",
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
from federation.entities.base import Profile
|
||||||
|
|
||||||
|
|
||||||
|
def get_object_function(object_id):
|
||||||
|
return Profile(
|
||||||
|
url=f"https://example.com/profile/1234/",
|
||||||
|
atom_url=f"https://example.com/profile/1234/atom.xml",
|
||||||
|
id=f"https://example.com/profile/1234/",
|
||||||
|
handle="foobar@example.com",
|
||||||
|
guid="1234",
|
||||||
|
name="Bob Bobértson",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_profile(handle=None, request=None):
|
||||||
|
return Profile(
|
||||||
|
url=f"https://example.com/profile/1234/",
|
||||||
|
atom_url=f"https://example.com/profile/1234/atom.xml",
|
||||||
|
id=f"https://example.com/profile/1234/",
|
||||||
|
handle="foobar@example.com",
|
||||||
|
guid="1234",
|
||||||
|
)
|
|
@ -14,13 +14,6 @@ def dummy_view(request, *args, **kwargs):
|
||||||
|
|
||||||
class TestActivityPubObjectView:
|
class TestActivityPubObjectView:
|
||||||
def test_renders_as2(self):
|
def test_renders_as2(self):
|
||||||
entity = ActivitypubProfile(
|
|
||||||
raw_content="foobar", name="Bob Bobértson", public=True,
|
|
||||||
tag_list=["socialfederation", "federation"], image_urls={
|
|
||||||
"large": "urllarge", "medium": "urlmedium", "small": "urlsmall"
|
|
||||||
},
|
|
||||||
id="https://127.0.0.1",
|
|
||||||
)
|
|
||||||
# TODO test with real content type, but also json
|
# TODO test with real content type, but also json
|
||||||
request = RequestFactory().get("/", CONTENT_TYPE='application/json')
|
request = RequestFactory().get("/", CONTENT_TYPE='application/json')
|
||||||
response = dummy_view(request)(request=request)
|
response = dummy_view(request)(request=request)
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
SECRET_KEY = "foobar"
|
|
||||||
|
|
||||||
INSTALLED_APPS = tuple()
|
|
||||||
|
|
||||||
FEDERATION = {
|
|
||||||
"base_url": "https://example.com",
|
|
||||||
"get_profile_function": "federation.tests.hostmeta.django.utils.get_profile",
|
|
||||||
"search_path": "/search?q=",
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
from federation.entities.base import Profile
|
|
||||||
|
|
||||||
|
|
||||||
def get_profile(handle=None, request=None):
|
|
||||||
return Profile(
|
|
||||||
url=f"https://example.com/profile/1234/",
|
|
||||||
atom_url=f"https://example.com/profile/1234/atom.xml",
|
|
||||||
id=f"diaspora://{handle}/profile/1234",
|
|
||||||
handle=handle,
|
|
||||||
guid="1234",
|
|
||||||
)
|
|
|
@ -1,3 +1,3 @@
|
||||||
[pytest]
|
[pytest]
|
||||||
testpaths = federation
|
testpaths = federation
|
||||||
DJANGO_SETTINGS_MODULE = federation.tests.hostmeta.django.settings
|
DJANGO_SETTINGS_MODULE = federation.tests.django.settings
|
||||||
|
|
Ładowanie…
Reference in New Issue