@@ -40,7 +40,7 @@ def test_geom_from_geojson_success(geom_geojson,
4040 feature_geojson ,
4141 featurecollection_geojson ,
4242 assert_geom_equal ):
43- ggeo = geojson .as_geom (geom_geojson )
43+ ggeo = geojson .as_geom_or_ref (geom_geojson )
4444 assert_geom_equal (ggeo , geom_geojson )
4545
4646 fgeo = geojson .geom_from_geojson (feature_geojson )
@@ -51,85 +51,89 @@ def test_geom_from_geojson_success(geom_geojson,
5151
5252
5353def test_geom_from_geojson_no_geometry (feature_geojson ):
54- feature_geojson .pop (' geometry' )
54+ feature_geojson .pop (" geometry" )
5555 with pytest .raises (exceptions .GeoJSONError ):
5656 _ = geojson .geom_from_geojson (feature_geojson )
5757
5858
5959def test_geom_from_geojson_missing_coordinates (geom_geojson ):
60- geom_geojson .pop (' coordinates' )
60+ geom_geojson .pop (" coordinates" )
6161 with pytest .raises (exceptions .GeoJSONError ):
6262 _ = geojson .geom_from_geojson (geom_geojson )
6363
6464
6565def test_geom_from_geojson_missing_type (geom_geojson ):
66- geom_geojson .pop (' type' )
66+ geom_geojson .pop (" type" )
6767 with pytest .raises (exceptions .GeoJSONError ):
6868 _ = geojson .geom_from_geojson (geom_geojson )
6969
7070
7171def test_geom_from_geojson_multiple_features (featurecollection_geojson ):
7272 # duplicate the feature
7373 featurecollection_geojson [
74- ' features' ] = 2 * featurecollection_geojson [' features' ]
74+ " features" ] = 2 * featurecollection_geojson [" features" ]
7575 with pytest .raises (geojson .GeoJSONError ):
7676 _ = geojson .geom_from_geojson (featurecollection_geojson )
7777
7878
79- def test_validate_geom_invalid_type (geom_geojson ):
80- geom_geojson [' type' ] = ' invalid'
79+ def test_validate_geom_as_geojson_invalid_type (geom_geojson ):
80+ geom_geojson [" type" ] = " invalid"
8181 with pytest .raises (exceptions .GeoJSONError ):
82- _ = geojson .validate_geom (geom_geojson )
82+ _ = geojson .validate_geom_as_geojson (geom_geojson )
8383
8484
85- def test_validate_geom_wrong_type (geom_geojson ):
86- geom_geojson [' type' ] = ' point'
85+ def test_validate_geom_as_geojson_wrong_type (geom_geojson ):
86+ geom_geojson [" type" ] = " point"
8787 with pytest .raises (exceptions .GeoJSONError ):
88- _ = geojson .validate_geom (geom_geojson )
88+ _ = geojson .validate_geom_as_geojson (geom_geojson )
8989
9090
91- def test_validate_geom_invalid_coordinates (geom_geojson ):
92- geom_geojson [' coordinates' ] = ' invalid'
91+ def test_validate_geom_as_geojson_invalid_coordinates (geom_geojson ):
92+ geom_geojson [" coordinates" ] = " invalid"
9393 with pytest .raises (exceptions .GeoJSONError ):
94- _ = geojson .validate_geom (geom_geojson )
94+ _ = geojson .validate_geom_as_geojson (geom_geojson )
9595
9696
97- def test_validate_geom_empty_coordinates (geom_geojson ):
98- geom_geojson [' coordinates' ] = []
99- _ = geojson .validate_geom (geom_geojson )
97+ def test_validate_geom_as_geojson_empty_coordinates (geom_geojson ):
98+ geom_geojson [" coordinates" ] = []
99+ _ = geojson .validate_geom_as_geojson (geom_geojson )
100100
101101
102- def test_as_geom (geom_geojson ):
103- assert geojson .as_geom (geom_geojson ) == geom_geojson
102+ def test_as_geom_or_ref (geom_geojson ):
103+ assert geojson .as_geom_or_ref (geom_geojson ) == geom_geojson
104104
105105
106106def test_as_polygon (geom_geojson ):
107107 assert geojson .as_polygon (geom_geojson ) == geom_geojson
108108
109109
110+ def test_as_reference (geom_reference ):
111+ assert geojson .as_ref (geom_reference ) == geom_reference
112+
113+
110114def test_as_polygon_wrong_type (point_geom_geojson ):
111115 with pytest .raises (exceptions .GeoJSONError ):
112116 _ = geojson .as_polygon (point_geom_geojson )
113117
114118
115119def test_as_featurecollection_success (feature_geojson ):
116120 feature2 = feature_geojson .copy ()
117- feature2 [' properties' ] = {' foo' : ' bar' }
121+ feature2 [" properties" ] = {" foo" : " bar" }
118122 values = [feature_geojson , feature2 ]
119123 res = geojson .as_featurecollection (values )
120124
121- expected = {' type' : ' FeatureCollection' , ' features' : values }
125+ expected = {" type" : " FeatureCollection" , " features" : values }
122126 assert res == expected
123127
124128
125129def test__is_instance_of_success (feature_geojson ):
126- assert geojson ._is_instance_of (feature_geojson , ' Feature' )
130+ assert geojson ._is_instance_of (feature_geojson , " Feature" )
127131
128132 feature2 = feature_geojson .copy ()
129- feature2 [' properties' ] = {' foo' : ' bar' }
130- assert geojson ._is_instance_of (feature2 , ' Feature' )
133+ feature2 [" properties" ] = {" foo" : " bar" }
134+ assert geojson ._is_instance_of (feature2 , " Feature" )
131135
132136
133137def test__is_instance_of_does_not_exist (feature_geojson ):
134138 with pytest .raises (exceptions .GeoJSONError ):
135- geojson ._is_instance_of (feature_geojson , ' Foobar' )
139+ geojson ._is_instance_of (feature_geojson , " Foobar" )
0 commit comments