diff --git a/src/palletjack/utils.py b/src/palletjack/utils.py index 524a587..abee553 100644 --- a/src/palletjack/utils.py +++ b/src/palletjack/utils.py @@ -380,9 +380,9 @@ def sedf_to_gdf(dataframe): gdf = gpd.GeoDataFrame(dataframe, geometry=dataframe.spatial.name) try: - gdf.set_crs(dataframe.spatial.sr["latestWkid"], inplace=True) + gdf.set_crs(dataframe.spatial.sr.latestWkid, inplace=True) except AttributeError: - gdf.set_crs(dataframe.spatial.sr["wkid"], inplace=True) + gdf.set_crs(dataframe.spatial.sr.wkid, inplace=True) return gdf diff --git a/tests/test_utils.py b/tests/test_utils.py index 55489a1..5eafe1e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -5,7 +5,6 @@ from pathlib import Path import numpy as np -import palletjack import pandas as pd import pyogrio import pytest @@ -13,6 +12,8 @@ from arcgis.features import FeatureLayer, Table from pandas import testing as tm +import palletjack + @pytest.fixture(scope="module") #: only call this once per module def iris(): @@ -1833,15 +1834,19 @@ def test_chunker(self): class TestSEDFtoGDF: def test_sedf_to_gdf_uses_wkid_when_missing_latestwkid(self, mocker): gdf_mock = mocker.patch("palletjack.utils.gpd.GeoDataFrame").return_value - df_attrs = {"spatial.sr": {"wkid": "foo"}} - df_mock = mocker.Mock(**df_attrs) + + df_mock = mocker.Mock() + df_mock.spatial.sr = mocker.Mock(spec=palletjack.utils.arcgis.geometry.SpatialReference) + df_mock.spatial.sr.wkid = "foo" palletjack.utils.sedf_to_gdf(df_mock) gdf_mock.set_crs.assert_called_with("foo", inplace=True) def test_sedf_to_gdf_uses_sedf_geometry_column(self, mocker): - mock_sedf = mocker.Mock(**{"spatial.name": "FOOSHAPE", "spatial.sr": {"wkid": "foo"}}) + mock_sedf = mocker.Mock(**{"spatial.name": "FOOSHAPE"}) # , "spatial.sr": {"wkid": "foo"}}) + mock_sedf.spatial.sr = mocker.Mock(spec=palletjack.utils.arcgis.geometry.SpatialReference) + mock_sedf.spatial.sr.wkid = "foo" gpd_mock = mocker.patch("palletjack.utils.gpd.GeoDataFrame") palletjack.utils.sedf_to_gdf(mock_sedf)