1- from geojson_pydantic .geometries import LineString , MultiLineString , MultiPoint , Point
1+ from geojson_pydantic .geometries import LineString , MultiLineString , MultiPoint , Point , Polygon
22from geojson_pydantic .types import Position , Position2D , Position3D
33
44from geojson_faker import GeoJsonFaker
@@ -101,7 +101,7 @@ def test_multi_point():
101101
102102 assert isinstance (multi_point , MultiPoint )
103103 assert multi_point .type == "MultiPoint"
104- assert 0 < len (multi_point .coordinates ) < 1000
104+ assert 0 < len (multi_point .coordinates ) <= 100
105105
106106 for coordinates in multi_point .coordinates :
107107 assert isinstance (coordinates , Position2D ) or isinstance (coordinates , Position3D )
@@ -117,7 +117,7 @@ def test_multi_point2d():
117117
118118 assert isinstance (multi_point , MultiPoint )
119119 assert multi_point .type == "MultiPoint"
120- assert 0 < len (multi_point .coordinates ) < 1000
120+ assert 0 < len (multi_point .coordinates ) <= 100
121121
122122 for coordinates in multi_point .coordinates :
123123 assert isinstance (coordinates , Position2D ) and not isinstance (coordinates , Position3D )
@@ -131,7 +131,7 @@ def test_multi_point3d():
131131
132132 assert isinstance (multi_point , MultiPoint )
133133 assert multi_point .type == "MultiPoint"
134- assert 0 < len (multi_point .coordinates ) < 1000
134+ assert 0 < len (multi_point .coordinates ) <= 100
135135
136136 for coordinates in multi_point .coordinates :
137137 assert isinstance (coordinates , Position3D ) and not isinstance (coordinates , Position2D )
@@ -146,7 +146,7 @@ def test_line_string():
146146
147147 assert isinstance (line_string , LineString )
148148 assert line_string .type == "LineString"
149- assert 2 < len (line_string .coordinates ) < 1000
149+ assert 2 <= len (line_string .coordinates ) <= 100
150150
151151 for coordinates in line_string .coordinates :
152152 assert isinstance (coordinates , Position2D ) or isinstance (coordinates , Position3D )
@@ -162,7 +162,7 @@ def test_line_string2d():
162162
163163 assert isinstance (line_string , LineString )
164164 assert line_string .type == "LineString"
165- assert 2 < len (line_string .coordinates ) < 1000
165+ assert 2 <= len (line_string .coordinates ) <= 100
166166
167167 for coordinates in line_string .coordinates :
168168 assert isinstance (coordinates , Position2D ) and not isinstance (coordinates , Position3D )
@@ -176,7 +176,7 @@ def test_line_string3d():
176176
177177 assert isinstance (line_string , LineString )
178178 assert line_string .type == "LineString"
179- assert 2 < len (line_string .coordinates ) < 1000
179+ assert 2 <= len (line_string .coordinates ) <= 100
180180
181181 for coordinates in line_string .coordinates :
182182 assert isinstance (coordinates , Position3D ) and not isinstance (coordinates , Position2D )
@@ -191,11 +191,11 @@ def test_multi_line_string():
191191
192192 assert isinstance (multi_line_string , MultiLineString )
193193 assert multi_line_string .type == "MultiLineString"
194- assert 0 < len (multi_line_string .coordinates ) < 1000
194+ assert 0 < len (multi_line_string .coordinates ) <= 100
195195
196196 for line_string in multi_line_string .coordinates :
197197 assert isinstance (line_string , list )
198- assert 2 < len (multi_line_string . coordinates ) < 1000
198+ assert 2 <= len (line_string ) <= 100
199199 for coordinates in line_string :
200200 assert isinstance (coordinates , Position2D ) or isinstance (coordinates , Position3D )
201201 assert isinstance (coordinates .longitude , float )
@@ -210,11 +210,11 @@ def test_multi_line_string2d():
210210
211211 assert isinstance (multi_line_string , MultiLineString )
212212 assert multi_line_string .type == "MultiLineString"
213- assert 0 < len (multi_line_string .coordinates ) < 1000
213+ assert 0 < len (multi_line_string .coordinates ) <= 100
214214
215215 for line_string in multi_line_string .coordinates :
216216 assert isinstance (line_string , list )
217- assert 2 < len (multi_line_string . coordinates ) < 1000
217+ assert 2 <= len (line_string ) <= 100
218218 for coordinates in line_string :
219219 assert isinstance (coordinates , Position2D ) and not isinstance (coordinates , Position3D )
220220 assert isinstance (coordinates .longitude , float )
@@ -227,13 +227,67 @@ def test_multi_line_string3d():
227227
228228 assert isinstance (multi_line_string , MultiLineString )
229229 assert multi_line_string .type == "MultiLineString"
230- assert 0 < len (multi_line_string .coordinates ) < 1000
230+ assert 0 < len (multi_line_string .coordinates ) <= 100
231231
232232 for line_string in multi_line_string .coordinates :
233233 assert isinstance (line_string , list )
234- assert 2 < len (multi_line_string . coordinates ) < 1000
234+ assert 2 <= len (line_string ) <= 100
235235 for coordinates in line_string :
236236 assert isinstance (coordinates , Position3D ) and not isinstance (coordinates , Position2D )
237237 assert isinstance (coordinates .longitude , float )
238238 assert isinstance (coordinates .latitude , float )
239239 assert isinstance (coordinates .altitude , float )
240+
241+
242+ def test_polygon ():
243+ geojson_faker = GeoJsonFaker ()
244+ polygon = geojson_faker .polygon
245+
246+ assert isinstance (polygon , Polygon )
247+ assert polygon .type == "Polygon"
248+ assert 0 < len (polygon .coordinates ) <= 100
249+
250+ for linear_ring in polygon .coordinates :
251+ assert isinstance (linear_ring , list )
252+ assert 4 <= len (linear_ring ) <= 100
253+ for coordinates in linear_ring :
254+ assert isinstance (coordinates , Position2D ) or isinstance (coordinates , Position3D )
255+ assert isinstance (coordinates .longitude , float )
256+ assert isinstance (coordinates .latitude , float )
257+ if isinstance (coordinates , Position3D ):
258+ assert isinstance (coordinates .altitude , float )
259+
260+
261+ def test_polygon2d ():
262+ geojson_faker = GeoJsonFaker ()
263+ polygon = geojson_faker .polygon2d
264+
265+ assert isinstance (polygon , Polygon )
266+ assert polygon .type == "Polygon"
267+ assert 0 < len (polygon .coordinates ) <= 100
268+
269+ for linear_ring in polygon .coordinates :
270+ assert isinstance (linear_ring , list )
271+ assert 4 <= len (linear_ring ) <= 100
272+ for coordinates in linear_ring :
273+ assert isinstance (coordinates , Position2D ) and not isinstance (coordinates , Position3D )
274+ assert isinstance (coordinates .longitude , float )
275+ assert isinstance (coordinates .latitude , float )
276+
277+
278+ def test_polygon3d ():
279+ geojson_faker = GeoJsonFaker ()
280+ polygon = geojson_faker .polygon3d
281+
282+ assert isinstance (polygon , Polygon )
283+ assert polygon .type == "Polygon"
284+ assert 0 < len (polygon .coordinates ) <= 100
285+
286+ for linear_ring in polygon .coordinates :
287+ assert isinstance (linear_ring , list )
288+ assert 4 <= len (linear_ring ) <= 100
289+ for coordinates in linear_ring :
290+ assert isinstance (coordinates , Position3D ) and not isinstance (coordinates , Position2D )
291+ assert isinstance (coordinates .longitude , float )
292+ assert isinstance (coordinates .latitude , float )
293+ assert isinstance (coordinates .altitude , float )
0 commit comments