mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 04:39:16 +02:00
Blacked the code
This commit is contained in:
parent
b6fc0051fa
commit
62ca3bd736
279 changed files with 8861 additions and 9527 deletions
|
@ -6,102 +6,76 @@ from funkwhale_api.instance import nodeinfo
|
|||
|
||||
|
||||
def test_nodeinfo_dump(preferences, mocker):
|
||||
preferences['instance__nodeinfo_stats_enabled'] = True
|
||||
preferences["instance__nodeinfo_stats_enabled"] = True
|
||||
stats = {
|
||||
'users': 1,
|
||||
'tracks': 2,
|
||||
'albums': 3,
|
||||
'artists': 4,
|
||||
'track_favorites': 5,
|
||||
'music_duration': 6,
|
||||
'listenings': 7,
|
||||
"users": 1,
|
||||
"tracks": 2,
|
||||
"albums": 3,
|
||||
"artists": 4,
|
||||
"track_favorites": 5,
|
||||
"music_duration": 6,
|
||||
"listenings": 7,
|
||||
}
|
||||
mocker.patch('funkwhale_api.instance.stats.get', return_value=stats)
|
||||
mocker.patch("funkwhale_api.instance.stats.get", return_value=stats)
|
||||
|
||||
expected = {
|
||||
'version': '2.0',
|
||||
'software': {
|
||||
'name': 'funkwhale',
|
||||
'version': funkwhale_api.__version__
|
||||
},
|
||||
'protocols': ['activitypub'],
|
||||
'services': {
|
||||
'inbound': [],
|
||||
'outbound': []
|
||||
},
|
||||
'openRegistrations': preferences['users__registration_enabled'],
|
||||
'usage': {
|
||||
'users': {
|
||||
'total': stats['users'],
|
||||
}
|
||||
},
|
||||
'metadata': {
|
||||
'private': preferences['instance__nodeinfo_private'],
|
||||
'shortDescription': preferences['instance__short_description'],
|
||||
'longDescription': preferences['instance__long_description'],
|
||||
'nodeName': preferences['instance__name'],
|
||||
'library': {
|
||||
'federationEnabled': preferences['federation__enabled'],
|
||||
'federationNeedsApproval': preferences['federation__music_needs_approval'],
|
||||
'anonymousCanListen': preferences['common__api_authentication_required'],
|
||||
'tracks': {
|
||||
'total': stats['tracks'],
|
||||
},
|
||||
'artists': {
|
||||
'total': stats['artists'],
|
||||
},
|
||||
'albums': {
|
||||
'total': stats['albums'],
|
||||
},
|
||||
'music': {
|
||||
'hours': stats['music_duration']
|
||||
},
|
||||
"version": "2.0",
|
||||
"software": {"name": "funkwhale", "version": funkwhale_api.__version__},
|
||||
"protocols": ["activitypub"],
|
||||
"services": {"inbound": [], "outbound": []},
|
||||
"openRegistrations": preferences["users__registration_enabled"],
|
||||
"usage": {"users": {"total": stats["users"]}},
|
||||
"metadata": {
|
||||
"private": preferences["instance__nodeinfo_private"],
|
||||
"shortDescription": preferences["instance__short_description"],
|
||||
"longDescription": preferences["instance__long_description"],
|
||||
"nodeName": preferences["instance__name"],
|
||||
"library": {
|
||||
"federationEnabled": preferences["federation__enabled"],
|
||||
"federationNeedsApproval": preferences[
|
||||
"federation__music_needs_approval"
|
||||
],
|
||||
"anonymousCanListen": preferences[
|
||||
"common__api_authentication_required"
|
||||
],
|
||||
"tracks": {"total": stats["tracks"]},
|
||||
"artists": {"total": stats["artists"]},
|
||||
"albums": {"total": stats["albums"]},
|
||||
"music": {"hours": stats["music_duration"]},
|
||||
},
|
||||
'usage': {
|
||||
'favorites': {
|
||||
'tracks': {
|
||||
'total': stats['track_favorites'],
|
||||
}
|
||||
},
|
||||
'listenings': {
|
||||
'total': stats['listenings']
|
||||
}
|
||||
}
|
||||
}
|
||||
"usage": {
|
||||
"favorites": {"tracks": {"total": stats["track_favorites"]}},
|
||||
"listenings": {"total": stats["listenings"]},
|
||||
},
|
||||
},
|
||||
}
|
||||
assert nodeinfo.get() == expected
|
||||
|
||||
|
||||
def test_nodeinfo_dump_stats_disabled(preferences, mocker):
|
||||
preferences['instance__nodeinfo_stats_enabled'] = False
|
||||
preferences["instance__nodeinfo_stats_enabled"] = False
|
||||
|
||||
expected = {
|
||||
'version': '2.0',
|
||||
'software': {
|
||||
'name': 'funkwhale',
|
||||
'version': funkwhale_api.__version__
|
||||
},
|
||||
'protocols': ['activitypub'],
|
||||
'services': {
|
||||
'inbound': [],
|
||||
'outbound': []
|
||||
},
|
||||
'openRegistrations': preferences['users__registration_enabled'],
|
||||
'usage': {
|
||||
'users': {
|
||||
'total': 0,
|
||||
}
|
||||
},
|
||||
'metadata': {
|
||||
'private': preferences['instance__nodeinfo_private'],
|
||||
'shortDescription': preferences['instance__short_description'],
|
||||
'longDescription': preferences['instance__long_description'],
|
||||
'nodeName': preferences['instance__name'],
|
||||
'library': {
|
||||
'federationEnabled': preferences['federation__enabled'],
|
||||
'federationNeedsApproval': preferences['federation__music_needs_approval'],
|
||||
'anonymousCanListen': preferences['common__api_authentication_required'],
|
||||
"version": "2.0",
|
||||
"software": {"name": "funkwhale", "version": funkwhale_api.__version__},
|
||||
"protocols": ["activitypub"],
|
||||
"services": {"inbound": [], "outbound": []},
|
||||
"openRegistrations": preferences["users__registration_enabled"],
|
||||
"usage": {"users": {"total": 0}},
|
||||
"metadata": {
|
||||
"private": preferences["instance__nodeinfo_private"],
|
||||
"shortDescription": preferences["instance__short_description"],
|
||||
"longDescription": preferences["instance__long_description"],
|
||||
"nodeName": preferences["instance__name"],
|
||||
"library": {
|
||||
"federationEnabled": preferences["federation__enabled"],
|
||||
"federationNeedsApproval": preferences[
|
||||
"federation__music_needs_approval"
|
||||
],
|
||||
"anonymousCanListen": preferences[
|
||||
"common__api_authentication_required"
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
assert nodeinfo.get() == expected
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue