Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #856 from dstansby/skip-helios
Browse files Browse the repository at this point in the history
Skip helios tests if website down
  • Loading branch information
dstansby authored Mar 7, 2020
2 parents 3c10d9c + 47a7bc2 commit 9804e43
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog/856.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated the url for downloading Helios 4Hz magnetic field data.
3 changes: 2 additions & 1 deletion heliopy/data/helios.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,8 @@ def local_dir(self, interval):
def download(self, interval):
remote_dir = ('E2_experiment/'
'Data_Cologne_Nov2016_bestdata/'
'HR/helios{}'.format(self.probe))
'HR%20-%20High%20Resolution%204Hz%20Data/'
f'helios{self.probe}')
remote_url = f'{remote_base_url}/{remote_dir}'

local_fname = self.fname(interval)
Expand Down
6 changes: 4 additions & 2 deletions heliopy/data/test/test_helios.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

import pytest

from .util import check_data_output
from .util import check_data_output, website_working

helios = pytest.importorskip('heliopy.data.helios')
pytest.mark.skipif(
not website_working('http://helios-data.ssl.berkeley.edu/data/'))
pytest.mark.data()

probe = '1'
Expand Down Expand Up @@ -50,7 +52,7 @@ def test_distribution_funcs():
local_dir = local_dir / 'helios1' / 'dist' / '1974' / '346'
local_dir.mkdir(parents=True, exist_ok=True)
remote_file = ('http://helios-data.ssl.berkeley.edu/data/E1_experiment'
'/helios_original/helios_1/1974/346/'
'/E1_original_data/helios_1/1974/346/'
'h1y74d346h03m27s21_hdm.1')
local_fname, _ = urllib.request.urlretrieve(
remote_file, './h1y74d346h03m27s21_hdm.1')
Expand Down
4 changes: 4 additions & 0 deletions heliopy/data/test/test_mms.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
probes = ['1', '4']


@pytest.mark.skip()
@pytest.mark.parametrize("probe", probes)
def test_fgm(probe):
df = mms.fgm(probe, 'srvy', starttime, endtime)
Expand All @@ -31,12 +32,15 @@ def test_fpi_des_moms(probe):
check_data_output(df)


# These tests take a *long* time to run, so comment them out
@pytest.mark.skip()
@pytest.mark.parametrize("probe", probes)
def test_fpi_dis_dist(probe):
df = mms.fpi_dis_dist(probe, 'fast', starttime, endtime)
check_data_output(df)


@pytest.mark.skip()
@pytest.mark.parametrize("probe", probes)
def test_fpi_des_dist(probe):
df = mms.fpi_des_dist(probe, 'fast', starttime, endtime)
Expand Down
9 changes: 7 additions & 2 deletions heliopy/data/test/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import astropy.units as u
import pandas as pd
import requests
import sunpy


Expand All @@ -9,7 +10,7 @@ def check_data_output(df):
'''
check_units(df)
if type(df) is sunpy.timeseries.timeseriesbase.GenericTimeSeries:
df = df.data
df = df.to_dataframe()
check_datetime_index(df)
assert df.shape[0] > 0
assert df.shape[1] > 0
Expand All @@ -25,5 +26,9 @@ def check_units(df):
warnings.warn("Function has no units attached", RuntimeWarning)
assert type(df.index[0]) == pd.Timestamp
else:
for column in df.data.columns:
for column in df.columns:
assert type(df.quantity(column)) == u.quantity.Quantity


def website_working(url):
return requests.get(url).status_code == 200

0 comments on commit 9804e43

Please sign in to comment.