Skip to content

Commit

Permalink
test: use a pytest fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau committed Feb 22, 2025
1 parent 6eff56d commit 7a5aa06
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
15 changes: 15 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,18 @@ def s2_class_image():
This image is located in Argentina and Chile (Patagonia).
"""
return ee.Image("COPERNICUS/S2_SR_HARMONIZED/20230120T142709_20230120T143451_T18GYT")


@pytest.fixture
def polygon_instance():
"""Return a defined polygon instance."""
return ee.Geometry.Polygon(
[
[
[-71.84476689765019, -42.81816243454466],
[-71.84476689765019, -42.897690198549135],
[-71.72391728827519, -42.897690198549135],
[-71.72391728827519, -42.81816243454466],
]
]
)
28 changes: 4 additions & 24 deletions tests/test_Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,27 +621,17 @@ def image(self):
class TestClassToBands:
"""Test the ``classToBands`` method."""

def test_class_to_bands(self, s2_class_image, ee_image_regression):
def test_class_to_bands(self, s2_class_image, polygon_instance, ee_image_regression):
"""Test the ``classToBands`` method."""
class_info = {"3": "shadow", "9": "clouds_high", "11": "snow"}
decoded = s2_class_image.geetools.classToBands(class_info, "SCL")
aoi = ee.Geometry.Polygon(
[
[
[-71.84476689765019, -42.81816243454466],
[-71.84476689765019, -42.897690198549135],
[-71.72391728827519, -42.897690198549135],
[-71.72391728827519, -42.81816243454466],
]
]
)
ee_image_regression.check(decoded, scale=10, region=aoi)
ee_image_regression.check(decoded, scale=10, region=polygon_instance)


class TestClassMask:
"""Test the ``classMask`` method."""

def test_class_mask(self, s2_class_image, ee_image_regression):
def test_class_mask(self, s2_class_image, polygon_instance, ee_image_regression):
"""Test the ``classMask`` method."""
class_info = {
"2": "dark",
Expand All @@ -652,17 +642,7 @@ def test_class_mask(self, s2_class_image, ee_image_regression):
"10": "cirrus",
}
decoded = s2_class_image.geetools.classMask(class_info, band="SCL")
aoi = ee.Geometry.Polygon(
[
[
[-71.84476689765019, -42.81816243454466],
[-71.84476689765019, -42.897690198549135],
[-71.72391728827519, -42.897690198549135],
[-71.72391728827519, -42.81816243454466],
]
]
)
ee_image_regression.check(decoded, scale=10, region=aoi)
ee_image_regression.check(decoded, scale=10, region=polygon_instance)


class TestPlot:
Expand Down

0 comments on commit 7a5aa06

Please sign in to comment.