Added stats endpoint for domain
This commit is contained in:
parent
be388870a3
commit
032197da3f
5 changed files with 71 additions and 1 deletions
|
|
@ -77,3 +77,23 @@ def test_external_domains(factories, settings):
|
|||
settings.FEDERATION_HOSTNAME = d1.pk
|
||||
|
||||
assert list(models.Domain.objects.external()) == [d2]
|
||||
|
||||
|
||||
def test_domain_stats(factories):
|
||||
expected = {
|
||||
"actors": 0,
|
||||
"libraries": 0,
|
||||
"tracks": 0,
|
||||
"albums": 0,
|
||||
"uploads": 0,
|
||||
"artists": 0,
|
||||
"outbox_activities": 0,
|
||||
"received_library_follows": 0,
|
||||
"emitted_library_follows": 0,
|
||||
"media_total_size": 0,
|
||||
"media_downloaded_size": 0,
|
||||
}
|
||||
|
||||
domain = factories["federation.Domain"]()
|
||||
|
||||
assert domain.get_stats() == expected
|
||||
|
|
|
|||
|
|
@ -103,3 +103,14 @@ def test_domain_nodeinfo(factories, superuser_api_client, mocker):
|
|||
assert response.data == {"status": "ok", "payload": {"hello": "world"}}
|
||||
|
||||
update_domain_nodeinfo.assert_called_once_with(domain_name=domain.name)
|
||||
|
||||
|
||||
def test_domain_stats(factories, superuser_api_client, mocker):
|
||||
domain = factories["federation.Domain"]()
|
||||
get_stats = mocker.patch.object(
|
||||
domain.__class__, "get_stats", return_value={"hello": "world"}
|
||||
)
|
||||
url = reverse("api:v1:manage:federation:domains-stats", kwargs={"pk": domain.name})
|
||||
response = superuser_api_client.get(url)
|
||||
assert response.status_code == 200
|
||||
assert response.data == {"hello": "world"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue