From 11517edf4b6cb7638a34dca8bcf69450341f809f Mon Sep 17 00:00:00 2001 From: Donald Campbell <125581724+donaldcampbelljr@users.noreply.github.com> Date: Tue, 19 Mar 2024 15:51:42 -0400 Subject: [PATCH] add checking for pep file type and simple test --- looper/utils.py | 15 +++++++++++++++ tests/smoketests/test_run.py | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/looper/utils.py b/looper/utils.py index 1ba6af9e..8c233243 100644 --- a/looper/utils.py +++ b/looper/utils.py @@ -598,6 +598,21 @@ def dotfile_path(directory=os.getcwd(), must_exist=False): cur_dir = parent_dir +def is_PEP_file_type(input_string: str) -> bool: + """ + Determines if the provided path is actually a file type that Looper can use for loading PEP + """ + + PEP_FILE_TYPES = ["yaml", "csv"] + + parsed_path = parse_registry_path(input_string) + + if parsed_path["subitem"] in PEP_FILE_TYPES: + return True + else: + return False + + def is_registry_path(input_string: str) -> bool: """ Check if input is a registry path to pephub diff --git a/tests/smoketests/test_run.py b/tests/smoketests/test_run.py index 932dfbe3..fc8650fd 100644 --- a/tests/smoketests/test_run.py +++ b/tests/smoketests/test_run.py @@ -34,6 +34,15 @@ def test_running_csv_pep(prep_temp_pep_csv): raise pytest.fail("DID RAISE {0}".format(Exception)) +@pytest.mark.parametrize( + "path", ["something/example.yaml", "somethingelse/example2.csv"] +) +def test_is_PEP_file_type(path): + + result = is_PEP_file_type(path) + assert result == True + + def is_connected(): """Determines if local machine can connect to the internet.""" import socket