Skip to content

Commit

Permalink
[fix] Fixed changing status of link from LinkAdmin #154
Browse files Browse the repository at this point in the history
Closes #154
  • Loading branch information
pandafy committed Jun 7, 2023
1 parent f099bd3 commit c023136
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openwisp_network_topology/integrations/device/overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -84,6 +86,8 @@ def link_get_queryset(cls, qs):
'organization__name',
'organization__is_active',
'status',
'properties',
'user_properties',
'cost',
'cost_text',
'source__addresses',
Expand Down
22 changes: 22 additions & 0 deletions openwisp_network_topology/integrations/device/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

0 comments on commit c023136

Please sign in to comment.