Skip to content

Commit

Permalink
tests that require an active NSIDC Earthdata session (#209)
Browse files Browse the repository at this point in the history
* update and run tests that require an active NSIDC Earthdata session
* add flat data resource note
* NOTE: using the fixture to successfully start a session can be considered the test
* transition options to json for cleaner test file
  • Loading branch information
JessicaS11 authored Aug 25, 2021
1 parent 6cf5d8f commit 37b4da7
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 665 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ stages:
jobs:
include:
- stage: basic tests
script: pytest icepyx/ --ignore icepyx/tests/behind_NSIDC_API_login.py
script: pytest icepyx/ --ignore icepyx/tests/test_behind_NSIDC_API_login.py
after_success: codecov

# - stage: behind Earthdata
# script:
# - export NSIDC_LOGIN=$NSIDC_LOGIN
# - pytest icepyx/tests/behind_NSIDC_API_login.py
- stage: behind Earthdata
script:
- export NSIDC_LOGIN=$NSIDC_LOGIN
- pytest icepyx/tests/test_behind_NSIDC_API_login.py
10 changes: 10 additions & 0 deletions examples/ICESat-2_DAAC_DataAccess_Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"sys."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
1 change: 1 addition & 0 deletions icepyx/tests/ATL06v04_options.json

Large diffs are not rendered by default.

659 changes: 0 additions & 659 deletions icepyx/tests/behind_NSIDC_API_login.py

This file was deleted.

48 changes: 48 additions & 0 deletions icepyx/tests/test_behind_NSIDC_API_login.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import icepyx as ipx
import icepyx.core.Earthdata as Earthdata
import pytest
import warnings


# Misc notes and needed tests
# test avail data and subsetting success for each input type (kml, shp, list of coords, bbox)
# check that downloaded data is subset? or is this an NSIDC level test so long as we verify the right info is submitted?


@pytest.fixture
def reg(scope="module"):
return ipx.Query("ATL06", [-55, 68, -48, 71], ["2019-02-22", "2019-02-28"])


@pytest.fixture
def session(reg, scope="module"):
return Earthdata._start_session(
"icepyx_devteam", "icepyx.dev@gmail.com", os.getenv("NSIDC_LOGIN")
)


########## is2ref module ##########
import icepyx.core.is2ref as is2ref
import json


def test_get_custom_options_output(session):
obs = is2ref._get_custom_options(session, "ATL06", "004")
with open("./ATL06v04_options.json", "r") as exp:
assert all(keys in obs.keys() for keys in exp.keys())
assert all(obs[key] == exp[key] for key in exp.keys())


########## query module ##########
# NOTE: best this test can do at the moment is a successful download with no errors...
def test_download_granules_with_subsetting(reg, session):
path = "./downloads_subset"
reg.order_granules(session)
reg.download_granules(session, 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
7 changes: 6 additions & 1 deletion icepyx/tests/test_granules.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# def session(reg_a):
# return reg_a._start_earthdata_session('icepyx_devteam', 'icepyx.dev@gmail.com', os.getenv('NSIDC_LOGIN'))

# check that agent key is added in event of no subsetting


# DevNote: clearly there's a better way that doesn't make the function so long... what is it?
def test_granules_info():
Expand Down Expand Up @@ -595,7 +597,10 @@ def test_no_granules_in_search_results():

def test_correct_granule_list_returned():
reg_a = ipx.Query(
"ATL06", [-55, 68, -48, 71], ["2019-02-20", "2019-02-28"], version="3",
"ATL06",
[-55, 68, -48, 71],
["2019-02-20", "2019-02-28"],
version="3",
)

(obs_grans,) = reg_a.avail_granules(ids=True)
Expand Down
1 change: 1 addition & 0 deletions icepyx/tests/test_is2ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def test_bad_product():

########## about_product ##########
# Note: requires internet connection
# could the github flat data option be used here? https://octo.github.com/projects/flat-data
# def test_product_info():
# obs = is2ref.about_product('ATL06')
# print(obs)
Expand Down

0 comments on commit 37b4da7

Please sign in to comment.