Skip to content

Commit

Permalink
fix: solve tests reproductivity issues (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau committed Jan 22, 2024
2 parents 4cfac99 + 19a74fc commit ff54bf9
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 13,049 deletions.
14 changes: 10 additions & 4 deletions tests/test_Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from urllib.request import urlretrieve

import ee
import numpy as np
import pytest

import geetools
Expand Down Expand Up @@ -224,14 +225,18 @@ def image_instance(self):
class TestToGrid:
"""Test the ``toGrid`` method."""

def test_to_grid(self, image_instance, vatican, data_regression):
def test_to_grid(self, image_instance, vatican, ndarrays_regression):
grid = image_instance.geetools.toGrid(1, "B2", vatican)
data_regression.check(grid.getInfo())
grid = [f["geometry"]["coordinates"] for f in grid.getInfo()["features"]]
grid = {f"geometry_{i}": np.array(c) for i, c in enumerate(grid)}
ndarrays_regression.check(grid)

def test_deprecated_method(self, image_instance, vatican, data_regression):
def test_deprecated_method(self, image_instance, vatican, ndarrays_regression):
with pytest.deprecated_call():
grid = geetools.tools.image.toGrid(image_instance, 1, "B2", vatican)
data_regression.check(grid.getInfo())
grid = [f["geometry"]["coordinates"] for f in grid.getInfo()["features"]]
grid = {f"geometry_{i}": np.array(c) for i, c in enumerate(grid)}
ndarrays_regression.check(grid)

@pytest.fixture
def image_instance(self):
Expand Down Expand Up @@ -823,6 +828,7 @@ class TestGetSTAC:

def test_get_stac(self, data_regression):
stac = ee.ImageCollection("COPERNICUS/S2_SR").first().geetools.getSTAC()
stac["extent"].pop("temporal") # it will change all the time
data_regression.check(stac)


Expand Down
Binary file added tests/test_Image/test_deprecated_method.npz
Binary file not shown.

0 comments on commit ff54bf9

Please sign in to comment.