Skip to content

Commit

Permalink
Tweaks to improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
SolarDrew authored and Cadair committed Jan 23, 2024
1 parent 334a2e5 commit 71e2301
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 0 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ def pytest_configure(config):
# pre-cache the IERS file for astropy to prevent downloads
# which will cause errors with remote_data off
from astropy.utils.iers import IERS_Auto; IERS_Auto.open()

os.environ['DKIST_SKIP_UPDATE_SEARCH_VALUES'] = 'True'
os.environ['IS_TEST_ENV'] = 'True'
8 changes: 4 additions & 4 deletions dkist/utils/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ def get_api_response_location():
update_search_values = False
# Threshold age at which to refresh search values
max_age = dt.timedelta(days=7).total_seconds()
if not os.environ.get('DKIST_SKIP_UPDATE_SEARCH_VALUES'): #pragma: no cover
if not os.environ.get('DKIST_SKIP_UPDATE_SEARCH_VALUES'):
if not search_api_response.exists():
update_search_values = True
update_search_values = True #pragma: no cover
else:
last_modified = dt.datetime.fromtimestamp(search_api_response.stat().st_mtime)
now = dt.datetime.now()
file_age = (now - last_modified).total_seconds()
if file_age > max_age:
if file_age > max_age: #pragma: no cover
update_search_values = True

if update_search_values:
if update_search_values and not os.environ.get('IS_TEST_ENV'): #pragma: no cover
logging.info("Downloading valid search values")
data = urllib.request.urlopen('https://api.dkistdc.nso.edu/datasets/v1/searchValues')
with open(search_api_response, "w") as f:
Expand Down

0 comments on commit 71e2301

Please sign in to comment.