From fecbb60c366a5161657ed6d93512175ac071cbdc Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 16 Jan 2020 10:47:45 -0500 Subject: [PATCH] Use assertHttpStatus() when evaluating HTTP response status --- netbox/ipam/tests/test_api.py | 3 +-- netbox/utilities/testing.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/netbox/ipam/tests/test_api.py b/netbox/ipam/tests/test_api.py index 4d16d3ad9..47b6e91ec 100644 --- a/netbox/ipam/tests/test_api.py +++ b/netbox/ipam/tests/test_api.py @@ -1009,8 +1009,7 @@ class VLANTest(APITestCase): url = reverse('ipam-api:vlan-detail', kwargs={'pk': self.vlan1.pk}) response = self.client.delete(url, **self.header) - # can't use assertHttpStatus here because we don't have response.data - self.assertEqual(response.status_code, 409) + self.assertHttpStatus(response, status.HTTP_409_CONFLICT) content = json.loads(response.content.decode('utf-8')) self.assertIn('detail', content) diff --git a/netbox/utilities/testing.py b/netbox/utilities/testing.py index 3d0bf1a05..b222e497c 100644 --- a/netbox/utilities/testing.py +++ b/netbox/utilities/testing.py @@ -20,7 +20,7 @@ class APITestCase(_APITestCase): """ err_message = "Expected HTTP status {}; received {}: {}" self.assertEqual(response.status_code, expected_status, err_message.format( - expected_status, response.status_code, response.data + expected_status, response.status_code, getattr(response, 'data', 'No data') ))