Skip to content

Commit 776c240

Browse files
committed
fix(test): update test urls
1 parent bc2434d commit 776c240

6 files changed

Lines changed: 19 additions & 16 deletions

File tree

tests/assets.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
ASSETS = {
1010
"image": "https://jigsawstack.com/preview/vocr-example.jpg",
11+
"gif": "https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif",
12+
"svg": "https://upload.wikimedia.org/wikipedia/commons/8/84/Example.svg",
1113
"audio": "https://jigsawstack.com/preview/stt-example.wav",
1214
"csv": "https://r2public.jigsawstack.com/interfaze/examples/prediction-example.csv",
1315
"scene": "https://raw.githubusercontent.com/ultralytics/yolov5/master/data/images/bus.jpg",

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def completion(
8383
)
8484
TASK_TRANSCRIBE = completion('{"name": "speech_to_text", "result": {"text": "hello world"}}')
8585
TASK_WEB_SEARCH = completion(
86-
'{"name": "web_search", "result": {"results": [{"title": "AI agents", "url": "https://example.com"}]}}'
86+
'{"name": "web_search", "result": {"results": [{"title": "AI agents", "url": "https://news.ycombinator.com"}]}}'
8787
)
8888
TASK_SCRAPE = completion('{"name": "scraper", "result": {"text": "Hacker News"}}')
8989
TASK_TRANSLATE = completion('{"name": "translate", "result": "Bonjour"}')

tests/test_inputs_and_client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ def test_file_part():
2626

2727

2828
def test_file_forwards_computed_mime():
29-
assert inputs.file("https://x.com/d.pdf")["file"]["format"] == "application/pdf"
29+
assert inputs.file(ASSETS["pdf"], filename="attention.pdf")["file"]["format"] == "application/pdf"
3030

3131

3232
def test_video_forwards_mp4_mime():
33-
part = inputs.video("https://x.com/clip.mp4")
33+
part = inputs.video(ASSETS["video"])
3434
assert part["type"] == "file" and part["file"]["format"] == "video/mp4"
3535

3636

37-
def test_file_unknown_ext_omits_format():
38-
assert "format" not in inputs.file("https://x.com/page")["file"]
37+
def test_file_extensionless_omits_format():
38+
assert "format" not in inputs.file(ASSETS["pdf"])["file"]
3939

4040

4141
def test_audio_uses_input_audio():
@@ -54,8 +54,8 @@ def test_audio_rejects_blacklisted_data_uri():
5454

5555

5656
def test_video_uses_file_part():
57-
part = inputs.video("https://x.com/clip.mp4")
58-
assert part["type"] == "file" and part["file"]["file_data"] == "https://x.com/clip.mp4"
57+
part = inputs.video(ASSETS["video"])
58+
assert part["type"] == "file" and part["file"]["file_data"] == ASSETS["video"]
5959

6060

6161
def test_base64_image_part():
@@ -78,7 +78,7 @@ def test_video_part_rides_on_file():
7878

7979
def test_gif_rejected():
8080
with pytest.raises(InterfazeError):
81-
inputs.image("https://jigsawstack.com/preview/example.gif")
81+
inputs.image(ASSETS["gif"])
8282

8383

8484
def test_avif_rejected_via_format():
@@ -118,7 +118,7 @@ def test_auto_part_extensionless_url_falls_through_to_file():
118118

119119

120120
def test_unknown_extension_file_part_has_no_format_key():
121-
part = inputs.file("https://example.com/dataset.xyz123")
121+
part = inputs.file(ASSETS["svg"])
122122
assert "format" not in part["file"]
123123
assert "filename" not in part["file"]
124124

tests/test_langchain.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
pytest.importorskip("langchain_openai")
88

99
import respx
10+
from assets import ASSETS
1011
from conftest import BASIC, STREAM_CHUNKS, _chunk, completion, last_body, mock_json, mock_sse
1112

1213
from interfaze import InterfazeError
@@ -99,13 +100,13 @@ def test_video_block_converted_to_file_part():
99100
message = HumanMessage(
100101
content=[
101102
{"type": "text", "text": "what happens in this clip?"},
102-
{"type": "video", "url": "https://example.com/clip.mp4"},
103+
{"type": "video", "url": ASSETS["video"]},
103104
]
104105
)
105106
model.invoke([message]) # must not raise
106107
body = last_body(route)
107108
content = body["messages"][-1]["content"]
108-
assert {"type": "file", "file": {"file_data": "https://example.com/clip.mp4"}} in content
109+
assert {"type": "file", "file": {"file_data": ASSETS["video"]}} in content
109110

110111

111112
@respx.mock
@@ -126,7 +127,7 @@ def test_streaming_strips_inline_tags_and_carries_precontext():
126127
mock_sse(STREAM_CHUNKS)
127128
model = ChatInterfaze(api_key="t")
128129
chunks = list(model.stream([HumanMessage("x")]))
129-
text = "".join(c.content for c in chunks)
130+
text = "".join(c.content for c in chunks) # ty:ignore[no-matching-overload]
130131
assert "<precontext>" not in text
131132
assert text == "Total is $12.34"
132133
precontext_chunks = [c for c in chunks if c.additional_kwargs.get("precontext")]
@@ -148,7 +149,7 @@ def test_streaming_recovers_reasoning_split_across_chunks():
148149
mock_sse(THINK_SPLIT)
149150
model = ChatInterfaze(api_key="t")
150151
chunks = list(model.stream([HumanMessage("x")]))
151-
text = "".join(c.content for c in chunks)
152+
text = "".join(c.content for c in chunks) # ty:ignore[no-matching-overload]
152153
assert "<think>" not in text and text == "The sky is blue."
153154
reasoning = [c for c in chunks if c.additional_kwargs.get("reasoning")]
154155
assert reasoning and reasoning[0].additional_kwargs["reasoning"] == "Rayleigh scattering."

tests/test_stream.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ def test_tool_call_stream_events_and_final():
145145
assert final.choices[0].finish_reason == "tool_calls"
146146
assert final.choices[0].message.content is None
147147
tool_calls = final.choices[0].message.tool_calls
148-
assert tool_calls and tool_calls[0].function.name == "get_weather"
149-
assert tool_calls[0].function.arguments == '{"city":"Paris"}'
148+
assert tool_calls and tool_calls[0].function.name == "get_weather" # ty:ignore[unresolved-attribute]
149+
assert tool_calls[0].function.arguments == '{"city":"Paris"}' # ty:ignore[unresolved-attribute]
150150

151151

152152
@respx.mock

tests/test_tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_web_search(is_async):
117117
system_msg, user_msg = body["messages"]
118118
assert "<task>web_search</task>" in system_msg["content"]
119119
assert user_msg["content"] == "latest AI agent news"
120-
assert result == {"results": [{"title": "AI agents", "url": "https://example.com"}]}
120+
assert result == {"results": [{"title": "AI agents", "url": "https://news.ycombinator.com"}]}
121121

122122

123123
@IS_ASYNC

0 commit comments

Comments
 (0)