mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 23:28:26 +02:00
See #206: added API endpoint for managing settings
This commit is contained in:
parent
0dc9cdabab
commit
13c5219d71
4 changed files with 42 additions and 3 deletions
|
@ -21,3 +21,31 @@ def test_nodeinfo_endpoint_disabled(db, api_client, preferences):
|
|||
response = api_client.get(url)
|
||||
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
def test_settings_only_list_public_settings(db, api_client, preferences):
|
||||
url = reverse('api:v1:instance:settings')
|
||||
response = api_client.get(url)
|
||||
|
||||
for conf in response.data:
|
||||
p = preferences.model.objects.get(
|
||||
section=conf['section'], name=conf['name'])
|
||||
assert p.preference.show_in_api is True
|
||||
|
||||
|
||||
def test_admin_settings_restrict_access(db, logged_in_api_client, preferences):
|
||||
url = reverse('api:v1:instance:admin-settings-list')
|
||||
response = logged_in_api_client.get(url)
|
||||
|
||||
assert response.status_code == 403
|
||||
|
||||
|
||||
def test_admin_settings_correct_permission(
|
||||
db, logged_in_api_client, preferences):
|
||||
user = logged_in_api_client.user
|
||||
user.add_permission('change_globalpreferencemodel')
|
||||
url = reverse('api:v1:instance:admin-settings-list')
|
||||
response = logged_in_api_client.get(url)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert len(response.data) == len(preferences.all())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue