Move test settings and utils for Django to tests root

Fix first AS2 view decorator test.
merge-requests/132/head
Jason Robinson 2018-09-29 12:12:34 +03:00
rodzic 2db416c38d
commit 251f558428
8 zmienionych plików z 37 dodań i 29 usunięć

Wyświetl plik

@ -23,6 +23,7 @@ def activitypub_object_view(request, *args, **kwargs):
if not obj:
raise Http404
return JsonResponse(obj.to_as2())
as2_obj = obj.as_protocol('activitypub')
return JsonResponse(as2_obj.to_as2())
return inner
return decorator

Wyświetl plik

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

Wyświetl plik

@ -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=",
}

Wyświetl plik

@ -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",
)

Wyświetl plik

@ -14,13 +14,6 @@ def dummy_view(request, *args, **kwargs):
class TestActivityPubObjectView:
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
request = RequestFactory().get("/", CONTENT_TYPE='application/json')
response = dummy_view(request)(request=request)

Wyświetl plik

@ -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=",
}

Wyświetl plik

@ -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",
)

Wyświetl plik

@ -1,3 +1,3 @@
[pytest]
testpaths = federation
DJANGO_SETTINGS_MODULE = federation.tests.hostmeta.django.settings
DJANGO_SETTINGS_MODULE = federation.tests.django.settings