Skip to content

Commit

Permalink
skipping tests if servers down
Browse files Browse the repository at this point in the history
  • Loading branch information
heikoklein committed Dec 13, 2023
1 parent 21c94fc commit 0b9ef10
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_AERONETTimeSeriesReader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
import urllib.request
import os

import pyaro
Expand All @@ -18,7 +19,18 @@ class TestAERONETTimeSeriesReader(unittest.TestCase):
"aeronetsun_testdata.csv",
)

def external_resource_available(self, url):
try:
req = urllib.request.Request(TEST_URL, method="HEAD")
resp = urllib.request.urlopen(req)
resp.url
return True
except:
return False

def test_dl_data_unzipped(self):
if not self.external_resource_available(TEST_URL):
self.skipTest(f"external resource not available: {TEST_URL}")
engine = pyaro.list_timeseries_engines()["aeronetsunreader"]
with engine.open(
TEST_URL,
Expand All @@ -33,6 +45,8 @@ def test_dl_data_unzipped(self):
self.assertEqual(len(ts.stations()), 4)

def test_dl_data_zipped(self):
if not self.external_resource_available(TEST_ZIP_URL):
self.skipTest(f"external resource not available: {TEST_ZIP_URL}")
engine = pyaro.list_timeseries_engines()["aeronetsunreader"]
with engine.open(
TEST_ZIP_URL,
Expand Down

0 comments on commit 0b9ef10

Please sign in to comment.