From 5311f2930bbe27d73f7afe649dc37e9603205214 Mon Sep 17 00:00:00 2001 From: Pierrick Rambaud Date: Sun, 28 Jan 2024 17:52:49 +0100 Subject: [PATCH 1/7] fix: deprecate date last method --- tests/test_deprecated.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py index df3c38ac..fcc0dad6 100644 --- a/tests/test_deprecated.py +++ b/tests/test_deprecated.py @@ -1,5 +1,7 @@ """Test all the deprecated methods that have not been kept in the new implementation.""" +from datetime import datetime + import pytest import geetools @@ -15,3 +17,12 @@ def test_stretch_std(self): def test_stretch_percentile(self): with pytest.raises(NotImplementedError): geetools.visualization.stretch_percentile(None, None) + + +class TestDate: + """Test methods from the deprecated_date module.""" + + def test_millis_to_datetime(self): + with pytest.deprecated_call(): + date = geetools.date.millisToDatetime(1527804000000) + assert date == datetime.strptime("2018-06-01", "%Y-%m-%d") From 53143bb611154c018361db8ae73459dd90b443bc Mon Sep 17 00:00:00 2001 From: Pierrick Rambaud Date: Sun, 28 Jan 2024 18:01:10 +0100 Subject: [PATCH 2/7] fix: test the exception method --- tests/test_DateRange.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_DateRange.py b/tests/test_DateRange.py index e8db3917..68d39daf 100644 --- a/tests/test_DateRange.py +++ b/tests/test_DateRange.py @@ -43,3 +43,11 @@ def test_deprecated_alertnate_method(self, daterange_instance): assert list.size().getInfo() == 30 assert first.format("YYYY-MM-dd").getInfo() == "2020-01-01" assert last.format("YYYY-MM-dd").getInfo() == "2020-01-31" + + +class TestCheckUnit: + """Test the ``checkUnit`` method exception.""" + + def test_check_unit(self): + with pytest.raises(ValueError): + geetools.tools.date.checkUnit("toto") From 4602235a29f82ce076743e55b47b4d36e151d163 Mon Sep 17 00:00:00 2001 From: Pierrick Rambaud Date: Sun, 28 Jan 2024 18:10:40 +0100 Subject: [PATCH 3/7] fix: typo --- tests/test_DateRange.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_DateRange.py b/tests/test_DateRange.py index 68d39daf..6718ce98 100644 --- a/tests/test_DateRange.py +++ b/tests/test_DateRange.py @@ -50,4 +50,4 @@ class TestCheckUnit: def test_check_unit(self): with pytest.raises(ValueError): - geetools.tools.date.checkUnit("toto") + ee.DateRange.geetools.checkUnit("toto") From 7e5ddfadc31844b2fc7d374e06422aff512a16bc Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Sun, 28 Jan 2024 17:39:27 +0000 Subject: [PATCH 4/7] test: improve coverage of computed object --- tests/test_ComputedObect.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_ComputedObect.py b/tests/test_ComputedObect.py index ef177677..faab7fc8 100644 --- a/tests/test_ComputedObect.py +++ b/tests/test_ComputedObect.py @@ -89,6 +89,10 @@ def test_open(self, tmp_path): opened = ee.Number.open(file) assert object.eq(opened).getInfo() + def test_open_not_correct_suffix(self): + with pytest.raises(ValueError): + ee.Number.open("file.toto") + def test_deprecated_method(self, tmp_path): (object := ee.Number(1.1)).save((file := tmp_path / "test.gee")) with pytest.deprecated_call(): From 9dfe229ed54e56f97eec212a94cde7fe7601255c Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Sun, 28 Jan 2024 18:15:35 +0000 Subject: [PATCH 5/7] fix: typo in tested values --- tests/test_deprecated.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py index e83c0cbf..26e9cbc3 100644 --- a/tests/test_deprecated.py +++ b/tests/test_deprecated.py @@ -24,7 +24,7 @@ class TestDate: def test_millis_to_datetime(self): with pytest.deprecated_call(): - date = geetools.date.millisToDatetime(1527804000000) + date = geetools.date.millisToDatetime(1527811200000) assert date == datetime.strptime("2018-06-01", "%Y-%m-%d") From 6e95a0508f94ebac72d993fab52891e3c17f4b2c Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Sun, 28 Jan 2024 18:40:04 +0000 Subject: [PATCH 6/7] fix: wrong function tested --- tests/test_DateRange.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_DateRange.py b/tests/test_DateRange.py index 6718ce98..bbe6db77 100644 --- a/tests/test_DateRange.py +++ b/tests/test_DateRange.py @@ -46,8 +46,8 @@ def test_deprecated_alertnate_method(self, daterange_instance): class TestCheckUnit: - """Test the ``checkUnit`` method exception.""" + """Test the ``check_unit`` method exception.""" def test_check_unit(self): with pytest.raises(ValueError): - ee.DateRange.geetools.checkUnit("toto") + ee.DateRange.geetools.check_unit("toto") From be8d66297dac8cf29720646276c65cc41beeda86 Mon Sep 17 00:00:00 2001 From: Rambaud Pierrick <12rambau@users.noreply.github.com> Date: Sun, 28 Jan 2024 18:52:15 +0000 Subject: [PATCH 7/7] test: change the indices tested file --- tests/test_Image/test_default_spectral_indices.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_Image/test_default_spectral_indices.yml b/tests/test_Image/test_default_spectral_indices.yml index f6e27a59..6a718e17 100644 --- a/tests/test_Image/test_default_spectral_indices.yml +++ b/tests/test_Image/test_default_spectral_indices.yml @@ -208,7 +208,7 @@ WI2: -0.3508100169371153 WI2015: -108966.54196450702 WRI: 0.39238655381190113 WVP: 681.9462692210739 -kEVI: 0.754691564374628 +kEVI: 0.7546915643746379 kIPVI: 0.6366978189206153 kNDVI: 0.27339563784123116 kRVI: 2.04969719717336