mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-19 10:19:27 -05:00
Add basic tests for schema validation
This commit is contained in:
parent
fc4867a4c8
commit
38e45efdcf
27
src/documents/tests/test_api_schema.py
Normal file
27
src/documents/tests/test_api_schema.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
from django.core.management import call_command
|
||||||
|
from django.core.management.base import CommandError
|
||||||
|
from rest_framework import status
|
||||||
|
from rest_framework.test import APITestCase
|
||||||
|
|
||||||
|
|
||||||
|
class TestApiSchema(APITestCase):
|
||||||
|
ENDPOINT = "/api/schema/"
|
||||||
|
|
||||||
|
def test_valid_schema(self):
|
||||||
|
"""
|
||||||
|
Test that the schema is valid
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
call_command("spectacular", "--validate", "--fail-on-warn")
|
||||||
|
except CommandError as e:
|
||||||
|
self.fail(f"Schema validation failed: {e}")
|
||||||
|
|
||||||
|
def test_get_schema_endpoints(self):
|
||||||
|
"""
|
||||||
|
Test that the schema endpoints exist and return a 200 status code
|
||||||
|
"""
|
||||||
|
schema_response = self.client.get(self.ENDPOINT)
|
||||||
|
self.assertEqual(schema_response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
ui_response = self.client.get(self.ENDPOINT + "view/")
|
||||||
|
self.assertEqual(ui_response.status_code, status.HTTP_200_OK)
|
Loading…
x
Reference in New Issue
Block a user