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

Reinstate test_download_granules_without_subsetting #581

Merged
merged 15 commits into from
Sep 3, 2024
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
5 changes: 5 additions & 0 deletions icepyx/core/granules.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,11 @@
status = statuslist[0]
print("Initial status of your order request at NSIDC is: ", status)

# If status is already finished without going into pending/processing
if status.startswith("complete"):
loop_response = self.session.get(statusURL)
loop_root = ET.fromstring(loop_response.content)

Check warning on line 402 in icepyx/core/granules.py

View check run for this annotation

Codecov / codecov/patch

icepyx/core/granules.py#L401-L402

Added lines #L401 - L402 were not covered by tests

# Continue loop while request is still processing
while status == "pending" or status == "processing":
print(
Expand Down
47 changes: 42 additions & 5 deletions icepyx/tests/test_behind_NSIDC_API_login.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
Integration tests that require authentication to Earthdata login.
"""

import glob

Check warning on line 5 in icepyx/tests/test_behind_NSIDC_API_login.py

View check run for this annotation

Codecov / codecov/patch

icepyx/tests/test_behind_NSIDC_API_login.py#L5

Added line #L5 was not covered by tests
import json
import os

Expand Down Expand Up @@ -49,8 +54,40 @@
reg.download_granules(path)


# def test_download_granules_without_subsetting(reg_a, session):
# path = './downloads'
# reg_a.order_granules(session, subset=False)
# reg_a.download_granules(session, path)
# #check that the max extent of the downloaded granules isn't subsetted
def test_download_granules_without_subsetting(reg, session, capsys):

Check warning on line 57 in icepyx/tests/test_behind_NSIDC_API_login.py

View check run for this annotation

Codecov / codecov/patch

icepyx/tests/test_behind_NSIDC_API_login.py#L57

Added line #L57 was not covered by tests
"""
Test that granules can be ordered from NSIDC and downloaded with the `subset=False`
option.
"""
path = "./downloads"

Check warning on line 62 in icepyx/tests/test_behind_NSIDC_API_login.py

View check run for this annotation

Codecov / codecov/patch

icepyx/tests/test_behind_NSIDC_API_login.py#L62

Added line #L62 was not covered by tests

reg.order_granules(verbose=False, subset=False, email=False)
out, err = capsys.readouterr() # capture stdout and stderr
assert out.startswith(

Check warning on line 66 in icepyx/tests/test_behind_NSIDC_API_login.py

View check run for this annotation

Codecov / codecov/patch

icepyx/tests/test_behind_NSIDC_API_login.py#L64-L66

Added lines #L64 - L66 were not covered by tests
"Total number of data order requests is 1 for 3 granules.\n"
"Data request 1 of 1 is submitting to NSIDC\n"
)
assert err == ""

Check warning on line 70 in icepyx/tests/test_behind_NSIDC_API_login.py

View check run for this annotation

Codecov / codecov/patch

icepyx/tests/test_behind_NSIDC_API_login.py#L70

Added line #L70 was not covered by tests

assert reg.reqparams == {

Check warning on line 72 in icepyx/tests/test_behind_NSIDC_API_login.py

View check run for this annotation

Codecov / codecov/patch

icepyx/tests/test_behind_NSIDC_API_login.py#L72

Added line #L72 was not covered by tests
"client_string": "icepyx",
"include_meta": "Y",
"page_num": 0,
"page_size": 2000,
"request_mode": "async",
"short_name": "ATL06",
"version": "006",
}
assert len(reg.granules.orderIDs) == 2
assert int(reg.granules.orderIDs[0]) >= 5_000_000_000_000

Check warning on line 82 in icepyx/tests/test_behind_NSIDC_API_login.py

View check run for this annotation

Codecov / codecov/patch

icepyx/tests/test_behind_NSIDC_API_login.py#L81-L82

Added lines #L81 - L82 were not covered by tests

reg.download_granules(path=path)

Check warning on line 84 in icepyx/tests/test_behind_NSIDC_API_login.py

View check run for this annotation

Codecov / codecov/patch

icepyx/tests/test_behind_NSIDC_API_login.py#L84

Added line #L84 was not covered by tests
# check that there are the right number of files of the correct size
assert len(glob.glob(pathname=f"{path}/ATL06_201902*.iso.xml")) == 3
h5_paths = sorted(glob.glob(pathname=f"{path}/ATL06_201902*.h5"))
assert len(h5_paths) == 3

Check warning on line 88 in icepyx/tests/test_behind_NSIDC_API_login.py

View check run for this annotation

Codecov / codecov/patch

icepyx/tests/test_behind_NSIDC_API_login.py#L86-L88

Added lines #L86 - L88 were not covered by tests
assert [os.path.getsize(filename=p) for p in h5_paths] == [
53228429, # 50.8 MiB
65120027, # 62.1 MiB
49749227, # 47.4 MiB
]