Skip to content

Commit e7a678a

Browse files
committed
Adds missing async client tests for tilde and relative paths
Ensures test parity between sync and async clients by adding: - test_custom_state_directory_with_tilde for AsyncReplicatedClient - test_custom_state_directory_relative_path for AsyncReplicatedClient Both clients now have identical test coverage (4 custom state directory tests each), verifying path normalization works consistently across sync and async implementations.
1 parent 6281caf commit e7a678a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/test_client.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,37 @@ async def test_custom_state_directory(self):
128128
assert client.state_manager._state_file == expected_file
129129
assert custom_dir.exists()
130130

131+
@pytest.mark.asyncio
132+
async def test_custom_state_directory_with_tilde(self):
133+
"""Test that ~ expansion works in async client custom state directory."""
134+
client = AsyncReplicatedClient(
135+
publishable_key="pk_test_123",
136+
app_slug="my-app",
137+
state_directory="~/test-replicated-state",
138+
)
139+
# Should be expanded to actual home directory
140+
assert "~" not in str(client.state_manager._state_dir)
141+
assert str(client.state_manager._state_dir).startswith(str(Path.home()))
142+
143+
@pytest.mark.asyncio
144+
async def test_custom_state_directory_relative_path(self):
145+
"""Test that relative paths are resolved in async client."""
146+
with tempfile.TemporaryDirectory() as tmpdir:
147+
# Change to temp directory and use relative path
148+
original_cwd = os.getcwd()
149+
try:
150+
os.chdir(tmpdir)
151+
client = AsyncReplicatedClient(
152+
publishable_key="pk_test_123",
153+
app_slug="my-app",
154+
state_directory="./relative_state",
155+
)
156+
# Should be resolved to absolute path
157+
assert client.state_manager._state_dir.is_absolute()
158+
assert str(tmpdir) in str(client.state_manager._state_dir)
159+
finally:
160+
os.chdir(original_cwd)
161+
131162
@pytest.mark.asyncio
132163
async def test_default_state_directory_unchanged(self):
133164
"""Test that async client default behavior is unchanged."""

0 commit comments

Comments
 (0)