Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Fixed changing status of link from LinkAdmin #154 #198

Merged
merged 2 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to add user_properties too here?
I would do the same on node_get_queryset for consistency.

'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 @@ -489,3 +489,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')
Loading