Added API endpoint for listing public instance settings

This commit is contained in:
Eliot Berriot 2018-02-17 21:21:08 +01:00
parent 0944ef2a07
commit 6152b3bb36
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
7 changed files with 69 additions and 1 deletions

View file

@ -0,0 +1,22 @@
from django.urls import reverse
from dynamic_preferences.api import serializers
def test_can_list_settings_via_api(preferences, api_client):
url = reverse('api:v1:instance:settings')
all_preferences = preferences.model.objects.all()
expected_preferences = {
p.preference.identifier(): p
for p in all_preferences
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:
i = '__'.join([p['section'], p['name']])
assert i in expected_preferences