Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
uv cache clean
uv pip install --find-links https://girder.github.io/large_image_wheels GDAL pyproj
uv pip install -r pyproject.toml --extra all
uv pip install joblib
- name: Test import
run: |
uv run python -c "import geemap; print('geemap import successful')"
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
run: |
uv pip install --find-links https://girder.github.io/large_image_wheels gdal pyproj
uv pip install -r pyproject.toml --extra tests
uv pip install -r pyproject.toml --extra all
# For python > 3.12, make sure setuptools is installed.
uv pip install setuptools
- name: Test import
run: |
uv run python -c "import geemap; print('geemap import successful')"
Expand Down
68 changes: 67 additions & 1 deletion tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
import requests


try:
import joblib

JOBLIB_AVAILABLE = True
except ImportError:
JOBLIB_AVAILABLE = False


class CommonTest(unittest.TestCase):

# TODO: test_ee_export_image
Expand Down Expand Up @@ -598,7 +606,65 @@ def test_check_file_path(self):
# TODO: test_dynamic_world_s2
# TODO: test_download_ee_image
# TODO: test_download_ee_image_tiles
# TODO: test_download_ee_image_tiles_parallel

@unittest.skipIf(not JOBLIB_AVAILABLE, "joblib not available.")
@mock.patch.object(common, "download_ee_image")
def test_download_ee_image_tiles_parallel(self, mock_download_ee_image):
image_mock = mock.MagicMock(spec=ee.Image)
feature_mock = mock.MagicMock(spec=ee.Feature)
geom_mock = mock.MagicMock(spec=ee.Geometry)
feature_mock.geometry.return_value = geom_mock
fc_mock = mock.MagicMock(spec=ee.FeatureCollection)
fc_mock.size.return_value.getInfo.return_value = 2
fc_mock.toList.return_value.get.side_effect = [feature_mock, feature_mock]
fc_mock.aggregate_array.return_value.getInfo.return_value = ["1", "2"]

with tempfile.TemporaryDirectory() as tmpdir:
common.download_ee_image_tiles_parallel(
image_mock,
fc_mock,
out_dir=tmpdir,
column="id",
ee_init=False,
# Avoid separate process spawning.
job_args={"n_jobs": 1, "prefer": "threads"},
)
self.assertEqual(mock_download_ee_image.call_count, 2)
mock_download_ee_image.assert_any_call(
image_mock,
os.path.join(tmpdir, "1.tif"),
geom_mock,
None,
None,
None,
"near",
None,
True,
None,
None,
None,
None,
False,
None,
)
mock_download_ee_image.assert_any_call(
image_mock,
os.path.join(tmpdir, "2.tif"),
geom_mock,
None,
None,
None,
"near",
None,
True,
None,
None,
None,
None,
False,
None,
)

# TODO: test_download_ee_image_collection

def test_get_palette_colors(self):
Expand Down
Loading