def nodeinfo2_view(request, *args, **kwargs): try: nodeinfo2_func = get_function_from_config("nodeinfo2_function") except AttributeError: return HttpResponseBadRequest("Not configured") nodeinfo2 = nodeinfo2_func() return JsonResponse(generate_nodeinfo2_document(**nodeinfo2))
def test_generate_with_minimum_data(self): data = { "server": { "baseUrl": "https://example.com", "name": "Example server", "software": "example", "version": "0.5.0" }, "openRegistrations": True, } expected = { "version": "1.0", "server": { "baseUrl": "https://example.com", "name": "Example server", "software": "example", "version": "0.5.0" }, "organization": { "account": None, "contact": None, "name": None, }, "protocols": ["diaspora"], "relay": "", "services": { "inbound": [], "outbound": [] }, "openRegistrations": True, "usage": { "users": { "total": None, "activeHalfyear": None, "activeMonth": None, "activeWeek": None, }, "localPosts": None, "localComments": None, } } assert generate_nodeinfo2_document(**data) == expected