mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-10 19:27:05 +02:00
* Move Module & ModuleType models to a separate file * Add ModuleTypeProfile & related fields * Initial work on JSON schema validation * Add attributes property on ModuleType * Introduce MultipleOfValidator * Introduce JSONSchemaProperty * Enable dynamic form field rendering * Misc cleanup * Fix migration conflict * Ensure deterministic ordering of attriubte fields * Support choices & default values * Include module type attributes on module view * Enable modifying individual attributes via REST API * Enable filtering by attribute values * Add documentation & tests * Schema should be optional * Include attributes column for profiles * Profile is nullable * Include some initial profiles to be installed via migration * Fix migrations conflict * Fix filterset test * Misc cleanup * Fixes #19023: get_field_value() should respect null values in bound forms (#19024) * Skip filters which do not specify a JSON-serializable value * Fix handling of array item types * Fix initial data in schema field during bulk edit * Implement sanity checking for JSON schema definitions * Fall back to filtering by string value
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import json
|
||||
from decimal import Decimal
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
@@ -1305,6 +1306,79 @@ front-ports:
|
||||
self.assertEqual(response.get('Content-Type'), 'text/csv; charset=utf-8')
|
||||
|
||||
|
||||
class ModuleTypeProfileTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
|
||||
model = ModuleTypeProfile
|
||||
|
||||
SCHEMAS = [
|
||||
{
|
||||
"properties": {
|
||||
"foo": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"foo": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"foo": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
module_type_profiles = (
|
||||
ModuleTypeProfile(
|
||||
name='Module Type Profile 1',
|
||||
schema=cls.SCHEMAS[0]
|
||||
),
|
||||
ModuleTypeProfile(
|
||||
name='Module Type Profile 2',
|
||||
schema=cls.SCHEMAS[1]
|
||||
),
|
||||
ModuleTypeProfile(
|
||||
name='Module Type Profile 3',
|
||||
schema=cls.SCHEMAS[2]
|
||||
),
|
||||
)
|
||||
ModuleTypeProfile.objects.bulk_create(module_type_profiles)
|
||||
|
||||
tags = create_tags('Alpha', 'Bravo', 'Charlie')
|
||||
|
||||
cls.form_data = {
|
||||
'name': 'Module Type Profile X',
|
||||
'description': 'A new profile',
|
||||
'schema': json.dumps(cls.SCHEMAS[0]),
|
||||
'tags': [t.pk for t in tags],
|
||||
}
|
||||
|
||||
cls.csv_data = (
|
||||
"name,schema",
|
||||
f"Module Type Profile 4,{json.dumps(cls.SCHEMAS[0])}",
|
||||
f"Module Type Profile 5,{json.dumps(cls.SCHEMAS[1])}",
|
||||
f"Module Type Profile 6,{json.dumps(cls.SCHEMAS[2])}",
|
||||
)
|
||||
|
||||
cls.csv_update_data = (
|
||||
"id,description",
|
||||
f"{module_type_profiles[0].pk},New description",
|
||||
f"{module_type_profiles[1].pk},New description",
|
||||
f"{module_type_profiles[2].pk},New description",
|
||||
)
|
||||
|
||||
cls.bulk_edit_data = {
|
||||
'description': 'New description',
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# DeviceType components
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user