Fixes #22569: Ensures that Script Run OpenAPI operation is present
Does two things: 1. Adds a regression test to ensure that the `extras_scripts_run` operation is always present in contrib/openapi.json. This has regressed at least once since original implementation, so I wanted to make sure we catch it quickly in the future. 2. Overrides the Django `CACHES` setting for the OpenAPISchemaTestCase, which contains the new test, so that caching of the schema is disabled. This caused problems by masking whether or not the regression test (and other existing tests) were failing/succeeding in response to changes or not.
This commit is contained in:
parent
5f06007e4c
commit
2d519ece58
|
|
@ -5,7 +5,7 @@ Refs: #20638
|
|||
"""
|
||||
import json
|
||||
|
||||
from django.test import SimpleTestCase, TestCase
|
||||
from django.test import SimpleTestCase, TestCase, override_settings
|
||||
|
||||
from core.api.schema import FixSerializedPKRelatedField, NetBoxAutoSchema
|
||||
from dcim.api.serializers import SiteSerializer
|
||||
|
|
@ -15,6 +15,11 @@ from netbox.api.fields import SerializedPKRelatedField
|
|||
from netbox.api.serializers import BulkOperationErrorSerializer
|
||||
|
||||
|
||||
@override_settings(CACHES={
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.dummy.DummyCache'
|
||||
}
|
||||
})
|
||||
class OpenAPISchemaTestCase(TestCase):
|
||||
"""Tests for OpenAPI schema generation."""
|
||||
|
||||
|
|
@ -331,6 +336,22 @@ class OpenAPISchemaTestCase(TestCase):
|
|||
with self.subTest(component=component, field=field):
|
||||
self.assertEqual(components[component]['properties'][field]['items']['type'], 'integer')
|
||||
|
||||
def test_script_run_operation_exists(self):
|
||||
"""
|
||||
Encodes presence of extras_scripts_run operation in schema as expected.
|
||||
|
||||
Refs: #22569
|
||||
"""
|
||||
paths = self.schema['paths']
|
||||
resource_path = paths['/api/extras/scripts/{id}/']
|
||||
self.assertIn('post', resource_path)
|
||||
|
||||
run_operation = resource_path['post']
|
||||
|
||||
self.assertEqual(run_operation['operationId'], 'extras_scripts_run')
|
||||
self.assertEqual(len(run_operation['responses']), 1)
|
||||
self.assertIn('200', run_operation['responses'])
|
||||
|
||||
|
||||
class WritableFieldRebuildTestCase(TestCase):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue