Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong orbit downloaded for manually passed date #44

Merged
merged 3 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
include:
- os: windows-latest
python-version: "3.10"
python-version: "3.12"
- os: macos-latest
python-version: "3.10"
python-version: "3.12"

steps:
- uses: actions/checkout@v2
Expand All @@ -25,7 +25,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install requests click python-dateutil sentinelsat>=1.0 pytest responses
python -m pip install requests click python-dateutil sentinelsat>=1.0 pytest
- name: Test with pytest
run: |
python -m pytest -v -W=error --doctest-modules --ignore=eof/__main__.py
python -m pytest -v --doctest-modules --ignore=eof/__main__.py
7 changes: 6 additions & 1 deletion eof/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,12 @@ def main(
orbit_dts, missions = None, None
elif date:
missions = [mission] if mission else ["S1A", "S1B"]
orbit_dts = [date] * len(missions)
orbit_dts = [parse(date)] * len(missions)
# Check they didn't pass a whole datetime
if all((dt.hour == 0 and dt.minute == 0) for dt in orbit_dts):
# If we only specify dates, make sure the whole thing is covered
# This means we should set the `hour` to be late in the day
orbit_dts = [dt.replace(hour=23) for dt in orbit_dts]
else:
# No command line args given: search current directory
orbit_dts, missions = find_scenes_to_download(
Expand Down
13 changes: 9 additions & 4 deletions eof/tests/test_eof.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from eof import download
from eof import download, products


def test_find_scenes_to_download(tmpdir):
Expand All @@ -29,7 +29,8 @@ def test_download_eofs_errors():
orbit_dates = [datetime.datetime(2018, 5, 2, 4, 30, 26)]
with pytest.raises(ValueError):
download.download_eofs(orbit_dates, missions=["BadMissionStr"])
# More missions for dates
# 1 date, 2 missions ->
# ValueError: missions arg must be same length as orbit_dts
with pytest.raises(ValueError):
download.download_eofs(orbit_dates, missions=["S1A", "S1B"])

Expand All @@ -44,6 +45,10 @@ def test_main_error_args():
download.main(search_path="/notreal", mission="S1A")


def test_mission(tmpdir):
def test_download_mission_date(tmpdir):
with tmpdir.as_cwd():
download.main(mission="S1A", date="20200101")
filenames = download.main(mission="S1A", date="20200101")
assert len(filenames) == 1
product = products.SentinelOrbit(filenames[0])
assert product.start_time < datetime.datetime(2020, 1, 1)
assert product.stop_time > datetime.datetime(2020, 1, 1, 23, 59)
Loading