Skip to content

Commit dff5149

Browse files
authored
[chores:fix] Fixed collection of metrics via hex UUID path
The recent change to url patterns introduced a regression. A similar fix to the same issue was done recently to OpenWISP Controller, the best solution is to reuse the same solution also in OpenWISP Monitoring.
1 parent 874aa15 commit dff5149

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

openwisp_monitoring/device/api/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
name="api_device_metric_list",
1717
),
1818
path(
19-
"api/v1/monitoring/device/<uuid:pk>/",
19+
# uuid_any is registered by openwisp-controller
20+
"api/v1/monitoring/device/<uuid_any:pk>/",
2021
views.device_metric,
2122
name="api_device_metric",
2223
),

openwisp_monitoring/device/tests/test_api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ def test_200_none(self):
180180
def test_200_create(self):
181181
self.create_test_data(no_resources=True)
182182

183+
def test_200_create_uuid_without_dashes(self):
184+
organization = self._create_org()
185+
device = self._create_device(organization=organization)
186+
data = {"type": "DeviceMonitoring", "interfaces": []}
187+
response = self._post_data(device.pk.hex, device.key, data)
188+
self.assertEqual(response.status_code, 200)
189+
183190
@patch("openwisp_monitoring.device.tasks.write_device_metrics.delay")
184191
def test_background_write(self, mocked_task):
185192
device = self._create_device(organization=self._create_org())

0 commit comments

Comments
 (0)