From c023136440b029edd8dbe872ca67f72c8a660221 Mon Sep 17 00:00:00 2001 From: Gagan Deep Date: Wed, 7 Jun 2023 20:31:29 +0530 Subject: [PATCH] [fix] Fixed changing status of link from LinkAdmin #154 Closes #154 --- .../integrations/device/overrides.py | 4 ++++ .../integrations/device/tests.py | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/openwisp_network_topology/integrations/device/overrides.py b/openwisp_network_topology/integrations/device/overrides.py index 341dd4fe..b5f56038 100644 --- a/openwisp_network_topology/integrations/device/overrides.py +++ b/openwisp_network_topology/integrations/device/overrides.py @@ -60,6 +60,8 @@ def node_get_queryset(cls, qs): 'organization__is_active', 'label', 'addresses', + 'properties', + 'user_properties', 'devicenode__device__id', 'devicenode__device__name', 'devicenode__device__name', @@ -84,6 +86,8 @@ def link_get_queryset(cls, qs): 'organization__name', 'organization__is_active', 'status', + 'properties', + 'user_properties', 'cost', 'cost_text', 'source__addresses', diff --git a/openwisp_network_topology/integrations/device/tests.py b/openwisp_network_topology/integrations/device/tests.py index e8fbbfad..953313ff 100644 --- a/openwisp_network_topology/integrations/device/tests.py +++ b/openwisp_network_topology/integrations/device/tests.py @@ -493,3 +493,25 @@ def test_link_node_different_topology(self): link.full_clean() self.assertIn('source', context.exception.error_dict) self.assertIn('target', context.exception.error_dict) + + def test_link_update_status(self): + t = Topology.objects.first() + n1 = self._create_node(label='node1org1', topology=t) + n2 = self._create_node(label='node2org1', topology=t) + link = self._create_link(topology=t, source=n1, target=n2) + path = reverse('{0}_link_change'.format(self.prefix), args=[link.pk]) + response = self.client.post( + path, + data={ + 'topology': str(t.pk), + 'organization': str(t.organization_id), + 'source': str(n1.id), + 'target': str(n2.id), + 'cost': '1.0', + 'status': 'down', + }, + follow=True, + ) + self.assertEqual(response.status_code, 200) + link.refresh_from_db() + self.assertEqual(link.status, 'down')