Skip to content

Commit

Permalink
Skip tests if internet is not available (#311)
Browse files Browse the repository at this point in the history
* Skip test_validate_regression and test_off_nominal_roll_violations if command sheet is not available

* black/ruff

* fixup

* fixup^2

* Check for internet for all tests that require it

---------

Co-authored-by: Tom Aldcroft <[email protected]>
  • Loading branch information
javierggt and taldcroft authored Jan 12, 2024
1 parent 4253c0f commit 88e7264
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion kadi/commands/tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@
import numpy as np
import pytest
import ska_sun
from testr.test_helper import has_internet

from kadi.commands.utils import compress_time_series
from kadi.commands.validate import Validate, ValidateRoll
from kadi.commands.validate import (
Validate,
ValidateRoll,
)

# Regression testing for this 5-day period covering a safe mode with plenty of things
# happening. There are a number of violations in this period and a couple of excluded
# intervals.
REGRESSION_STOP = "2022:297"
REGRESSION_DAYS = 5

HAS_INTERNET = has_internet()


def write_regression_data(stop, days, no_exclude):
cwd = Path(__file__).parent
Expand Down Expand Up @@ -107,6 +113,7 @@ def test_validate_subclasses():
assert set(data_all_exp.keys()) == {cls.state_name for cls in Validate.subclasses}


@pytest.mark.skipif(not HAS_INTERNET, reason="Command sheet not available")
@pytest.mark.parametrize("cls", Validate.subclasses)
@pytest.mark.parametrize("no_exclude", [False, True])
def test_validate_regression(cls, no_exclude, fast_sun_position_method):
Expand Down Expand Up @@ -135,6 +142,7 @@ def test_validate_regression(cls, no_exclude, fast_sun_position_method):
assert np.all(data_obs["violations"] == data_exp["violations"])


@pytest.mark.skipif(not HAS_INTERNET, reason="Command sheet not available")
def test_off_nominal_roll_violations():
"""Test off_nominal_roll violations over a time range with tail sun observations"""
# Default sun position method is "accurate".
Expand Down
4 changes: 3 additions & 1 deletion kadi/tests/test_occweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import requests
import ska_file
import ska_ftp
from testr.test_helper import has_internet

from kadi import occweb

Expand Down Expand Up @@ -66,7 +67,7 @@ def test_put_get_user_none():
# uses the /proj/sot/ska/data/aspect_authorization area, so existence of the right file
# in there can just be checked by the get_auth routine
user, passwd = occweb.get_auth()
HAS_OCCWEB = bool(user is not None)
HAS_OCCWEB = bool(user is not None) and has_internet()


@pytest.mark.skipif(not HAS_OCCWEB, reason="No access to OCCweb")
Expand Down Expand Up @@ -139,6 +140,7 @@ def test_get_occweb_noodle(lowercase, backslash):
assert files_path.pformat_all() == exp


@pytest.mark.skipif(not HAS_OCCWEB, reason="No access to OCCweb")
@pytest.mark.parametrize("noodle_path", occweb.NOODLE_OCCWEB_MAP)
def test_all_get_occweb_noodle(noodle_path):
"""Make sure we can get a directory from noodle for all available
Expand Down

0 comments on commit 88e7264

Please sign in to comment.