| 1 |
From: Florent 'Skia' Jacquet <[email protected]> |
| 2 |
Date: Fri, 12 Dec 2025 18:18:03 +0100 |
| 3 |
Subject: [PATCH] tests/gis: don't rely on precise object IDs in database |
| 4 |
|
| 5 |
Objects IDs can change, and are generally very brittle. That made the |
| 6 |
tests to fail when run in Debian autopkgtest for whatever reason. |
| 7 |
Testing coverage isn't actually impacted by relaxing those particular |
| 8 |
asserts on the "location", given that the location is used thereafter to |
| 9 |
re-query and verify the created object. |
| 10 |
|
| 11 |
Forwarded: https://github.com/django-tastypie/django-tastypie/pull/1696 |
| 12 |
--- |
| 13 |
tests/gis/tests/views.py | 10 +++++----- |
| 14 |
1 file changed, 5 insertions(+), 5 deletions(-) |
| 15 |
|
| 16 |
diff --git a/tests/gis/tests/views.py b/tests/gis/tests/views.py |
| 17 |
index 8755386e6d3b..394681de4a6d 100644 |
| 18 |
--- a/tests/gis/tests/views.py |
| 19 |
+++ b/tests/gis/tests/views.py |
| 20 |
@@ -161,10 +161,10 @@ class MoreViewsTestCase(TestCaseWithFixture): |
| 21 |
self.assertEqual(response.status_code, 201) |
| 22 |
|
| 23 |
location = response['Location'] |
| 24 |
- self.assertTrue(location.endswith('/api/v1/geonotes/4/')) |
| 25 |
+ self.assertIn('/api/v1/geonotes/', location) |
| 26 |
|
| 27 |
# make sure posted object exists |
| 28 |
- response = self.client.get('/api/v1/geonotes/4/', HTTP_ACCEPT='application/json') |
| 29 |
+ response = self.client.get(location, HTTP_ACCEPT='application/json') |
| 30 |
|
| 31 |
self.assertEqual(response.status_code, 200) |
| 32 |
|
| 33 |
@@ -208,10 +208,10 @@ class MoreViewsTestCase(TestCaseWithFixture): |
| 34 |
self.assertEqual(response.status_code, 201) |
| 35 |
|
| 36 |
location = response['Location'] |
| 37 |
- self.assertTrue(location.endswith('/api/v1/geonotes/4/')) |
| 38 |
+ self.assertIn('/api/v1/geonotes/', location) |
| 39 |
|
| 40 |
# make sure posted object exists |
| 41 |
- response = self.client.get('/api/v1/geonotes/4/', HTTP_ACCEPT='application/json') |
| 42 |
+ response = self.client.get(location, HTTP_ACCEPT='application/json') |
| 43 |
|
| 44 |
self.assertEqual(response.status_code, 200) |
| 45 |
|
| 46 |
@@ -225,7 +225,7 @@ class MoreViewsTestCase(TestCaseWithFixture): |
| 47 |
self.assertEqual(obj['points'], {"coordinates": [[-122.475233, 37.768616999999999], [-122.470416, 37.767381999999998]], "type": "MultiPoint"}) |
| 48 |
|
| 49 |
# Or we can ask for XML |
| 50 |
- response = self.client.get('/api/v1/geonotes/4/', HTTP_ACCEPT='application/xml') |
| 51 |
+ response = self.client.get(location, HTTP_ACCEPT='application/xml') |
| 52 |
|
| 53 |
self.assertEqual(response.status_code, 200) |
| 54 |
data = response.content.decode('utf-8') |
| 55 |
-- |
| 56 |
2.51.0 |
| 57 |
|