3
3
import xml .etree .ElementTree as ET
4
4
5
5
from django .urls import reverse
6
- from django .contrib .gis .geos import MultiPolygon , Polygon , Point , LineString
6
+ from django .contrib .gis .geos import MultiPolygon , Polygon , Point , LineString , GEOSGeometry
7
7
8
8
from rest_framework .test import APITestCase
9
9
from social_django .models import UserSocialAuth
@@ -228,10 +228,13 @@ def test_auto_user_field(self):
228
228
229
229
class TestAoIDetailAPIViews (APITestCase ):
230
230
def setUp (self ):
231
- self .m_polygon = MultiPolygon (
232
- Polygon (((0 , 0 ), (0 , 1 ), (1 , 1 ), (0 , 0 ))),
233
- Polygon (((1 , 1 ), (1 , 2 ), (2 , 2 ), (1 , 1 )))
234
- )
231
+ self .m_polygon = {
232
+ "type" : "MultiPolygon" ,
233
+ "coordinates" : [
234
+ [ [ [ 0.0 , 0.0 ], [ 0.0 , 1.0 ], [ 1.0 , 1.0 ], [ 0.0 , 0.0 ] ] ],
235
+ [ [ [ 1.0 , 1.0 ], [ 1.0 , 2.0 ], [ 2.0 , 2.0 ], [ 1.0 , 1.0 ] ] ]
236
+ ]
237
+ }
235
238
self .user = User .objects .create_user (
236
239
username = 'test_user' ,
237
240
@@ -245,14 +248,14 @@ def setUp(self):
245
248
self .aoi = AreaOfInterest .objects .create (
246
249
name = 'Best place in the world' ,
247
250
user = self .user ,
248
- geometry = self .m_polygon ,
251
+ geometry = GEOSGeometry ( f' { self .m_polygon } ' ) ,
249
252
filters = {
250
253
'editor' : 'Potlatch 2' ,
251
254
'harmful' : 'False' ,
252
255
'users' : 'test' ,
253
256
'uids' : '234,43' ,
254
257
'checked_by' : 'qa_user' ,
255
- 'geometry' : self .m_polygon . geojson
258
+ 'geometry' : self .m_polygon
256
259
},
257
260
)
258
261
self .m_polygon_2 = MultiPolygon (
@@ -290,7 +293,7 @@ def test_retrieve_detail_authenticated(self):
290
293
'users' : 'test' ,
291
294
'uids' : '234,43' ,
292
295
'checked_by' : 'qa_user' ,
293
- 'geometry' : self .m_polygon . geojson
296
+ 'geometry' : self .m_polygon
294
297
}
295
298
)
296
299
self .assertEqual (
0 commit comments