Merge pull request #22969 from netbox-community/22925-make-moduletypetestcase-independent-of-migration-seeded-data

Closes #22925: Make ModuleTypeTestCase independent of migration-seeded data
This commit is contained in:
bctiemann 2026-08-20 13:14:41 -04:00 committed by GitHub
commit 24b700336e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 8 deletions

View File

@ -1248,13 +1248,13 @@ class ModuleTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
)
Manufacturer.objects.bulk_create(manufacturers)
profile = ModuleTypeProfile.objects.create(name='Module Type Profile 1', schema=cls.SCHEMA)
cls.profile = ModuleTypeProfile.objects.create(name='Module Type Profile 1', schema=cls.SCHEMA)
module_types = ModuleType.objects.bulk_create([
ModuleType(
model='Module Type 1',
manufacturer=manufacturers[0],
profile=profile,
profile=cls.profile,
attribute_data={'media': ['copper', 'qsfp28']},
),
ModuleType(model='Module Type 2', manufacturer=manufacturers[0]),
@ -1263,8 +1263,6 @@ class ModuleTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
tags = create_tags('Alpha', 'Bravo', 'Charlie')
fan_module_type_profile = ModuleTypeProfile.objects.get(name='Fan')
cls.form_data = {
'manufacturer': manufacturers[1].pk,
'model': 'Device Type X',
@ -1280,7 +1278,7 @@ class ModuleTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
cls.csv_data = (
"manufacturer,model,part_number,comments,profile",
f"Manufacturer 1,fan0,generic-fan,,{fan_module_type_profile.name}"
f"Manufacturer 1,Module Type 4,module-type-4,,{cls.profile.name}",
)
cls.csv_update_data = (
@ -1334,9 +1332,8 @@ class ModuleTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
def verify_module_type_profile(scenario_name):
# TODO: remove extra regression asserts once parent test supports testing all import fields
fan_module_type = ModuleType.objects.get(part_number='generic-fan')
fan_module_type_profile = ModuleTypeProfile.objects.get(name='Fan')
assert fan_module_type.profile == fan_module_type_profile
module_type = ModuleType.objects.get(part_number='module-type-4')
self.assertEqual(module_type.profile_id, self.profile.pk)
# run base test
super().test_bulk_import_objects_with_permission(post_import_callback=verify_module_type_profile)