Skip to content

Commit 210f54b

Browse files
Merge pull request #136 from developmentseed/resolveCircular
resolve circular deps between geometry and geometryCollection
2 parents d78b841 + f3a41be commit 210f54b

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

geojson_pydantic/geometries.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ def check_geometries(cls, geometries: List) -> List:
319319
Field(discriminator="type"),
320320
]
321321

322+
GeometryCollection.update_forward_refs()
323+
322324

323325
def parse_geometry_obj(obj: Any) -> Geometry:
324326
"""

tests/test_features.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ class GenericProperties(BaseModel):
7171
}
7272

7373

74+
@pytest.mark.parametrize(
75+
"obj",
76+
[
77+
FeatureCollection,
78+
Feature,
79+
],
80+
)
81+
def test_pydantic_schema(obj):
82+
"""Test schema for Pydantic Object."""
83+
assert obj.model_json_schema()
84+
85+
7486
def test_feature_collection_iteration():
7587
"""test if feature collection is iterable"""
7688
gc = FeatureCollection(

tests/test_geometries.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@
1818
)
1919

2020

21+
@pytest.mark.parametrize(
22+
"obj",
23+
[
24+
GeometryCollection,
25+
LineString,
26+
MultiLineString,
27+
MultiPoint,
28+
MultiPolygon,
29+
Point,
30+
Polygon,
31+
],
32+
)
33+
def test_pydantic_schema(obj):
34+
"""Test schema for Pydantic Object."""
35+
assert obj.model_json_schema()
36+
37+
2138
def assert_wkt_equivalence(geom: Union[Geometry, GeometryCollection]):
2239
"""Assert WKT equivalence with Shapely."""
2340
# Remove any trailing `.0` to match Shapely format

0 commit comments

Comments
 (0)