Skip to content

Commit

Permalink
Modernize the code for Django 4.2
Browse files Browse the repository at this point in the history
with the help of django-upgrade

https://github.com/adamchainz/django-upgrade
  • Loading branch information
ulgens committed Nov 2, 2024
1 parent 6a21de4 commit e17136b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
4 changes: 1 addition & 3 deletions tests/django_restframework_gis_tests/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from .models import Location


@admin.register(Location)
class LocationAdmin(GeoModelAdmin):
list_display = ('name', 'geometry')


admin.site.register(Location, LocationAdmin)
18 changes: 9 additions & 9 deletions tests/django_restframework_gis_tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_post_HTML_browsable_api(self):
),
}
response = self.client.post(
self.location_list_url, data, HTTP_ACCEPT='text/html'
self.location_list_url, data, headers={"accept": 'text/html'}
)
self.assertEqual(response.status_code, 201)
self.assertEqual(Location.objects.count(), 1)
Expand Down Expand Up @@ -289,7 +289,7 @@ def test_geojson_format(self):
self.assertCountEqual(json.dumps(response.data), json.dumps(expected))
else:
self.assertItemsEqual(json.dumps(response.data), json.dumps(expected))
response = self.client.get(url, HTTP_ACCEPT='text/html')
response = self.client.get(url, headers={"accept": 'text/html'})
self.assertContains(response, "Kool geojson test")

def test_geojson_id_attribute(self):
Expand Down Expand Up @@ -391,7 +391,7 @@ def test_post_geojson_location_list_HTML(self):
self.geojson_location_list_url,
data=json.dumps(data),
content_type='application/json',
HTTP_ACCEPT='text/html',
headers={"accept": 'text/html'},
)
self.assertEqual(response.status_code, 201)
self.assertEqual(Location.objects.count(), 1)
Expand Down Expand Up @@ -495,12 +495,12 @@ def test_geofeatured_model_post_as_multipartformdata(self):

def test_HTML_browsable_geojson_location_list(self):
response = self.client.get(
self.geojson_location_list_url, HTTP_ACCEPT='text/html'
self.geojson_location_list_url, headers={"accept": 'text/html'}
)
self.assertEqual(response.status_code, 200)
self._create_locations()
response = self.client.get(
self.geojson_location_list_url, HTTP_ACCEPT='text/html'
self.geojson_location_list_url, headers={"accept": 'text/html'}
)
self.assertContains(response, 'l1')
self.assertContains(response, 'l2')
Expand All @@ -512,7 +512,7 @@ def test_post_geojson_location_list_HTML_web_form(self):
"geometry": json.dumps({"type": "Point", "coordinates": [10.1, 10.1]}),
}
response = self.client.post(
self.geojson_location_list_url, data, HTTP_ACCEPT='text/html'
self.geojson_location_list_url, data, headers={"accept": 'text/html'}
)
self.assertEqual(response.status_code, 201)
self.assertEqual(Location.objects.count(), 1)
Expand All @@ -524,7 +524,7 @@ def test_post_geojson_location_list_HTML_web_form_WKT(self):
self.assertEqual(Location.objects.count(), 0)
data = {"name": "HTML test WKT", "geometry": "POINT (10.1 10.1)"}
response = self.client.post(
self.geojson_location_list_url, data, HTTP_ACCEPT='text/html'
self.geojson_location_list_url, data, headers={"accept": 'text/html'}
)
self.assertEqual(response.status_code, 201)
self.assertEqual(Location.objects.count(), 1)
Expand All @@ -535,7 +535,7 @@ def test_post_geojson_location_list_HTML_web_form_WKT(self):
def test_geojson_HTML_widget_value(self):
self._create_locations()
response = self.client.get(
self.geojson_location_list_url, HTTP_ACCEPT='text/html'
self.geojson_location_list_url, headers={"accept": 'text/html'}
)
self.assertContains(response, '<textarea name="geometry"')
self.assertContains(response, '"type": "Point"')
Expand All @@ -545,7 +545,7 @@ def test_geojson_HTML_widget_value(self):
def test_geojson_HTML_widget_value_pre_drf_39(self):
self._create_locations()
response = self.client.get(
self.geojson_location_list_url, HTTP_ACCEPT='text/html'
self.geojson_location_list_url, headers={"accept": 'text/html'}
)
self.assertContains(response, '<textarea name="geometry"')
self.assertContains(response, '&quot;type&quot;: &quot;Point&quot;')
Expand Down

0 comments on commit e17136b

Please sign in to comment.