Skip to content
Snippets Groups Projects

INFRA-10659: Implement self-healing mechanism for Netbox jobs

Merged Fahrudin Halilovic requested to merge feature/INFRA-10659-self-healing-mechanism into main
@@ -16,7 +16,6 @@ from netbox_awx_plugin.synchronization import (
sync_host_group_association,
disassociate_removed_groups,
)
from netbox_awx_plugin.synchronization import serializers, group_prefixes
from django.contrib.contenttypes.models import ContentType
@@ -60,6 +59,18 @@ class SynchronizationTestCase(TestCase):
self.device.primary_ip4 = self.ip_address
self.device.save()
# Patch 'get_current_job' to return a mock job
self.job_patcher = patch('netbox_awx_plugin.synchronization.get_current_job')
self.mock_get_current_job = self.job_patcher.start()
self.mock_job = Mock()
self.mock_job.meta = {}
self.mock_job.timeout = 180
self.mock_job.id = 'test-job-id'
self.mock_get_current_job.return_value = self.mock_job
def tearDown(self):
self.job_patcher.stop()
@patch('netbox_awx_plugin.models.AWXInventory.disassociate_host_group')
@patch('netbox_awx_plugin.models.AWXInventory.associate_host_group')
@patch('netbox_awx_plugin.models.AWXInventory.get_group')
@@ -190,7 +201,6 @@ class SynchronizationTestCase(TestCase):
@patch('netbox_awx_plugin.models.AWXInventory.get_group')
def test_sync_virtual_machine(self, mock_get_group, mock_associate_host_group, mock_get_host, mock_create_host):
# Create a role for the virtual machine
vm_content_type = ContentType.objects.get_for_model(VirtualMachine)
vm_role = DeviceRole.objects.create(
name='Web Server',
slug='web-server'
Loading