2018-05-07 20:09:03 +00:00
|
|
|
from django.urls import reverse
|
|
|
|
|
|
|
|
|
|
|
|
def test_nodeinfo_endpoint(db, api_client, mocker):
|
|
|
|
payload = {
|
|
|
|
'test': 'test'
|
|
|
|
}
|
|
|
|
mocked_nodeinfo = mocker.patch(
|
|
|
|
'funkwhale_api.instance.nodeinfo.get', return_value=payload)
|
2018-05-07 20:28:21 +00:00
|
|
|
url = reverse('api:v1:instance:nodeinfo-2.0')
|
2018-05-07 20:09:03 +00:00
|
|
|
response = api_client.get(url)
|
2018-05-07 21:29:07 +00:00
|
|
|
ct = 'application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8' # noqa
|
2018-05-07 20:09:03 +00:00
|
|
|
assert response.status_code == 200
|
2018-05-07 21:29:07 +00:00
|
|
|
assert response['Content-Type'] == ct
|
2018-05-07 20:09:03 +00:00
|
|
|
assert response.data == payload
|
|
|
|
|
|
|
|
|
|
|
|
def test_nodeinfo_endpoint_disabled(db, api_client, preferences):
|
|
|
|
preferences['instance__nodeinfo_enabled'] = False
|
2018-05-07 20:28:21 +00:00
|
|
|
url = reverse('api:v1:instance:nodeinfo-2.0')
|
2018-05-07 20:09:03 +00:00
|
|
|
response = api_client.get(url)
|
|
|
|
|
|
|
|
assert response.status_code == 404
|