From 7a42e5e896c1429c5e1a576abadf3d4f5fbd795a Mon Sep 17 00:00:00 2001 From: spwoodcock Date: Mon, 11 Dec 2023 10:01:12 +0000 Subject: [PATCH] test: add test for splitting with geojson dict aoi --- tests/test_splitter.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_splitter.py b/tests/test_splitter.py index c2c95db..bc42ec4 100644 --- a/tests/test_splitter.py +++ b/tests/test_splitter.py @@ -17,6 +17,7 @@ # """Test task splitting algorithms.""" +import json import logging from pathlib import Path from uuid import uuid4 @@ -51,13 +52,35 @@ def test_init_splitter_types(aoi_json): assert len(splitter.aoi) == 4 +def test_split_by_square_with_dict(aoi_json): + """Test divide by square from geojson dict types.""" + features = split_by_square( + aoi_json.get("features")[0], + meters=50, + ) + assert len(features.get("features")) == 54 + features = split_by_square( + aoi_json.get("features")[0].get("geometry"), + meters=50, + ) + assert len(features.get("features")) == 54 + + def test_split_by_square_with_str(aoi_json): """Test divide by square from geojson str and file.""" + # GeoJSON Dumps features = split_by_square( geojson.dumps(aoi_json.get("features")[0]), meters=50, ) assert len(features.get("features")) == 54 + # JSON Dumps + features = split_by_square( + json.dumps(aoi_json.get("features")[0].get("geometry")), + meters=50, + ) + assert len(features.get("features")) == 54 + # File features = split_by_square( "tests/testdata/kathmandu.geojson", meters=100,