funkwhale/api/tests/instance/test_preferences.py

37 wiersze
1017 B
Python
Czysty Zwykły widok Historia

import pytest
from django.urls import reverse
def test_can_list_settings_via_api(preferences, api_client):
2018-06-09 13:36:16 +00:00
url = reverse("api:v1:instance:settings")
all_preferences = preferences.model.objects.all()
expected_preferences = {
p.preference.identifier(): p
for p in all_preferences
2018-06-09 13:36:16 +00:00
if getattr(p.preference, "show_in_api", False)
}
assert len(expected_preferences) > 0
response = api_client.get(url)
assert response.status_code == 200
assert len(response.data) == len(expected_preferences)
for p in response.data:
2018-06-09 13:36:16 +00:00
i = "__".join([p["section"], p["name"]])
assert i in expected_preferences
2018-06-09 13:36:16 +00:00
@pytest.mark.parametrize(
"pref,value",
[
("instance__name", "My instance"),
("instance__short_description", "For music lovers"),
("instance__long_description", "For real music lovers"),
],
)
def test_instance_settings(pref, value, preferences):
preferences[pref] = value
assert preferences[pref] == value