mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-09-08 21:23:44 -05:00
Chore: reorganize api tests (#4935)
* Move permissions-related API tests * Move bulk-edit-related API tests * Move bulk-download-related API tests * Move uisettings-related API tests * Move remoteversion-related API tests * Move tasks API tests * Move object-related API tests * Move consumption-template-related API tests * Rename pared-down documents API test file Co-Authored-By: Trenton H <797416+stumpylog@users.noreply.github.com>
This commit is contained in:
65
src/documents/tests/test_api_uisettings.py
Normal file
65
src/documents/tests/test_api_uisettings.py
Normal file
@@ -0,0 +1,65 @@
|
||||
import json
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from rest_framework import status
|
||||
from rest_framework.test import APITestCase
|
||||
|
||||
from documents.tests.utils import DirectoriesMixin
|
||||
|
||||
|
||||
class TestApiUiSettings(DirectoriesMixin, APITestCase):
|
||||
ENDPOINT = "/api/ui_settings/"
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.test_user = User.objects.create_superuser(username="test")
|
||||
self.test_user.first_name = "Test"
|
||||
self.test_user.last_name = "User"
|
||||
self.test_user.save()
|
||||
self.client.force_authenticate(user=self.test_user)
|
||||
|
||||
def test_api_get_ui_settings(self):
|
||||
response = self.client.get(self.ENDPOINT, format="json")
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertDictEqual(
|
||||
response.data["user"],
|
||||
{
|
||||
"id": self.test_user.id,
|
||||
"username": self.test_user.username,
|
||||
"is_superuser": True,
|
||||
"groups": [],
|
||||
"first_name": self.test_user.first_name,
|
||||
"last_name": self.test_user.last_name,
|
||||
},
|
||||
)
|
||||
self.assertDictEqual(
|
||||
response.data["settings"],
|
||||
{
|
||||
"update_checking": {
|
||||
"backend_setting": "default",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
def test_api_set_ui_settings(self):
|
||||
settings = {
|
||||
"settings": {
|
||||
"dark_mode": {
|
||||
"enabled": True,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
response = self.client.post(
|
||||
self.ENDPOINT,
|
||||
json.dumps(settings),
|
||||
content_type="application/json",
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
ui_settings = self.test_user.ui_settings
|
||||
self.assertDictEqual(
|
||||
ui_settings.settings,
|
||||
settings["settings"],
|
||||
)
|
Reference in New Issue
Block a user