Skip to content

Commit

Permalink
test: cli verbose level fix in tests (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunato authored Feb 22, 2022
1 parent 470aa49 commit d9f16f4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion eodag/api/product/metadata_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def convert_to_rounded_wkt(value):
@staticmethod
def convert_to_bounds_lists(input_geom):
if isinstance(input_geom, MultiPolygon):
geoms = [geom for geom in input_geom]
geoms = [geom for geom in input_geom.geoms]
# sort with larger one at first (stac-browser only plots first one)
geoms.sort(key=lambda x: x.area, reverse=True)
return [list(x.bounds[0:4]) for x in geoms]
Expand Down
7 changes: 7 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
download,
eodag,
search_crunch,
setup_logging,
)
from tests.units.test_core import TestCore
from tests.utils import mock, no_blanks
Expand All @@ -52,9 +53,15 @@ def user_conf(self, conf_file="user_conf.yml", content=b"key: to unused conf"):
yield conf_file

def setUp(self):
super(TestEodagCli, self).setUp()
self.runner = CliRunner()
self.faker = Faker()

def tearDown(self):
super(TestEodagCli, self).tearDown()
# Default logging: no logging but still displays progress bars
setup_logging(1)

def test_eodag_without_args(self):
"""Calling eodag without arguments should print help message"""
result = self.runner.invoke(eodag)
Expand Down
8 changes: 4 additions & 4 deletions tests/units/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def test_get_geometry_from_various_only_locations(self):
locations_config, locations=dict(country="FRA")
)
self.assertIsInstance(geom_france, MultiPolygon)
self.assertEqual(len(geom_france), 3) # France + Guyana + Corsica
self.assertEqual(len(geom_france.geoms), 3) # France + Guyana + Corsica

def test_get_geometry_from_various_locations_with_wrong_location_name_in_kwargs(
self,
Expand Down Expand Up @@ -437,7 +437,7 @@ def test_get_geometry_from_various_only_locations_regex(self):
locations_config, locations=dict(country="PA[A-Z]")
)
self.assertIsInstance(geom_regex_pa, MultiPolygon)
self.assertEqual(len(geom_regex_pa), 2)
self.assertEqual(len(geom_regex_pa.geoms), 2)

def test_get_geometry_from_various_locations_no_match_raises_error(self):
"""If the location search doesn't match any of the feature attribute a ValueError must be raised"""
Expand All @@ -461,7 +461,7 @@ def test_get_geometry_from_various_geometry_and_locations(self):
)
self.assertIsInstance(geom_combined, MultiPolygon)
# France + Guyana + Corsica + somewhere over Poland
self.assertEqual(len(geom_combined), 4)
self.assertEqual(len(geom_combined.geoms), 4)
geometry = {
"lonmin": 0,
"latmin": 50,
Expand All @@ -473,7 +473,7 @@ def test_get_geometry_from_various_geometry_and_locations(self):
)
self.assertIsInstance(geom_combined, MultiPolygon)
# The bounding box overlaps with France inland
self.assertEqual(len(geom_combined), 3)
self.assertEqual(len(geom_combined.geoms), 3)


class TestCoreSearch(unittest.TestCase):
Expand Down
6 changes: 3 additions & 3 deletions tests/units/test_safe_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def chunk():

with self.assertLogs(self.logger, logging.WARN) as cm:
# assertLogs fails if no warning is raised
self.logger.warn("Dummy warning")
self.logger.warning("Dummy warning")
self.awsd.check_manifest_file_list(product_path)

self.assertEqual(len(cm.output), 1)
Expand Down Expand Up @@ -128,7 +128,7 @@ def chunk():

with self.assertLogs(self.logger, logging.WARN) as cm:
# assertLogs fails if no warning is raised
self.logger.warn("Dummy warning")
self.logger.warning("Dummy warning")
self.awsd.check_manifest_file_list(product_path)

self.assertEqual(len(cm.output), 1)
Expand Down Expand Up @@ -172,7 +172,7 @@ def chunk():

with self.assertLogs(self.logger, logging.WARN) as cm:
# assertLogs fails if no warning is raised
self.logger.warn("Dummy warning")
self.logger.warning("Dummy warning")
self.awsd.check_manifest_file_list(product_path)

self.assertEqual(len(cm.output), 2)
Expand Down

0 comments on commit d9f16f4

Please sign in to comment.