Skip to content

Commit

Permalink
Fixed mysql tests and reenabled mysql tests in CI. (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsnider2195 authored Jan 22, 2025
1 parent 483d15d commit da62cc9
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 38 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ jobs:
- python-version: "3.11"
db-backend: "postgresql"
nautobot-version: "2.0.0"
# - python-version: "3.12"
# db-backend: "mysql"
# nautobot-version: "stable"
- python-version: "3.12"
db-backend: "mysql"
nautobot-version: "stable"
runs-on: "ubuntu-22.04"
env:
INVOKE_NAUTOBOT_DEVICE_LIFECYCLE_MGMT_PYTHON_VER: "${{ matrix.python-version }}"
Expand Down
1 change: 1 addition & 0 deletions changes/410.housekeeping
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed mysql tests and reenabled mysql tests in CI.
4 changes: 2 additions & 2 deletions nautobot_device_lifecycle_mgmt/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ def create_validated_softwares():
software=software_one,
start=date(2019, 1, 10),
)
validatedsoftwarelcm.device_types.set([device_type]) # pylint: disable=no-member
validatedsoftwarelcm.save()
validatedsoftwarelcm.device_types.set([device_type]) # pylint: disable=no-member
software_two = SoftwareLCM.objects.create(
device_platform=device_platform_ios,
version="20.0.0 MD",
Expand All @@ -159,8 +159,8 @@ def create_validated_softwares():
software=software_two,
start=date(2019, 1, 10),
)
validatedsoftwarelcm_two.device_types.set([device_type]) # pylint: disable=no-member
validatedsoftwarelcm_two.save()
validatedsoftwarelcm_two.device_types.set([device_type]) # pylint: disable=no-member

validated_items = (
software_one,
Expand Down
12 changes: 6 additions & 6 deletions nautobot_device_lifecycle_mgmt/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,35 +355,35 @@ def setUpTestData(cls): # pylint: disable=invalid-name
end=datetime.date(2025, 1, 8),
preferred=True,
)
validated_software.devices.set([device.pk for device in devices])
validated_software.save()
validated_software.devices.set([device.pk for device in devices])

validated_software = ValidatedSoftwareLCM(
software=softwares[1],
start=datetime.date(2018, 2, 23),
end=datetime.date(2019, 6, 12),
preferred=False,
)
validated_software.device_types.set([devicetype.pk for devicetype in devicetypes])
validated_software.save()
validated_software.device_types.set([devicetype.pk for devicetype in devicetypes])

validated_software = ValidatedSoftwareLCM(
software=softwares[1],
start=datetime.date(2019, 11, 19),
end=datetime.date(2030, 7, 30),
preferred=False,
)
validated_software.device_roles.set([devicerole.pk for devicerole in deviceroles])
validated_software.save()
validated_software.device_roles.set([devicerole.pk for devicerole in deviceroles])

ValidatedSoftwareLCM(
software=softwares[1],
start=datetime.date(2020, 10, 9),
end=datetime.date(2025, 1, 16),
preferred=False,
)
validated_software.inventory_items.set([inventoryitem.pk for inventoryitem in inventoryitems])
validated_software.save()
validated_software.inventory_items.set([inventoryitem.pk for inventoryitem in inventoryitems])

@skip("Not implemented")
def test_bulk_delete_objects(self):
Expand Down Expand Up @@ -647,8 +647,8 @@ def setUpTestData(cls): # pylint: disable=too-many-locals,invalid-name
image_file_checksum="78arfabd75b0fa2vzas1e7a7ac6faa3fc",
default_image=True,
)
software_image.inventory_items.set([inventoryitem.pk for inventoryitem in inventoryitems_arista])
software_image.save()
software_image.inventory_items.set([inventoryitem.pk for inventoryitem in inventoryitems_arista])

software_image = SoftwareImageLCM(
image_file_name="eos_4.25.7f.swi",
Expand All @@ -657,8 +657,8 @@ def setUpTestData(cls): # pylint: disable=too-many-locals,invalid-name
image_file_checksum="78arfabd75b0fa2vfas1e7a7ac6faa3fc",
default_image=True,
)
software_image.device_types.set([devicetype.pk for devicetype in devicetypes_arista])
software_image.save()
software_image.device_types.set([devicetype.pk for devicetype in devicetypes_arista])

@skip("Not implemented")
def test_bulk_delete_objects(self):
Expand Down
10 changes: 5 additions & 5 deletions nautobot_device_lifecycle_mgmt/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,26 +265,26 @@ def setUp(self):
end="2023-05-14",
preferred=True,
)
validated_software.device_types.set([device_type.pk])
validated_software.save()
validated_software.device_types.set([device_type.pk])

validated_software = ValidatedSoftwareLCM(
software=self.softwares[1],
start="2020-04-15",
end="2022-11-01",
preferred=False,
)
validated_software.device_types.set([device_type.pk])
validated_software.save()
validated_software.device_types.set([device_type.pk])

validated_software = ValidatedSoftwareLCM(
software=self.softwares[1],
start="2020-01-15",
end="2025-11-01",
preferred=False,
)
validated_software.device_roles.set([device_role_router.pk])
validated_software.save()
validated_software.device_roles.set([device_role_router.pk])

def test_q_one_start(self):
"""Test q filter to find single record based on start date."""
Expand Down Expand Up @@ -776,16 +776,16 @@ def setUp(self):
software=self.softwares[0],
default_image=False,
)
soft_image.device_types.set([devicetype_1.pk])
soft_image.save()
soft_image.device_types.set([devicetype_1.pk])

soft_image = SoftwareImageLCM(
image_file_name="eos4.25.m.swi",
software=self.softwares[1],
default_image=True,
)
soft_image.device_types.set([self.devicetype_2.pk])
soft_image.save()
soft_image.device_types.set([self.devicetype_2.pk])

def test_q_image_name(self):
"""Test q filter to find single record based on the image name."""
Expand Down
2 changes: 1 addition & 1 deletion nautobot_device_lifecycle_mgmt/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,10 @@ def setUp(self):
software=self.software_1,
default_image=False,
)
soft_image.save()
soft_image.device_types.set([self.devicetype_3.pk])
soft_image.inventory_items.set([self.inventoryitem_2.pk])
soft_image.object_tags.set([self.tag_2.pk])
soft_image.save()

def test_specifying_all_fields_w_device_type(self):
data = {
Expand Down
26 changes: 13 additions & 13 deletions nautobot_device_lifecycle_mgmt/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ def test_create_validatedsoftwarelcm_required_only(self):
software=self.software,
start=date(2019, 1, 10),
)
validatedsoftwarelcm.device_types.set([self.device_type_1])
validatedsoftwarelcm.save()
validatedsoftwarelcm.device_types.set([self.device_type_1])

self.assertEqual(validatedsoftwarelcm.software, self.software)
self.assertEqual(str(validatedsoftwarelcm.start), "2019-01-10")
Expand All @@ -216,8 +216,8 @@ def test_create_validatedsoftwarelcm_all(self):
end=date(2022, 11, 1),
preferred=False,
)
validatedsoftwarelcm.device_types.set([self.device_type_1])
validatedsoftwarelcm.save()
validatedsoftwarelcm.device_types.set([self.device_type_1])

self.assertEqual(validatedsoftwarelcm.software, self.software)
self.assertEqual(str(validatedsoftwarelcm.start), "2020-04-15")
Expand All @@ -233,17 +233,17 @@ def test_validatedsoftwarelcm_valid_property(self):
start=date(2020, 4, 15),
preferred=False,
)
validatedsoftwarelcm_start_only.device_types.set([self.device_type_1])
validatedsoftwarelcm_start_only.save()
validatedsoftwarelcm_start_only.device_types.set([self.device_type_1])

validatedsoftwarelcm_start_end = ValidatedSoftwareLCM(
software=self.software,
start=date(2020, 4, 15),
end=date(2022, 11, 1),
preferred=False,
)
validatedsoftwarelcm_start_end.device_types.set([self.device_type_2])
validatedsoftwarelcm_start_end.save()
validatedsoftwarelcm_start_end.device_types.set([self.device_type_2])

date_valid = date(2021, 6, 11)
date_before_valid_start = date(2018, 9, 26)
Expand Down Expand Up @@ -271,15 +271,15 @@ def test_get_for_object_device(self):
software=self.software,
start=date(2019, 1, 10),
)
validatedsoftwarelcm_1.devices.set([self.device_1])
validatedsoftwarelcm_1.save()
validatedsoftwarelcm_1.devices.set([self.device_1])

validatedsoftwarelcm_2 = ValidatedSoftwareLCM(
software=self.software,
start=date(2018, 1, 10),
)
validatedsoftwarelcm_2.devices.set([self.device_2])
validatedsoftwarelcm_2.save()
validatedsoftwarelcm_2.devices.set([self.device_2])

validated_software_for_device = ValidatedSoftwareLCM.objects.get_for_object(self.device_1)
self.assertEqual(validated_software_for_device.count(), 1)
Expand All @@ -290,15 +290,15 @@ def test_get_for_object_devicetype(self):
software=self.software,
start=date(2019, 1, 10),
)
validatedsoftwarelcm_1.device_types.set([self.device_type_1])
validatedsoftwarelcm_1.save()
validatedsoftwarelcm_1.device_types.set([self.device_type_1])

validatedsoftwarelcm_2 = ValidatedSoftwareLCM(
software=self.software,
start=date(2018, 1, 10),
)
validatedsoftwarelcm_2.device_types.set([self.device_type_2])
validatedsoftwarelcm_2.save()
validatedsoftwarelcm_2.device_types.set([self.device_type_2])

validated_software_for_device_type = ValidatedSoftwareLCM.objects.get_for_object(self.device_type_1)
self.assertEqual(validated_software_for_device_type.count(), 1)
Expand All @@ -309,15 +309,15 @@ def test_get_for_object_inventoryitem(self):
software=self.software,
start=date(2019, 1, 10),
)
validatedsoftwarelcm_1.inventory_items.set([self.inventoryitem_1])
validatedsoftwarelcm_1.save()
validatedsoftwarelcm_1.inventory_items.set([self.inventoryitem_1])

validatedsoftwarelcm_2 = ValidatedSoftwareLCM(
software=self.software,
start=date(2018, 1, 10),
)
validatedsoftwarelcm_2.inventory_items.set([self.inventoryitem_2])
validatedsoftwarelcm_2.save()
validatedsoftwarelcm_2.inventory_items.set([self.inventoryitem_2])

validated_software_for_inventoryitem = ValidatedSoftwareLCM.objects.get_for_object(self.inventoryitem_1)
self.assertEqual(validated_software_for_inventoryitem.count(), 1)
Expand Down Expand Up @@ -579,8 +579,8 @@ def setUp(self):
def test_create_softwareimage_required_only(self):
"""Successfully create SoftwareImageLCM with required fields only."""
softwareimage = SoftwareImageLCM(image_file_name="ios17.3.3md.img", software=self.software)
softwareimage.device_types.set([self.device_type_1])
softwareimage.save()
softwareimage.device_types.set([self.device_type_1])

self.assertEqual(softwareimage.image_file_name, "ios17.3.3md.img")
self.assertEqual(softwareimage.software, self.software)
Expand All @@ -595,10 +595,10 @@ def test_create_softwareimage_all(self):
image_file_checksum="441rfabd75b0512r7fde7a7a66faa596",
default_image=True,
)
softwareimage.save()
softwareimage.device_types.set([self.device_type_1])
softwareimage.inventory_items.set([self.inventory_item])
softwareimage.object_tags.set([self.tag])
softwareimage.save()

self.assertEqual(softwareimage.image_file_name, "ios17.3.3md.img")
self.assertEqual(softwareimage.software, self.software)
Expand All @@ -619,8 +619,8 @@ def test_get_software_images_for_device_type(self):
image_file_checksum="441rfabd75b0512r7fde7a7a66faa596",
default_image=False,
)
softwareimage.device_types.set([self.device_type_1])
softwareimage.save()
softwareimage.device_types.set([self.device_type_1])

self.assertEqual(list(self.device_type_1.software_images.all()), [softwareimage])

Expand Down
16 changes: 8 additions & 8 deletions nautobot_device_lifecycle_mgmt/tests/test_software_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ def setUp(self):
software=self.software,
default_image=False,
)
self.soft_image_ot.object_tags.set([self.tag_1.pk])
self.soft_image_ot.save()
self.soft_image_ot.object_tags.set([self.tag_1.pk])

self.soft_image_dt = SoftwareImageLCM(
image_file_name="eos4.25dt.swi",
software=self.software,
default_image=False,
)
self.soft_image_dt.device_types.set([self.devicetype_2.pk])
self.soft_image_dt.save()
self.soft_image_dt.device_types.set([self.devicetype_2.pk])

self.soft_image_def = SoftwareImageLCM(
image_file_name="eos4.25def.swi",
Expand All @@ -127,16 +127,16 @@ def setUp(self):
software=self.software,
default_image=False,
)
self.soft_image_ot_win.object_tags.set([self.tag_2.pk])
self.soft_image_ot_win.save()
self.soft_image_ot_win.object_tags.set([self.tag_2.pk])

self.soft_image_dt_lose = SoftwareImageLCM(
image_file_name="eos4.25dt_lose.swi",
software=self.software,
default_image=False,
)
self.soft_image_dt_lose.device_types.set([self.devicetype_3.pk])
self.soft_image_dt_lose.save()
self.soft_image_dt_lose.device_types.set([self.devicetype_3.pk])

def test_soft_image_for_device_match_tag(self):
software_image_qs = SoftwareImageLCM.objects.all()
Expand Down Expand Up @@ -241,16 +241,16 @@ def setUp(self):
software=self.software,
default_image=False,
)
self.soft_image_ot.object_tags.set([self.tag_1.pk])
self.soft_image_ot.save()
self.soft_image_ot.object_tags.set([self.tag_1.pk])

self.soft_image_invitem = SoftwareImageLCM(
image_file_name="eos4.25invitem.swi",
software=self.software,
default_image=False,
)
self.soft_image_invitem.inventory_items.set([self.inventoryitem_2.pk])
self.soft_image_invitem.save()
self.soft_image_invitem.inventory_items.set([self.inventoryitem_2.pk])

self.soft_image_def = SoftwareImageLCM(
image_file_name="eos4.25def.swi",
Expand All @@ -264,16 +264,16 @@ def setUp(self):
software=self.software,
default_image=False,
)
self.soft_image_ot_win.object_tags.set([self.tag_2.pk])
self.soft_image_ot_win.save()
self.soft_image_ot_win.object_tags.set([self.tag_2.pk])

self.soft_image_spec_assgmt_lose = SoftwareImageLCM(
image_file_name="eos4.25dt_lose.swi",
software=self.software,
default_image=False,
)
self.soft_image_spec_assgmt_lose.inventory_items.set([self.inventoryitem_4.pk])
self.soft_image_spec_assgmt_lose.save()
self.soft_image_spec_assgmt_lose.inventory_items.set([self.inventoryitem_4.pk])

def test_soft_image_for_invitem_match_tag(self):
software_image_qs = SoftwareImageLCM.objects.all()
Expand Down

0 comments on commit da62cc9

Please sign in to comment.