Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions spinnaker_testbase/base_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ def assert_logs_messages(

def get_system_iobuf_files(self) -> List[str]:
"""
Get a list of the system iobuf files.
:returns: A list of the system iobuf files.
"""
system_iobuf_file_path = FecDataView.get_system_provenance_dir_path()
return os.listdir(system_iobuf_file_path)

def get_app_iobuf_files(self) -> List[str]:
"""
Get a list of the application iobuf files.
:returns: A list of the application iobuf files.
"""
app_iobuf_file_path = FecDataView.get_app_provenance_dir_path()
return os.listdir(app_iobuf_file_path)
1 change: 1 addition & 0 deletions spinnaker_testbase/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def host_is_reachable(ip_address: str) -> bool:
:param ip_address:
The IP address to ping. Hostnames can be used, but are not
recommended.
:returns: True if a ping worked at some time
"""
if ip_address in Ping.unreachable:
return False
Expand Down
34 changes: 11 additions & 23 deletions spinnaker_testbase/root_script_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,8 @@ class RootScriptBuilder(object):
Looks for example scripts that can be made into integration tests.
"""

def add_script(self, test_file: TextIOBase, name: str, local_path: str,
skip_imports: Optional[List[str]]) -> None:
"""
:param test_file:
:param name:
:param local_path:
:param skip_imports:
"""
def _add_script(self, test_file: TextIOBase, name: str, local_path: str,
skip_imports: Optional[List[str]]) -> None:
test_file.write("\n def test_")
test_file.write(name)
test_file.write("(self):\n")
Expand All @@ -58,21 +52,13 @@ def add_script(self, test_file: TextIOBase, name: str, local_path: str,
test_file.write("]")
test_file.write(")\n")

def add_scripts(self, a_dir: str, prefix_len: int, test_file: TextIOBase,
too_long: Dict[str, str], exceptions: Dict[str, str],
skip_exceptions: Dict[str, List[str]]) -> None:
"""
:param a_dir:
:param prefix_len:
:param test_file:
:param too_long:
:param exceptions:
:param skip_exceptions:
"""
def _add_scripts(self, a_dir: str, prefix_len: int, test_file: TextIOBase,
too_long: Dict[str, str], exceptions: Dict[str, str],
skip_exceptions: Dict[str, List[str]]) -> None:
for a_script in os.listdir(a_dir):
script_path = os.path.join(a_dir, a_script)
if os.path.isdir(script_path) and not a_script.startswith("."):
self.add_scripts(
self._add_scripts(
script_path, prefix_len, test_file, too_long, exceptions,
skip_exceptions)
if a_script.endswith(".py") and a_script != "__init__.py":
Expand All @@ -98,14 +84,16 @@ def add_scripts(self, a_dir: str, prefix_len: int, test_file: TextIOBase,
name = local_path[:-3].replace(os.sep, "_").replace(
"-", "_")
skip_imports = skip_exceptions.get(a_script, None)
self.add_script(test_file, name, local_path, skip_imports)
self._add_script(test_file, name, local_path, skip_imports)

def create_test_scripts(
self, dirs: Union[str, List[str]],
too_long: Optional[Dict[str, str]] = None,
exceptions: Optional[Dict[str, str]] = None,
skip_exceptions: Optional[Dict[str, List[str]]] = None) -> None:
"""
Creates a file of integration tests to run the scripts/ examples

:param dirs: List of dirs to find scripts in.
These are relative paths to the repository
:param too_long: Dict of files that take too long to run and how long.
Expand Down Expand Up @@ -150,5 +138,5 @@ def create_test_scripts(
with open(test_script, "a", encoding="utf-8") as test_file:
for script_dir in dirs:
a_dir = os.path.join(repository_dir, script_dir)
self.add_scripts(a_dir, len(repository_dir)+1, test_file,
too_long, exceptions, skip_exceptions)
self._add_scripts(a_dir, len(repository_dir)+1, test_file,
too_long, exceptions, skip_exceptions)
10 changes: 10 additions & 0 deletions spinnaker_testbase/script_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,22 @@ def check_script(self, script: str, broken_msg: Optional[str] = None,
skip_exceptions: Optional[List[type]] = None,
use_script_dir: bool = True) -> None:
"""
Checks/runs a script, timing the run.

Includes a work around for matplotlib
so it does not actually try to plot

:param script: relative path to the file to run
:param broken_msg:
message to print instead of raising an exception;
no current use-case known
:param skip_exceptions:
list of exception classes to convert in SkipTest
:param use_script_dir:
If True this checker will change directory into the scripts
directory so that the local cfg file is read.
If False the caller is responsible for changing into the directory
containing any relative cfg.
"""
# pylint: disable=global-statement
global script_checker_shown
Expand Down
8 changes: 1 addition & 7 deletions unittests/test_doc_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ def test_doc_checks(self) -> None:
abs_class_file = os.path.abspath(class_file)
unittest_dir = os.path.dirname(abs_class_file)
repo_dir = os.path.dirname(unittest_dir)
checker = DocsChecker(
check_init=False, # in dependencies
check_short=False, # 4 errors in 2 files
check_params=False, # 7 errors in 4 files
check_returns=False, # 3 errors in 2 files
check_properties=False # in dependencies
)
checker = DocsChecker()
checker.check_dir(repo_dir)
checker.check_no_errors()
Loading