Repository: CS-SI/eodag

Issue:
progress bar and int id
If product id is an integer, it makes download progress bar crash:
```py
>>> from eodag import EODataAccessGateway                                                                                                                                                                                                    
>>> dag = EODataAccessGateway()                                                                                                                                                                                                              
>>> dag.set_preferred_provider("usgs")                                                                                                                                                                                                       
>>> prods, _ = dag.search(productType="SENTINEL_2A")
>>> prods[0].properties["id"]
18933649                                                                                                                                                                                                                                     
>>> prods[0].download()
                                                                                                                                                                                                                                             
Traceback (most recent call last):                                                                                                                                                                                                           
  File "<stdin>", line 1, in <module>                                                                                                                                                                                                        
  File "/home/sylvain/workspace/eodag/eodag/api/product/_product.py", line 286, in download                                                                                                                                                  
    progress_callback.refresh()
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/tqdm/std.py", line 1361, in refresh
    self.display()
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/tqdm/std.py", line 1509, in display
    self.sp(self.__str__() if msg is None else msg)
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/tqdm/std.py", line 1165, in __str__
    return self.format_meter(**self.format_dict)
  File "/home/sylvain/.virtualenvs/eodag-dev/lib/python3.8/site-packages/tqdm/std.py", line 475, in format_meter
    bool_prefix_colon_already = (prefix[-2:] == ": ")
TypeError: 'int' object is not subscriptable
```

It should be cast to `str` before set as progress bar prefix.

Discussion:
github-actions[bot]: ## Unit Test Results
    1 files   -     1      1 suites   - 1   4m 47s [:stopwatch:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "duration of all tests") - 6m 50s
268 tests +    1  265 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "passed tests") ±    0  2 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "skipped / disabled tests") ±0  1 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "failed tests") +1 
268 runs   - 266  265 [:heavy_check_mark:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "passed tests")  - 265  2 [:zzz:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "skipped / disabled tests")  - 2  1 [:x:](https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#the-symbols "failed tests") +1 

For more details on these failures, see [this check](https://github.com/CS-SI/eodag/runs/7520866179).

Results for commit e0e2c5a0. ± Comparison against base commit 0a782d7f.

[test-results]:data:application/gzip;base64,H4sIAEzo32IC/1XMQQ6DIBCF4asY1l2Aggy9TEOmQ0Kq0iCsmt69o7Zql//3kvcSIQ40i2ujLo2Yayx73Gv2JaaJswXLwFNZxraHX93miriSOegRnwvtEHwcvp8bUM4ps0iWXKfjc4n/y02Ox7VPh2uf/zCNYywcgiS1aLyUaIGkBXC9ca4j0/UayCrUSoOyQbw/wjNTowUBAAA=

github-actions[bot]: <strong></strong>

| File | Coverage |   |
| - | :-: | :-: |
| **All files** | `80%` | :white_check_mark: |
| eodag/api/product/\_product.py | `83%` | :white_check_mark: |
| tests/units/test\_eoproduct.py | `98%` | :white_check_mark: |

_Minimum allowed coverage is `70%`_

<p align="right">Generated by :monkey: cobertura-action against e0e2c5a00c78e0788965993e53648e71c414817f </p>

Patch:
diff --git a/eodag/api/product/_product.py b/eodag/api/product/_product.py
index 683870ba..45162a1f 100644
--- a/eodag/api/product/_product.py
+++ b/eodag/api/product/_product.py
@@ -282,7 +282,7 @@ class EOProduct(object):
             # update units as bar may have been previously used for extraction
             progress_callback.unit = "B"
             progress_callback.unit_scale = True
-        progress_callback.desc = self.properties.get("id", "")
+        progress_callback.desc = str(self.properties.get("id", ""))
         progress_callback.refresh()
 
         fs_path = self.downloader.download(


Test patch:
diff --git a/tests/units/test_eoproduct.py b/tests/units/test_eoproduct.py
index 7829c168..045edf0d 100644
--- a/tests/units/test_eoproduct.py
+++ b/tests/units/test_eoproduct.py
@@ -34,6 +34,7 @@ from tests.context import (
     EOProduct,
     HTTPDownload,
     NoDriver,
+    ProgressCallback,
     config,
 )
 from tests.utils import mock
@@ -44,6 +45,12 @@ class TestEOProduct(EODagTestCase):
 
     def setUp(self):
         super(TestEOProduct, self).setUp()
+        self.output_dir = tempfile.mkdtemp()
+
+    def tearDown(self):
+        super(TestEOProduct, self).tearDown()
+        if os.path.isdir(self.output_dir):
+            shutil.rmtree(self.output_dir)
 
     def test_eoproduct_search_intersection_geom(self):
         """EOProduct search_intersection attr must be it's geom when no bbox_or_intersect param given"""  # noqa
@@ -383,3 +390,26 @@ class TestEOProduct(EODagTestCase):
         finally:
             # Teardown (all the created files are within outputs_prefix)
             shutil.rmtree(output_dir)
+
+    def test_eoproduct_download_progress_bar(self):
+        """eoproduct.download must show a progress bar"""
+        product = self._dummy_downloadable_product()
+        product.properties["id"] = 12345
+        progress_callback = ProgressCallback()
+
+        # progress bar did not start
+        self.assertEqual(progress_callback.n, 0)
+
+        # extract=true would replace bar desc with extraction status
+        product.download(
+            progress_callback=progress_callback,
+            outputs_prefix=self.output_dir,
+            extract=False,
+        )
+
+        # should be product id cast to str
+        self.assertEqual(progress_callback.desc, "12345")
+
+        # progress bar finished
+        self.assertEqual(progress_callback.n, progress_callback.total)
+        self.assertGreater(progress_callback.total, 0)