Skip to content

Commit 4b88305

Browse files
zekeclaude
andcommitted
fix: add bearer tokens to get_path_url tests to prevent auth errors
The FileOutput and AsyncFileOutput classes require authenticated clients. Added TEST_TOKEN constant and provided bearer_token parameter to all client instantiations in tests to fix CI authentication failures. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 2a70529 commit 4b88305

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/lib/test_get_path_url.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
from replicate.lib._files import FileOutput, AsyncFileOutput
55
from replicate.lib._predictions_use import URLPath, get_path_url
66

7+
# Test token for client instantiation
8+
TEST_TOKEN = "test-bearer-token"
9+
710

811
def test_get_path_url_with_urlpath():
912
"""Test get_path_url returns the URL for URLPath instances."""
@@ -17,7 +20,7 @@ def test_get_path_url_with_urlpath():
1720
def test_get_path_url_with_fileoutput():
1821
"""Test get_path_url returns the URL for FileOutput instances."""
1922
url = "https://example.com/test.jpg"
20-
file_output = FileOutput(url, replicate.Replicate())
23+
file_output = FileOutput(url, replicate.Replicate(bearer_token=TEST_TOKEN))
2124

2225
result = get_path_url(file_output)
2326
assert result == url
@@ -26,7 +29,7 @@ def test_get_path_url_with_fileoutput():
2629
def test_get_path_url_with_async_fileoutput():
2730
"""Test get_path_url returns the URL for AsyncFileOutput instances."""
2831
url = "https://example.com/test.jpg"
29-
async_file_output = AsyncFileOutput(url, replicate.AsyncReplicate())
32+
async_file_output = AsyncFileOutput(url, replicate.AsyncReplicate(bearer_token=TEST_TOKEN))
3033

3134
result = get_path_url(async_file_output)
3235
assert result == url
@@ -61,7 +64,7 @@ def test_get_path_url_module_level_import():
6164
from replicate import get_path_url as module_get_path_url
6265

6366
url = "https://example.com/test.jpg"
64-
file_output = FileOutput(url, replicate.Replicate())
67+
file_output = FileOutput(url, replicate.Replicate(bearer_token=TEST_TOKEN))
6568

6669
result = module_get_path_url(file_output)
6770
assert result == url
@@ -70,7 +73,7 @@ def test_get_path_url_module_level_import():
7073
def test_get_path_url_direct_module_access():
7174
"""Test that get_path_url can be accessed directly from replicate module."""
7275
url = "https://example.com/test.jpg"
73-
file_output = FileOutput(url, replicate.Replicate())
76+
file_output = FileOutput(url, replicate.Replicate(bearer_token=TEST_TOKEN))
7477

7578
result = replicate.get_path_url(file_output)
7679
assert result == url
@@ -79,7 +82,7 @@ def test_get_path_url_direct_module_access():
7982
def test_fileoutput_has_url_attribute():
8083
"""Test that FileOutput instances have __url__ attribute."""
8184
url = "https://example.com/test.jpg"
82-
file_output = FileOutput(url, replicate.Replicate())
85+
file_output = FileOutput(url, replicate.Replicate(bearer_token=TEST_TOKEN))
8386

8487
assert hasattr(file_output, "__url__")
8588
assert file_output.__url__ == url
@@ -88,7 +91,7 @@ def test_fileoutput_has_url_attribute():
8891
def test_async_fileoutput_has_url_attribute():
8992
"""Test that AsyncFileOutput instances have __url__ attribute."""
9093
url = "https://example.com/test.jpg"
91-
async_file_output = AsyncFileOutput(url, replicate.AsyncReplicate())
94+
async_file_output = AsyncFileOutput(url, replicate.AsyncReplicate(bearer_token=TEST_TOKEN))
9295

9396
assert hasattr(async_file_output, "__url__")
9497
assert async_file_output.__url__ == url

0 commit comments

Comments
 (0)