From 0cf519e84ecf38718553929d61a101d14a23f810 Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Sun, 12 Jun 2022 07:31:33 -0400 Subject: [PATCH 1/2] Possibly fix derived param aliases test --- Ska/engarchive/tests/test_fetch.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Ska/engarchive/tests/test_fetch.py b/Ska/engarchive/tests/test_fetch.py index e8fa23f3..663a84b1 100644 --- a/Ska/engarchive/tests/test_fetch.py +++ b/Ska/engarchive/tests/test_fetch.py @@ -152,25 +152,27 @@ def test_filter_bad_times_default_copy(): assert np.all(dates == DATES_EXPECT2) -@pytest.mark.parametrize('msid', ['DP_piTch_fss', 'Calc_pitCH_fss']) +@pytest.mark.parametrize('msid', ['DP_piTch_css', 'Calc_pitCH_css']) @pytest.mark.parametrize('sources', (('cxc',), ('maude',), ('cxc', 'maude'))) def test_fetch_derived_param_aliases(msid, sources): - cxc_tstop = fetch.get_time_range('dp_pitch_fss', 'secs')[1] + cxc_tstop = fetch.get_time_range('dp_pitch', 'secs')[1] + dt = 2000 # seconds + msg = (f'{CxoTime(cxc_tstop).date=} {dt=}\n' + f'{CxoTime(cxc_tstop - dt).date=}\n' + f'{CxoTime(cxc_tstop + dt).date=}\n' + f'{CxoTime.now().date=}\n' + f'{CxoTime.now().iso=}\n' + f'{sources=} {msid=}') + print(msg) # stdout gets reported for test failures with fetch.data_source(*sources): - # Get data from +/- 1 day from end of CXC data - dt = 86400 # seconds - d1 = fetch.Msid('piTch_fss', cxc_tstop - dt, cxc_tstop + dt) + # Get data within `dt` secs of end of CXC data + d1 = fetch.Msid('piTCh_css', cxc_tstop - dt, cxc_tstop + dt) d2 = fetch.Msid(msid, cxc_tstop - dt, cxc_tstop + dt) assert d2.msid == msid # version as the user provide assert d2.MSID == d1.MSID # normalized version for accessing databases assert np.all(d1.times == d2.times) assert np.all(d1.vals == d2.vals) - if len(d1) == 0: - msg = (f'No data found for cxo_tstop={CxoTime(cxc_tstop).date} {dt=}' - f' {sources=} {msid=} ' - f'{CxoTime(cxc_tstop - dt).date=} ' - f'{CxoTime(cxc_tstop + dt).date=}') - raise AssertionError(msg) + assert len(d1) > 0 def test_interpolate(): From fa36e9bc2f9517b97499f42a848bdd81e2645646 Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Thu, 7 Jul 2022 14:14:20 -0400 Subject: [PATCH 2/2] Fix more bugs in this test --- Ska/engarchive/tests/test_fetch.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ska/engarchive/tests/test_fetch.py b/Ska/engarchive/tests/test_fetch.py index 663a84b1..de40ff10 100644 --- a/Ska/engarchive/tests/test_fetch.py +++ b/Ska/engarchive/tests/test_fetch.py @@ -155,7 +155,7 @@ def test_filter_bad_times_default_copy(): @pytest.mark.parametrize('msid', ['DP_piTch_css', 'Calc_pitCH_css']) @pytest.mark.parametrize('sources', (('cxc',), ('maude',), ('cxc', 'maude'))) def test_fetch_derived_param_aliases(msid, sources): - cxc_tstop = fetch.get_time_range('dp_pitch', 'secs')[1] + cxc_tstop = fetch.get_time_range('dp_pitch_css', 'secs')[1] dt = 2000 # seconds msg = (f'{CxoTime(cxc_tstop).date=} {dt=}\n' f'{CxoTime(cxc_tstop - dt).date=}\n' @@ -166,8 +166,8 @@ def test_fetch_derived_param_aliases(msid, sources): print(msg) # stdout gets reported for test failures with fetch.data_source(*sources): # Get data within `dt` secs of end of CXC data - d1 = fetch.Msid('piTCh_css', cxc_tstop - dt, cxc_tstop + dt) - d2 = fetch.Msid(msid, cxc_tstop - dt, cxc_tstop + dt) + d1 = fetch.MSID('piTCh_css', cxc_tstop - dt, cxc_tstop + dt) + d2 = fetch.MSID(msid, cxc_tstop - dt, cxc_tstop + dt) assert d2.msid == msid # version as the user provide assert d2.MSID == d1.MSID # normalized version for accessing databases assert np.all(d1.times == d2.times)