-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor AOI to handle multiple polygons per AOI
- Loading branch information
Showing
3 changed files
with
186 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import pytest | ||
|
||
from te_schemas.aoi import AOI | ||
|
||
|
||
def test_valid_geojson_point(): | ||
geojson = {"type": "Point", "coordinates": [125.6, 10.1]} | ||
aoi = AOI(geojson) | ||
assert aoi.is_valid() # Assuming AOI class has an is_valid method | ||
|
||
|
||
def test_invalid_geojson(): | ||
geojson = {"type": "InvalidType", "coordinates": [125.6, 10.1]} | ||
with pytest.raises(ValueError): | ||
AOI(geojson) | ||
|
||
|
||
def test_geojson_missing_coordinates(): | ||
geojson = {"type": "Point"} | ||
with pytest.raises(ValueError): | ||
AOI(geojson) | ||
|
||
|
||
def test_geojson_with_properties(): | ||
geojson = { | ||
"type": "Feature", | ||
"geometry": {"type": "Point", "coordinates": [125.6, 10.1]}, | ||
"properties": {"name": "Dinagat Islands"}, | ||
} | ||
aoi = AOI(geojson) | ||
assert aoi.geojson["features"][0]["properties"]["name"] == "Dinagat Islands" | ||
|
||
|
||
def test_valid_geojson_polygon(): | ||
geojson = { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[[125.6, 10.1], [125.7, 10.1], [125.7, 10.2], [125.6, 10.2], [125.6, 10.1]] | ||
], | ||
} | ||
aoi = AOI(geojson) | ||
assert aoi.is_valid() | ||
|
||
|
||
def test_valid_geojson_featurecollection(): | ||
geojson = { | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"geometry": {"type": "Point", "coordinates": [125.6, 10.1]}, | ||
"properties": {"name": "Dinagat Islands"}, | ||
}, | ||
{ | ||
"type": "Feature", | ||
"geometry": { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[125.6, 10.1], | ||
[125.7, 10.1], | ||
[125.7, 10.2], | ||
[125.6, 10.2], | ||
[125.6, 10.1], | ||
] | ||
], | ||
}, | ||
"properties": {"name": "Polygon Feature"}, | ||
}, | ||
], | ||
} | ||
aoi = AOI(geojson) | ||
assert aoi.is_valid() |