@@ -521,7 +521,7 @@ def test_geometry_serializer_method_field(self):
521
521
self .assertEqual (response .status_code , 200 )
522
522
self .assertEqual (response .data ['properties' ]['name' ], 'hidden geometry' )
523
523
self .assertEqual (response .data ['geometry' ]['type' ], 'Point' )
524
- self .assertEqual (response .data ['geometry' ]['coordinates' ], ( 0.0 , 0.0 ) )
524
+ self .assertEqual (response .data ['geometry' ]['coordinates' ], [ 0.0 , 0.0 ] )
525
525
526
526
def test_geometry_serializer_method_field_none (self ):
527
527
location = Location .objects .create (name = 'None value' , geometry = 'POINT (135.0 45.0)' )
@@ -584,3 +584,57 @@ def test_pickle(self):
584
584
pickled = pickle .dumps (geojsondict )
585
585
restored = pickle .loads (pickled )
586
586
self .assertEqual (restored , geojsondict )
587
+
588
+ def test_geometrycollection_geojson (self ):
589
+ """ test geometry collection geojson behaviour """
590
+ location = Location .objects .create (name = 'geometry collection geojson test' ,
591
+ geometry = 'GEOMETRYCOLLECTION ('
592
+ 'POINT (135.0 45.0),'
593
+ 'LINESTRING (135.0 45.0,140.0 50.0,145.0 55.0),'
594
+ 'POLYGON ((135.0 45.0,140.0 50.0,145.0 55.0,135.0 45.0)))' )
595
+ url = reverse ('api_geojson_location_details' , args = [location .id ])
596
+ expected = {
597
+ 'id' : location .id ,
598
+ 'type' : 'Feature' ,
599
+ 'properties' : {
600
+ 'details' : "http://testserver/geojson/%s/" % location .id ,
601
+ 'name' : 'geometry collection geojson test' ,
602
+ 'fancy_name' : 'Kool geometry collection geojson test' ,
603
+ 'timestamp' : None ,
604
+ 'slug' : 'geometry-collection-geojson-test' ,
605
+ },
606
+ 'geometry' : {
607
+ 'type' : 'GeometryCollection' ,
608
+ 'geometries' : [
609
+ {
610
+ 'type' : 'Point' ,
611
+ 'coordinates' : [135.0 , 45.0 ]
612
+ },
613
+ {
614
+ 'type' : 'LineString' ,
615
+ 'coordinates' : [
616
+ [135.0 , 45.0 ],
617
+ [140.0 , 50.0 ],
618
+ [145.0 , 55.0 ]
619
+ ]
620
+ },
621
+ {
622
+ 'type' : 'Polygon' ,
623
+ 'coordinates' : [
624
+ [
625
+ [135.0 , 45.0 ],
626
+ [140.0 , 50.0 ],
627
+ [145.0 , 55.0 ],
628
+ [135.0 , 45.0 ],
629
+ ]
630
+ ]
631
+ },
632
+ ],
633
+ }
634
+ }
635
+ response = self .client .get (url )
636
+ if sys .version_info > (3 , 0 , 0 ):
637
+ self .assertCountEqual (json .dumps (response .data ), json .dumps (expected ))
638
+ else :
639
+ self .assertItemsEqual (json .dumps (response .data ), json .dumps (expected ))
640
+ self .assertContains (response , "Kool geometry collection geojson test" )
0 commit comments