1818 publish_message ,
1919 PUBLISH_TIMEOUT ,
2020)
21+ from logdetective_packit .utils import is_url
2122
2223
2324from tests .utils import (
@@ -117,9 +118,10 @@ async def test_publish_message_exceptions(
117118async def test_call_log_detective (
118119 mock_env_vars , mock_external_calls , mock_server_logger
119120):
120-
121121 log_detective_analysis_id = "8052517e-cf69-11f0-9b27-9a478821d0e2"
122- log_detective_build_analysis_start = datetime .fromisoformat ("2025-12-10 10:57:57.341695+00:00" )
122+ log_detective_build_analysis_start = datetime .fromisoformat (
123+ "2025-12-10 10:57:57.341695+00:00"
124+ )
123125 build_info = BuildInfo (** MINIMAL_BUILD_INFO )
124126 await call_log_detective (
125127 build_info = build_info ,
@@ -144,7 +146,9 @@ async def test_call_log_detective_request_exception(
144146
145147 with pytest .raises (HTTPStatusError ):
146148 log_detective_build_analysis_id = "8052517e-cf69-11f0-9b27-9a478821d0e2"
147- log_detective_build_analysis_start = datetime .fromisoformat ("2025-12-10 10:57:57.341695+00:00" )
149+ log_detective_build_analysis_start = datetime .fromisoformat (
150+ "2025-12-10 10:57:57.341695+00:00"
151+ )
148152 await call_log_detective (
149153 build_info = build_info ,
150154 log_detective_analysis_id = log_detective_build_analysis_id ,
@@ -160,13 +164,18 @@ async def test_analyze_build_skeleton(
160164):
161165 """Test for the entire /analyze endpoint."""
162166
167+ # Mock is_url to test calls
168+ mock_is_url = mocker .patch ("logdetective_packit.main.is_url" , side_effect = is_url )
169+
163170 # Mock the return value of requests.post().json()
164171 mock_response = mocker .Mock ()
165172 mock_response .json .return_value = {"status" : "analysis_started" , "id" : "fake-id" }
166173 mock_response .raise_for_status = mocker .Mock ()
167174 mock_external_calls ["mock_async_client" ].post .return_value = mock_response
168175
169- monkeypatch .setattr ("logdetective_packit.main.LD_URL" , "http://mock-ld-server.com/api" )
176+ monkeypatch .setattr (
177+ "logdetective_packit.main.LD_URL" , "http://mock-ld-server.com/api"
178+ )
170179 monkeypatch .setattr ("logdetective_packit.main.LD_TOKEN" , "test-token-123" )
171180 monkeypatch .setattr ("logdetective_packit.main.LD_PACKIT_TOKEN" , "secret-123" )
172181
@@ -193,8 +202,16 @@ async def test_analyze_build_skeleton(
193202 # Check that requests.post was called correctly
194203 expected_headers = {"Authorization" : "Bearer test-token-123" }
195204 # The code only takes the first log URL
196- expected_data = {"url" : "http://example.com/builder-live.log" }
197-
205+ expected_data = {
206+ "files" : [
207+ {
208+ "name" : "builder-live.log" ,
209+ "url" : "http://example.com/builder-live.log" ,
210+ }
211+ ]
212+ }
213+
214+ mock_is_url .assert_called_once_with ("http://example.com/builder-live.log" )
198215 mock_external_calls ["mock_async_client" ].post .assert_called_once_with (
199216 url = "http://mock-ld-server.com/api" ,
200217 json = expected_data ,
0 commit comments