Skip to content

Commit 9d27194

Browse files
committed
Use pytest-remotedata for offline/online test split
1 parent bd8ecdc commit 9d27194

6 files changed

Lines changed: 36 additions & 6 deletions

File tree

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ omit =
44
sunpy_soar/*setup_package*
55
sunpy_soar/extern/*
66
sunpy_soar/version*
7+
sunpy_soar/_dev/*
8+
*/sunpy_soar/_dev/*
79
*/sunpy_soar/conftest.py
810
*/sunpy_soar/*setup_package*
911
*/sunpy_soar/extern/*

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ jobs:
6565
toxdeps: tox-pypi-filter
6666
posargs: -n auto
6767
envs: |
68-
- linux: py314
69-
- windows: py312
70-
- macos: py312
71-
- linux: py312-oldestdeps
72-
- linux: py314-devdeps
68+
- linux: py314-online
69+
- windows: py312-online
70+
- macos: py312-online
71+
- linux: py312-oldestdeps-online
72+
- linux: py314-devdeps-online
7373
secrets:
7474
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7575

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ tests-only = [
3333
"pytest-cov",
3434
"pytest-doctestplus",
3535
"pytest",
36+
"pytest-remotedata",
3637
]
3738
tests = [
3839
"sunpy_soar[tests-deps,tests-only]",

pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ addopts =
2222
--doctest-rst
2323
-p no:unraisableexception
2424
-p no:threadexception
25+
markers =
26+
remote_data: marks this test function as needing remote data.
27+
remote_data_strict = true
2528
filterwarnings =
2629
# Turn all warnings into errors so they do not pass silently.
2730
error

sunpy_soar/tests/test_sunpy_soar.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
SUNPY_VERSION = (sunpy.version.major, sunpy.version.minor)
1515

16+
17+
@pytest.mark.remote_data
1618
def test_search() -> None:
1719
instrument = a.Instrument("EUI")
1820
time = a.Time("2022-02-11", "2022-02-12")
@@ -39,6 +41,7 @@ def test_search() -> None:
3941
sunpy.map.Map(fname)
4042

4143

44+
@pytest.mark.remote_data
4245
def test_search_low_latency() -> None:
4346
time = a.Time("2020-11-13", "2020-11-14")
4447
level = a.Level("LL02")
@@ -52,6 +55,7 @@ def test_search_low_latency() -> None:
5255
assert len(files) == 1
5356

5457

58+
@pytest.mark.remote_data
5559
def test_insitu_search() -> None:
5660
instrument = a.Instrument("MAG")
5761
time = a.Time("2020-04-16", "2020-04-17")
@@ -65,6 +69,7 @@ def test_insitu_search() -> None:
6569
assert len(files) == 1
6670

6771

72+
@pytest.mark.remote_data
6873
def test_no_results() -> None:
6974
instrument = a.Instrument("EUI")
7075
time = a.Time("2019-02-01", "2019-02-02")
@@ -74,13 +79,15 @@ def test_no_results() -> None:
7479
assert len(res) == 0
7580

7681

82+
@pytest.mark.remote_data
7783
def test_no_instrument() -> None:
7884
# Check that a time only search returns results
7985
time = a.Time("2020-04-16", "2020-04-17")
8086
res = SOARClient().search(time)
8187
assert len(res) == 63
8288

8389

90+
@pytest.mark.remote_data
8491
def test_download_path(tmp_path) -> None:
8592
# Check that we can download things to a custom path using
8693
# the search parameters
@@ -119,6 +126,7 @@ def test_registered_soop_names() -> None:
119126
assert "\nr_small_mres_mcad_ar_long_term" in soop_attr
120127

121128

129+
@pytest.mark.remote_data
122130
def test_search_soop() -> None:
123131
instrument = a.Instrument("EUI")
124132
time = a.Time("2022-04-01 01:00", "2022-04-01 02:00")
@@ -132,6 +140,7 @@ def test_search_soop() -> None:
132140
assert res.file_num == 0
133141

134142

143+
@pytest.mark.remote_data
135144
def test_when_soar_provider_passed() -> None:
136145
# Tests when a.Provider.soar is passed that only SOARClient results are returned
137146
instrument = a.Instrument("EUI")
@@ -153,6 +162,7 @@ def test_when_sdac_provider_passed() -> None:
153162
assert res["vso"]
154163

155164

165+
@pytest.mark.remote_data
156166
def test_when_wrong_provider_passed() -> None:
157167
# Tests that no results are returned when a provider is passed which does not provide EUI data.
158168
# This is different from the above test because the SDAC and the SOAR both provide EUI data while
@@ -164,6 +174,7 @@ def test_when_wrong_provider_passed() -> None:
164174
assert len(res) == 0
165175

166176

177+
@pytest.mark.remote_data
167178
def test_search_wavelength_detector_column() -> None:
168179
instrument = a.Instrument("EUI")
169180
time = a.Time("2021-02-01", "2021-02-02")
@@ -174,6 +185,7 @@ def test_search_wavelength_detector_column() -> None:
174185
assert "Detector" in res[0].columns
175186

176187

188+
@pytest.mark.remote_data
177189
def test_search_detector_instrument_dimension_2() -> None:
178190
# Instruments "EUI", "METIS", "PHI" and "SOLOHI" have two dimensions in the SOAR data.
179191
# Selecting no dimension index in the query results in two identical output rows.
@@ -187,6 +199,7 @@ def test_search_detector_instrument_dimension_2() -> None:
187199
assert res.file_num == 266
188200

189201

202+
@pytest.mark.remote_data
190203
def test_search_detector_instrument_dimension_4() -> None:
191204
# The "SPICE" instrument has four dimensions in the SOAR data. As a result,
192205
# selecting no dimension index in the query results in four identical output rows.
@@ -200,6 +213,7 @@ def test_search_detector_instrument_dimension_4() -> None:
200213
assert res.file_num == 11
201214

202215

216+
@pytest.mark.remote_data
203217
def test_invalid_detector() -> None:
204218
instrument = a.Instrument("SPICE")
205219
time = a.Time("2023-03-03 15:00", "2023-03-03 16:00")
@@ -210,6 +224,7 @@ def test_invalid_detector() -> None:
210224
assert res.file_num == 0
211225

212226

227+
@pytest.mark.remote_data
213228
def test_wavelength_column_wavelength_exists() -> None:
214229
# For instruments EUI, METIS and SOLOHI "wavelength" column is available.
215230
# Test to check if the "Wavelength" column exists in the search results.
@@ -222,6 +237,7 @@ def test_wavelength_column_wavelength_exists() -> None:
222237
assert res.file_num == 12
223238

224239

240+
@pytest.mark.remote_data
225241
def test_wavelength_single() -> None:
226242
# Test to check if the wavelength value is filtered for a single value provided.
227243
instrument = a.Instrument("EUI")
@@ -233,6 +249,7 @@ def test_wavelength_single() -> None:
233249
assert all(table["Wavelength"] == 304)
234250

235251

252+
@pytest.mark.remote_data
236253
def test_wavelength_range() -> None:
237254
# Test to check if the wavelength value is filtered for wavemin and wavemax provided.
238255
instrument = a.Instrument("EUI")
@@ -312,6 +329,7 @@ def test_distance_join_query():
312329
)
313330

314331

332+
@pytest.mark.remote_data
315333
def test_distance_search_remote_sensing():
316334
instrument = a.Instrument("RPW")
317335
product = a.soar.Product("rpw-tnr-surv")
@@ -321,6 +339,7 @@ def test_distance_search_remote_sensing():
321339
assert res.file_num > 40
322340

323341

342+
@pytest.mark.remote_data
324343
def test_distance_search_insitu():
325344
instrument = a.Instrument("METIS")
326345
level = a.Level(2)
@@ -330,6 +349,7 @@ def test_distance_search_insitu():
330349
assert res.file_num == 310
331350

332351

352+
@pytest.mark.remote_data
333353
def test_distance_time_search():
334354
instrument = a.Instrument("EUI")
335355
time = a.Time("2023-04-27", "2023-04-28")
@@ -345,6 +365,7 @@ def test_distance_time_search():
345365

346366
# Remove this test and the mark from below once min sunpy dep >=7.1
347367
@pytest.mark.skipif(SUNPY_VERSION >= (7, 1), reason="Skip post sunpy 7.1")
368+
@pytest.mark.remote_data
348369
def test_distance_out_of_bounds_warning(recwarn):
349370
instrument = a.Instrument("EUI")
350371
time = a.Time("2023-04-27", "2023-04-28")
@@ -364,6 +385,7 @@ def test_distance_out_of_bounds_warning(recwarn):
364385

365386

366387
@pytest.mark.skipif(SUNPY_VERSION < (7, 1), reason="Skip pre sunpy 7.1")
388+
@pytest.mark.remote_data
367389
def test_distance_out_of_bounds_warning_post71(recwarn):
368390
instrument = a.Instrument("EUI")
369391
time = a.Time("2023-04-27", "2023-04-28")

tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ min_version = 4.0
33
requires =
44
tox-pypi-filter>=0.14
55
envlist =
6-
py{312,313,314}
6+
py{312,313,314}{,-online}
77
py314-devdeps
88
py312-oldestdeps
99
codestyle
@@ -18,6 +18,7 @@ description =
1818
run tests
1919
oldestdeps: with the oldest supported version of key dependencies
2020
devdeps: with the latest developer version of key dependencies
21+
online: that require remote data (as well as the offline ones)
2122
pass_env =
2223
# A variable to tell tests we are on a CI system
2324
CI
@@ -57,6 +58,7 @@ commands =
5758
--cov-report=xml \
5859
--cov=sunpy_soar \
5960
--cov-config={toxinidir}/.coveragerc \
61+
online: --remote-data=any \
6062
{toxinidir}/docs \
6163
{posargs}
6264

0 commit comments

Comments
 (0)