|
import pytest |
|
from langflow.base.data.utils import format_directory_path |
|
|
|
|
|
@pytest.mark.parametrize( |
|
("input_path", "expected"), |
|
[ |
|
|
|
("/home/user/documents/file.txt", "/home/user/documents/file.txt"), |
|
|
|
("/home/user/docu\nments/file.txt", "/home/user/docu\\nments/file.txt"), |
|
|
|
("/home/user/\ndocu\nments/file.txt", "/home/user/\\ndocu\\nments/file.txt"), |
|
|
|
("\n\n\n", "\\n\\n\\n"), |
|
|
|
("", ""), |
|
|
|
("/home/user/my-\ndocs/special_file!.pdf", "/home/user/my-\\ndocs/special_file!.pdf"), |
|
|
|
("C:\\Users\\\nDocuments\\file.txt", "C:\\Users\\\\nDocuments\\file.txt"), |
|
|
|
("/home/user/documents/\n", "/home/user/documents/\\n"), |
|
|
|
("\n/home/user/documents/", "\\n/home/user/documents/"), |
|
|
|
("/home/user/docu\n\nments/file.txt", "/home/user/docu\\n\\nments/file.txt"), |
|
], |
|
) |
|
def test_format_directory_path(input_path, expected): |
|
result = format_directory_path(input_path) |
|
assert result == expected |
|
|
|
|
|
|
|
def test_format_directory_path_type(): |
|
result = format_directory_path("/home/user/file.txt") |
|
assert isinstance(result, str) |
|
|