From e6505a71a1227541f0dc097cc2fb28ef7a59dc5e Mon Sep 17 00:00:00 2001 From: "C.-W. HSU" <11950284+chiaweh2@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:53:56 -0700 Subject: [PATCH] add test in the cefi_portal directly pytest rely on regional mom6 is removed to keep the indepency of the portal test --- python/cefi_opendap_test.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 python/cefi_opendap_test.py diff --git a/python/cefi_opendap_test.py b/python/cefi_opendap_test.py new file mode 100644 index 0000000..a1a8dad --- /dev/null +++ b/python/cefi_opendap_test.py @@ -0,0 +1,31 @@ +""" +This script is designed to test the opendap +access + +""" +import os +import sys +import requests + + +CATALOG_HEAD = 'https://psl.noaa.gov/thredds/catalog/' +REGIONAL_MOM6_PATH = 'Projects/CEFI/regional_mom6' + +catalog_url = os.path.join( + CATALOG_HEAD, + REGIONAL_MOM6_PATH, + 'catalog.html' +) + +try: + html_response = requests.get(catalog_url, timeout=10) + + if html_response.status_code == 200: + print("Success: URL responded with status 200.") + sys.exit(0) # Exit with status 0 (success) + else: + print(f"Error: URL responded with status {html_response.status_code}.") + sys.exit(1) # Exit with status 1 (non-success) +except requests.exceptions.RequestException as e: + print(f"Error: Failed to connect to {catalog_url}. Exception: {e}") + sys.exit(2) # Exit with status 2 (connection failure)