mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Makes minor improvements to ui_settings API testing
This commit is contained in:
parent
b21edde1bc
commit
0613e3ab12
@ -1370,21 +1370,38 @@ class TestDocumentApiV2(DirectoriesMixin, APITestCase):
|
||||
test_user = User.objects.create_superuser(username="test")
|
||||
self.client.force_login(user=test_user)
|
||||
|
||||
response = self.client.get(f"/api/ui_settings/", format="json")
|
||||
response = self.client.get("/api/ui_settings/", format="json")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(
|
||||
self.assertDictEqual(
|
||||
response.data["settings"],
|
||||
[],
|
||||
{},
|
||||
)
|
||||
|
||||
UiSettings.objects.create(
|
||||
user=test_user,
|
||||
settings='{"dark_mode":[{"enabled":"true"}]}',
|
||||
settings = {
|
||||
"settings": {
|
||||
"dark_mode": {
|
||||
"enabled": True,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
response = self.client.post(
|
||||
"/api/ui_settings/",
|
||||
json.dumps(settings),
|
||||
content_type="application/json",
|
||||
)
|
||||
response = self.client.get(f"/api/ui_settings/", format="json")
|
||||
self.assertNotEqual(
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
response = self.client.get("/api/ui_settings/", format="json")
|
||||
|
||||
print(response)
|
||||
print(response.data)
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertDictEqual(
|
||||
response.data["settings"],
|
||||
"{}",
|
||||
settings["settings"],
|
||||
)
|
||||
|
||||
|
||||
|
@ -732,7 +732,7 @@ class UiSettingsView(GenericAPIView):
|
||||
displayname = user.username
|
||||
if user.first_name or user.last_name:
|
||||
displayname = " ".join([user.first_name, user.last_name])
|
||||
settings = []
|
||||
settings = {}
|
||||
if hasattr(user, "ui_settings"):
|
||||
settings = user.ui_settings.settings
|
||||
return Response(
|
||||
|
Loading…
x
Reference in New Issue
Block a user