Просмотр исходного кода

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

Closes #22925: Make ModuleTypeTestCase independent of migration-seeded data
bctiemann 1 день назад
Родитель
Сommit
24b700336e
1 измененных файлов с 5 добавлено и 8 удалено
  1. 5 8
      netbox/dcim/tests/test_views.py

+ 5 - 8
netbox/dcim/tests/test_views.py

@@ -1248,13 +1248,13 @@ class ModuleTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
         )
         )
         Manufacturer.objects.bulk_create(manufacturers)
         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([
         module_types = ModuleType.objects.bulk_create([
             ModuleType(
             ModuleType(
                 model='Module Type 1',
                 model='Module Type 1',
                 manufacturer=manufacturers[0],
                 manufacturer=manufacturers[0],
-                profile=profile,
+                profile=cls.profile,
                 attribute_data={'media': ['copper', 'qsfp28']},
                 attribute_data={'media': ['copper', 'qsfp28']},
             ),
             ),
             ModuleType(model='Module Type 2', manufacturer=manufacturers[0]),
             ModuleType(model='Module Type 2', manufacturer=manufacturers[0]),
@@ -1263,8 +1263,6 @@ class ModuleTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
 
 
         tags = create_tags('Alpha', 'Bravo', 'Charlie')
         tags = create_tags('Alpha', 'Bravo', 'Charlie')
 
 
-        fan_module_type_profile = ModuleTypeProfile.objects.get(name='Fan')
-
         cls.form_data = {
         cls.form_data = {
             'manufacturer': manufacturers[1].pk,
             'manufacturer': manufacturers[1].pk,
             'model': 'Device Type X',
             'model': 'Device Type X',
@@ -1280,7 +1278,7 @@ class ModuleTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
 
 
         cls.csv_data = (
         cls.csv_data = (
             "manufacturer,model,part_number,comments,profile",
             "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 = (
         cls.csv_update_data = (
@@ -1334,9 +1332,8 @@ class ModuleTypeTestCase(ViewTestCases.PrimaryObjectViewTestCase):
 
 
         def verify_module_type_profile(scenario_name):
         def verify_module_type_profile(scenario_name):
             # TODO: remove extra regression asserts once parent test supports testing all import fields
             # 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
         # run base test
         super().test_bulk_import_objects_with_permission(post_import_callback=verify_module_type_profile)
         super().test_bulk_import_objects_with_permission(post_import_callback=verify_module_type_profile)