Skip to content

Commit fb292db

Browse files
committed
refactor(tests): update normalize_path test to cover strip_extension parameter
1 parent 83fb88d commit fb292db

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

tests/custom/integration/test_sync_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def test_pull_with_quiet_mode(
147147
def test_pull_with_invalid_path(
148148
cli_runner: CliRunner,
149149
):
150-
# GIVEN an invalid base directory
150+
# GIVEN an invalid path
151151
path = "nonexistent/path"
152152

153153
# WHEN running pull command

tests/custom/sync/test_client.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,26 @@ def test_normalize_path(sync_client: SyncClient):
3737
"""Test path normalization functionality."""
3838
# GIVEN various file paths with different formats
3939
test_cases = [
40-
("path/to/file.prompt", "path/to/file"),
41-
("path\\to\\file.agent", "path/to/file"),
42-
("trailing/slashes/file.agent/", "trailing/slashes/file"),
43-
("multiple//slashes//file.prompt", "multiple/slashes/file"),
40+
# Input path, expected with strip_extension=False, expected with strip_extension=True
41+
("path/to/file.prompt", "path/to/file.prompt", "path/to/file"),
42+
("path\\to\\file.agent", "path/to/file.agent", "path/to/file"),
43+
("trailing/slashes/file.agent/", "trailing/slashes/file.agent", "trailing/slashes/file"),
44+
("multiple//slashes//file.prompt", "multiple/slashes/file.prompt", "multiple/slashes/file"),
4445
]
4546

46-
for input_path, expected in test_cases:
47-
# WHEN they are normalized
48-
normalized = sync_client._normalize_path(input_path)
49-
# THEN they should be converted to the expected format
50-
assert normalized == expected
47+
# Test with strip_extension=False (default)
48+
for input_path, expected_with_ext, _ in test_cases:
49+
# WHEN they are normalized without stripping extension
50+
normalized = sync_client._normalize_path(input_path, strip_extension=False)
51+
# THEN they should be converted to the expected format with extension
52+
assert normalized == expected_with_ext
53+
54+
# Test with strip_extension=True
55+
for input_path, _, expected_without_ext in test_cases:
56+
# WHEN they are normalized with extension stripping
57+
normalized = sync_client._normalize_path(input_path, strip_extension=True)
58+
# THEN they should be converted to the expected format without extension
59+
assert normalized == expected_without_ext
5160

5261
# Test absolute path raises error
5362
with pytest.raises(HumanloopRuntimeError, match="Absolute paths are not supported"):

0 commit comments

Comments
 (0)