Skip to content

Commit

Permalink
i.eodag: add testsuite (#1163)
Browse files Browse the repository at this point in the history
* Add test for module exit code

* Add searching/filtering tests

* Add ids_list.txt

* Add save footprint & geojson tests

* Add printing tests

* Update testsuite to use flexible tests

* Add skip to tests if connection to provider can not be established
(apply changes from code review)

* Add eodag to .github workflows

* Add proj-bin to apt.txt
  • Loading branch information
HamedElgizery authored Aug 22, 2024
1 parent 8f99872 commit 2f36e10
Show file tree
Hide file tree
Showing 5 changed files with 413 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/apt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ libpng-dev
libproj-dev
libreadline-dev
libzstd-dev
proj-bin
pdal
sqlite3
subversion
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/extra_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
scipy
eodag
pandas
scikit-learn
GDAL==${GDAL_VERSION}
Expand Down
14 changes: 5 additions & 9 deletions src/imagery/i.eodag/i.eodag.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@

import sys
import os
import pytz
import json
import re
from pathlib import Path
Expand Down Expand Up @@ -454,16 +453,13 @@ def normalize_time(datetime_str: str):
:return: Datetime converted to 'YYYY-MM-DDTHH:MM:SS'
:rtype: str
"""
# Remove microseconds
if datetime_str.find("Z") != -1:
datetime_str = datetime_str[: datetime_str.find("Z")]
normalized_datetime = datetime.fromisoformat(datetime_str)
if normalized_datetime.tzinfo is None:
normalized_datetime = normalized_datetime.replace(tzinfo=timezone.utc)
# Remove microseconds
normalized_datetime = normalized_datetime.replace(microsecond=0)
# Convert time to UTC
normalized_datetime = normalized_datetime.astimezone(pytz.utc)
# Remove timezone info
normalized_datetime = normalized_datetime.replace(tzinfo=None)
return normalized_datetime.isoformat()
return normalized_datetime.strftime("%Y-%m-%dT%H:%M:%S")
return normalized_datetime.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S")


def no_fallback_search(search_parameters, provider):
Expand Down
8 changes: 8 additions & 0 deletions src/imagery/i.eodag/testsuite/data/ids_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
S2B_MSIL2A_20240529T081609_N0510_R121_T37SED_20240529T105453
S2B_MSIL2A_20240529T081609_N0510_R121_T37TDE_20240529T124818



S2B_MSIL2A_20240529T081609_N0510_R121_T37SED_20240529T105453
S2B_MSIL2A_2 0240529T081609_N0510_R121_T37SED_20240529T105453
S2B_MSIL2A _20240526T080609_N0510_R078_T37SDD_20240526T094753
Loading

0 comments on commit 2f36e10

Please sign in to comment.