-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #333 from lbl-anp/patch-flaky-tests
Skip NNDC/XCOM tests if databases are down
- Loading branch information
Showing
7 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,30 @@ | ||
"""Helpers for testing.""" | ||
from pathlib import Path | ||
import requests | ||
|
||
TESTS_PATH = Path(__file__).parent.absolute() | ||
REPO_PATH = TESTS_PATH.parent | ||
|
||
|
||
def database_is_up(url): | ||
"""Check whether an online database can be reached. | ||
Parameters | ||
---------- | ||
url : str | ||
URL to query. | ||
""" | ||
try: | ||
return requests.post(url).status_code == requests.codes.ok | ||
except requests.exceptions.ConnectionError: | ||
return False | ||
|
||
|
||
def nndc_is_up(): | ||
"""Check whether the NNDC databases can be reached.""" | ||
return database_is_up("https://www.nndc.bnl.gov/nudat3/indx_sigma.jsp") | ||
|
||
|
||
def xcom_is_up(): | ||
"""Check whether the NIST XCOM databases can be reached.""" | ||
return database_is_up("https://physics.nist.gov/PhysRefData/Xcom/html/xcom1.html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters