Skip to content

Commit

Permalink
add simple tests, and return false if path ends with csv for is_regis…
Browse files Browse the repository at this point in the history
…try_path #456
  • Loading branch information
donaldcampbelljr committed Mar 14, 2024
1 parent 19b81bb commit 25f438d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion looper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def is_registry_path(input_string: str) -> bool:
:return bool: True if input is a registry path
"""
try:
if input_string.endswith(".yaml"):
if input_string.endswith(".yaml") or input_string.endswith(".csv"):
return False
except AttributeError:
raise RegistryPathException(
Expand Down
18 changes: 18 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,24 @@ def prep_temp_pep_basic(example_pep_piface_path):
return path_to_looper_config


@pytest.fixture
def prep_temp_pep_csv(example_pep_piface_path):

# Get Path to local copy of hello_looper
hello_looper_dir_path = os.path.join(
example_pep_piface_path, "hello_looper-dev_derive"
)

# Make local temp copy of hello_looper
d = tempfile.mkdtemp()
shutil.copytree(hello_looper_dir_path, d, dirs_exist_ok=True)

advanced_dir = os.path.join(d, "csv")
path_to_looper_config = os.path.join(advanced_dir, ".looper.yaml")

return path_to_looper_config


@pytest.fixture
def prep_temp_config_with_pep(example_pep_piface_path):
# temp dir
Expand Down
21 changes: 21 additions & 0 deletions tests/smoketests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ def test_cli(prep_temp_pep):
raise pytest.fail("DID RAISE {0}".format(Exception))


def test_running_csv_pep(prep_temp_pep_csv):
tp = prep_temp_pep_csv

x = ["run", "--looper-config", tp, "--dry-run"]
try:
main(test_args=x)
except Exception:
raise pytest.fail("DID RAISE {0}".format(Exception))


def is_connected():
"""Determines if local machine can connect to the internet."""
import socket
Expand Down Expand Up @@ -597,3 +607,14 @@ def test_init_project_using_dict(self, prep_temp_config_with_pep):
)

assert len(init_project.pipeline_interfaces) == 3

def test_init_project_using_csv(self, prep_temp_pep_csv):
"""Verify looper runs using pephub in a basic case and return code is 0"""
tp = prep_temp_pep_csv
with mod_yaml_data(tp) as config_data:
pep_config_csv = config_data["pep_config"]

pep_config_csv = os.path.join(os.path.dirname(tp), pep_config_csv)
init_project = Project(cfg=pep_config_csv)

assert len(init_project.samples) == 2

0 comments on commit 25f438d

Please sign in to comment.