Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from funkwhale_network import crawler
async def test_fetch(session, responses):
domain = "test.domain"
well_known_payload = {
"links": [
{
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.0",
"href": "https://test.domain/nodeinfo/2.0/",
}
]
}
payload = {"hello": "world"}
responses.get(
"https://test.domain/.well-known/nodeinfo", payload=well_known_payload
)
responses.get("https://test.domain/nodeinfo/2.0/", payload=payload)
result = await crawler.fetch(session, domain)
assert result == payload
def test_validate_data(populated_db):
payload = {
"version": "2.0",
"software": {"name": "funkwhale", "version": "0.18-dev+git.b575999e"},
"openRegistrations": False,
"usage": {"users": {"total": 78}},
"metadata": {
"private": False,
"nodeName": "Funkwhale 101",
"library": {
"federationEnabled": True,
"federationNeedsApproval": True,
"anonymousCanListen": True,
"tracks": {"total": 98552},
"artists": {"total": 9831},
"albums": {"total": 10872},
"music": {"hours": 7650.678055555555},
},
"usage": {
"favorites": {"tracks": {"total": 1683}},
"listenings": {"total": 50294},
},
},
}
expected = {
"software": {
"name": "funkwhale",
"version": {
"major": 0,
"minor": 18,
"patch": 0,
"prerelease": "dev",
"build": "git.b575999e",
},
},
"openRegistrations": False,
"usage": {"users": {"total": 78}},
"metadata": {
"private": False,
"nodeName": "Funkwhale 101",
"library": {"federationEnabled": True, "anonymousCanListen": True},
},
}
result = crawler.clean_nodeinfo(payload)
assert result.data == expected