|
8 | 8 | import json |
9 | 9 | import pickle |
10 | 10 |
|
| 11 | +from unittest import skipIf |
| 12 | + |
11 | 13 | from django.test import TestCase |
12 | 14 | from django.contrib.gis.geos import GEOSGeometry, Polygon, Point |
13 | 15 | try: |
|
16 | 18 | from django.core.urlresolvers import reverse |
17 | 19 | from django.core.exceptions import ImproperlyConfigured |
18 | 20 |
|
| 21 | +import rest_framework |
| 22 | + |
19 | 23 | from rest_framework_gis import serializers as gis_serializers |
20 | 24 | from rest_framework_gis.fields import GeoJsonDict |
21 | 25 |
|
22 | 26 | from .models import Location, LocatedFile |
23 | 27 | from .serializers import LocationGeoSerializer |
24 | 28 |
|
| 29 | +is_pre_drf_39 = not rest_framework.VERSION.startswith('3.9') |
| 30 | + |
25 | 31 |
|
26 | 32 | class TestRestFrameworkGis(TestCase): |
27 | 33 | def setUp(self): |
@@ -472,7 +478,16 @@ def test_post_geojson_location_list_HTML_web_form_WKT(self): |
472 | 478 | location = Location.objects.all()[0] |
473 | 479 | self.assertEqual(location.name, "HTML test WKT") |
474 | 480 |
|
| 481 | + @skipIf(is_pre_drf_39, 'Skip this test if DRF < 3.9') |
475 | 482 | def test_geojson_HTML_widget_value(self): |
| 483 | + self._create_locations() |
| 484 | + response = self.client.get(self.geojson_location_list_url, HTTP_ACCEPT='text/html') |
| 485 | + self.assertContains(response, '<textarea name="geometry"') |
| 486 | + self.assertContains(response, '"type": "Point"') |
| 487 | + self.assertContains(response, '"coordinates": [') |
| 488 | + |
| 489 | + @skipIf(not is_pre_drf_39, 'Skip this test if DRF >= 3.9') |
| 490 | + def test_geojson_HTML_widget_value_pre_drf_39(self): |
476 | 491 | self._create_locations() |
477 | 492 | response = self.client.get(self.geojson_location_list_url, HTTP_ACCEPT='text/html') |
478 | 493 | self.assertContains(response, '<textarea name="geometry"') |
|
0 commit comments