Skip to content

Commit edc867c

Browse files
author
Alan Christie
committed
fix: file:// references in molecules
1 parent eafb929 commit edc867c

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/jote/jote.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
_DEFAULT_MANIFEST: str = os.path.join(_DEFINITION_DIRECTORY, "manifest.yaml")
3131
# Where can we expect to find test data?
3232
_DATA_DIRECTORY: str = "data"
33+
_DATA_DIRECTORY_PATH: str = f"{_DATA_DIRECTORY}/"
3334

3435
# Our yamllint configuration file
3536
# from the same directory as us.
@@ -346,16 +347,14 @@ def _copy_inputs(test_inputs: List[str], project_path: str) -> bool:
346347
"""Copies all the test files into the test project directory."""
347348

348349
# The files are assumed to reside in the repo's 'data' directory.
349-
print(f'# Copying inputs (from "${{PWD}}/{_DATA_DIRECTORY}")...')
350-
351-
expected_prefix: str = f"{_DATA_DIRECTORY}/"
350+
print(f'# Copying inputs (from "${{PWD}}/{_DATA_DIRECTORY_PATH}")...')
352351
for test_input in test_inputs:
353352

354353
print(f"# + {test_input}")
355354

356-
if not test_input.startswith(expected_prefix):
355+
if not test_input.startswith(_DATA_DIRECTORY_PATH):
357356
print("! FAILURE")
358-
print(f'! Input file {test_input} must start with "{expected_prefix}"')
357+
print(f'! Input file {test_input} must start with "{_DATA_DIRECTORY_PATH}"')
359358
return False
360359
if not os.path.isfile(test_input):
361360
print("! FAILURE")
@@ -663,12 +662,23 @@ def _run_a_test(
663662
== "molecules"
664663
):
665664
value = job_definition.tests[job_test_name].inputs[variable]
666-
job_variables[variable] = value
667665
prefix = _get_test_input_url_prefix(value)
668666
if prefix:
669-
# There's a prefix so it's a file (not a molecule string)
670-
# The input file for "file://one.sdf" is the basename "one.sdf"
671-
input_files.append(value[len(prefix) :])
667+
# There's a prefix so it's a file (not a molecule string).
668+
# The input file is expected to be something like
669+
# "file://data/one.sdf". In this case
670+
# the input file list is extended with the value "data/one.sdf"
671+
# and the variable (passed to the test) becomes "file://one.sdf"
672+
file_path_and_name: str = value[len(prefix) :]
673+
input_files.append(file_path_and_name)
674+
data_relative_file = file_path_and_name
675+
if file_path_and_name.startswith(_DATA_DIRECTORY_PATH):
676+
data_relative_file = file_path_and_name[
677+
len(_DATA_DIRECTORY_PATH) :
678+
]
679+
job_variables[variable] = f"{prefix}{data_relative_file}"
680+
else:
681+
job_variables[variable] = value
672682
else:
673683
# It is an input (not an option).
674684
# The input is a list if it's declared as 'multiple'.

0 commit comments

Comments
 (0)