Skip to content

Commit a920cc7

Browse files
updated testing existing files
1 parent c60cadc commit a920cc7

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

test_data_model/tests/test_file_exists.py

+19-8
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,37 @@ def test_file_exists(repo_path):
2121
Test if a file exists.
2222
2323
Parameters:
24-
file_path (str): The path to the file to check.
24+
repo_path (str): The path to the repository to check.
2525
2626
Returns:
27-
tuple: (success: bool, message: str)
27+
tuple: (test_name: str, success: bool, message: list)
2828
"""
2929

3030
test_name = "Checking if the mandatory files according to the contribution manual are present"
3131

32-
mandatory_files = ["schema.json", "examples/example.json", "examples/example-normalized.json", "examples/example.jsonld", "examples/example-normalized.jsonld", "notes.yaml", "ADOPTERS.yaml"]
32+
mandatory_files = [
33+
"schema.json",
34+
"examples/example.json",
35+
"examples/example-normalized.json",
36+
"examples/example.jsonld",
37+
"examples/example-normalized.jsonld",
38+
"notes.yaml",
39+
"ADOPTERS.yaml"
40+
]
3341
output = []
3442
success = True
43+
3544
for file in mandatory_files:
36-
path_to_file = repo_path + "/" + file
37-
# print(f"The path to file is {path_to_file}")
45+
path_to_file = os.path.join(repo_path, file)
3846
exist_file = os.path.exists(path_to_file)
3947
success = success and exist_file
4048

49+
# Extract the file name from the path
50+
file_name = os.path.basename(file)
51+
4152
if exist_file:
42-
output.append(f"The file {path_to_file} exists")
53+
output.append(f"The file {file_name} exists")
4354
else:
44-
output.append(f"*** The file {path_to_file} DOES NOT exist")
45-
return test_name, success, output
55+
output.append(f"*** The file {file_name} DOES NOT exist")
4656

57+
return test_name, success, output

0 commit comments

Comments
 (0)