Skip to content

Commit 7875ae6

Browse files
authored
Merge pull request #1257 from tisnik/lcore-974-fixed-issues-found-by-pyright-linter-
LCORE-974: fixed issues found by Pyright linter
2 parents f0647c7 + b055357 commit 7875ae6

5 files changed

Lines changed: 37 additions & 12 deletions

File tree

tests/unit/models/config/test_authentication_configuration.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,12 @@ def test_authentication_configuration_in_config_noop() -> None:
303303
color_log=True,
304304
access_log=True,
305305
workers=1,
306+
root_path="/.",
306307
),
307308
llama_stack=LlamaStackConfiguration(
308309
use_as_library_client=True,
309310
library_client_config_path="tests/configuration/run.yaml",
310-
url="http://localhost",
311+
url=AnyHttpUrl("http://localhost"),
311312
api_key=SecretStr(""),
312313
timeout=60,
313314
),
@@ -342,11 +343,12 @@ def test_authentication_configuration_skip_readiness_probe() -> None:
342343
color_log=True,
343344
access_log=True,
344345
workers=1,
346+
root_path="/.",
345347
),
346348
llama_stack=LlamaStackConfiguration(
347349
use_as_library_client=True,
348350
library_client_config_path="tests/configuration/run.yaml",
349-
url="http://localhost",
351+
url=AnyHttpUrl("http://localhost"),
350352
api_key=SecretStr(""),
351353
timeout=60,
352354
),
@@ -389,11 +391,12 @@ def test_authentication_configuration_in_config_k8s() -> None:
389391
color_log=True,
390392
access_log=True,
391393
workers=1,
394+
root_path="/.",
392395
),
393396
llama_stack=LlamaStackConfiguration(
394397
use_as_library_client=True,
395398
library_client_config_path="tests/configuration/run.yaml",
396-
url="http://localhost",
399+
url=AnyHttpUrl("http://localhost"),
397400
api_key=SecretStr(""),
398401
timeout=60,
399402
),
@@ -446,11 +449,12 @@ def test_authentication_configuration_in_config_rh_identity() -> None:
446449
color_log=True,
447450
access_log=True,
448451
workers=1,
452+
root_path="/.",
449453
),
450454
llama_stack=LlamaStackConfiguration(
451455
use_as_library_client=True,
452456
library_client_config_path="tests/configuration/run.yaml",
453-
url="http://localhost",
457+
url=AnyHttpUrl("http://localhost"),
454458
api_key=SecretStr(""),
455459
timeout=60,
456460
),
@@ -493,11 +497,12 @@ def test_authentication_configuration_in_config_jwktoken() -> None:
493497
color_log=True,
494498
access_log=True,
495499
workers=1,
500+
root_path="/.",
496501
),
497502
llama_stack=LlamaStackConfiguration(
498503
use_as_library_client=True,
499504
library_client_config_path="tests/configuration/run.yaml",
500-
url="http://localhost",
505+
url=AnyHttpUrl("http://localhost"),
501506
api_key=SecretStr(""),
502507
timeout=60,
503508
),

tests/unit/models/config/test_llama_stack_configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Unit tests for LlamaStackConfiguration model."""
22

33
import pytest
4-
from pydantic import ValidationError
4+
from pydantic import ValidationError, AnyHttpUrl
55

66
from utils.checks import InvalidConfigurationError
77

@@ -25,7 +25,7 @@ def test_llama_stack_configuration_constructor() -> None:
2525

2626
llama_stack_configuration = LlamaStackConfiguration(
2727
use_as_library_client=False,
28-
url="http://localhost",
28+
url=AnyHttpUrl("http://localhost"),
2929
library_client_config_path=None,
3030
api_key=None,
3131
timeout=60,

tests/unit/utils/test_common.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from logging import Logger
44

5+
from pydantic import AnyHttpUrl
56
from pytest_mock import MockerFixture
67

78
import pytest
@@ -37,10 +38,11 @@ async def test_register_mcp_servers_empty_list(mocker: MockerFixture) -> None:
3738
workers=10,
3839
color_log=True,
3940
access_log=True,
41+
root_path="/.",
4042
),
4143
llama_stack=LlamaStackConfiguration(
4244
use_as_library_client=False,
43-
url="http://localhost:8321",
45+
url=AnyHttpUrl("http://localhost:8321"),
4446
library_client_config_path=None,
4547
api_key=None,
4648
timeout=60,
@@ -98,10 +100,11 @@ async def test_register_mcp_servers_single_server_not_registered(
98100
workers=10,
99101
color_log=True,
100102
access_log=True,
103+
root_path="/.",
101104
),
102105
llama_stack=LlamaStackConfiguration(
103106
use_as_library_client=False,
104-
url="http://localhost:8321",
107+
url=AnyHttpUrl("http://localhost:8321"),
105108
library_client_config_path=None,
106109
api_key=None,
107110
timeout=60,
@@ -161,10 +164,11 @@ async def test_register_mcp_servers_single_server_already_registered(
161164
workers=10,
162165
color_log=True,
163166
access_log=True,
167+
root_path="/.",
164168
),
165169
llama_stack=LlamaStackConfiguration(
166170
use_as_library_client=False,
167-
url="http://localhost:8321",
171+
url=AnyHttpUrl("http://localhost:8321"),
168172
library_client_config_path=None,
169173
api_key=None,
170174
timeout=60,
@@ -233,10 +237,11 @@ async def test_register_mcp_servers_multiple_servers_mixed_registration(
233237
workers=10,
234238
color_log=True,
235239
access_log=True,
240+
root_path="/.",
236241
),
237242
llama_stack=LlamaStackConfiguration(
238243
use_as_library_client=False,
239-
url="http://localhost:8321",
244+
url=AnyHttpUrl("http://localhost:8321"),
240245
library_client_config_path=None,
241246
api_key=None,
242247
timeout=60,
@@ -304,10 +309,11 @@ async def test_register_mcp_servers_with_custom_provider(mocker: MockerFixture)
304309
workers=10,
305310
color_log=True,
306311
access_log=True,
312+
root_path="/.",
307313
),
308314
llama_stack=LlamaStackConfiguration(
309315
use_as_library_client=False,
310-
url="http://localhost:8321",
316+
url=AnyHttpUrl("http://localhost:8321"),
311317
library_client_config_path=None,
312318
api_key=None,
313319
timeout=60,
@@ -375,6 +381,7 @@ async def test_register_mcp_servers_async_with_library_client(
375381
workers=10,
376382
color_log=True,
377383
access_log=True,
384+
root_path="/.",
378385
),
379386
llama_stack=LlamaStackConfiguration(
380387
use_as_library_client=True,

tests/unit/utils/test_mcp_headers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ def test_extracts_matching_headers(self) -> None:
203203
name="rbac",
204204
url="http://rbac:8080",
205205
headers=["x-rh-identity", "x-request-id"],
206+
provider_id="xyzzy",
206207
)
207208
request_headers = {
208209
"x-rh-identity": "encoded-identity-value",
@@ -221,6 +222,7 @@ def test_skips_missing_headers(self) -> None:
221222
name="rbac",
222223
url="http://rbac:8080",
223224
headers=["x-rh-identity", "x-missing-header"],
225+
provider_id="xyzzy",
224226
)
225227
request_headers = {
226228
"x-rh-identity": "identity-value",
@@ -234,6 +236,7 @@ def test_empty_allowlist(self) -> None:
234236
name="rbac",
235237
url="http://rbac:8080",
236238
headers=[],
239+
provider_id="xyzzy",
237240
)
238241
request_headers = {"x-rh-identity": "identity-value"}
239242
result = extract_propagated_headers(server, request_headers)
@@ -245,6 +248,7 @@ def test_empty_request_headers(self) -> None:
245248
name="rbac",
246249
url="http://rbac:8080",
247250
headers=["x-rh-identity"],
251+
provider_id="xyzzy",
248252
)
249253
result = extract_propagated_headers(server, {})
250254
assert not result
@@ -255,6 +259,7 @@ def test_case_insensitive_lookup(self) -> None:
255259
name="rbac",
256260
url="http://rbac:8080",
257261
headers=["X-Rh-Identity"],
262+
provider_id="xyzzy",
258263
)
259264
# FastAPI/Starlette lowercases header names internally
260265
request_headers = {"x-rh-identity": "identity-value"}
@@ -267,6 +272,7 @@ def test_case_insensitive_lookup_mixed_case_request(self) -> None:
267272
name="rbac",
268273
url="http://rbac:8080",
269274
headers=["x-rh-identity"],
275+
provider_id="xyzzy",
270276
)
271277
# Plain dict with mixed-case keys (not Starlette Headers)
272278
request_headers = {"X-RH-Identity": "identity-value"}
@@ -278,6 +284,7 @@ def test_no_headers_field_configured(self) -> None:
278284
server = ModelContextProtocolServer(
279285
name="rbac",
280286
url="http://rbac:8080",
287+
provider_id="xyzzy",
281288
)
282289
request_headers = {"x-rh-identity": "identity-value"}
283290
result = extract_propagated_headers(server, request_headers)

tests/unit/utils/test_responses.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ async def test_get_mcp_tools_with_propagated_headers(
633633
name="rbac",
634634
url="http://rbac:8080",
635635
headers=["x-rh-identity", "x-request-id"],
636+
provider_id="provider",
636637
),
637638
]
638639
mock_config = mocker.Mock()
@@ -667,6 +668,7 @@ async def test_get_mcp_tools_propagated_headers_do_not_overwrite_auth_headers(
667668
url="http://rbac:8080",
668669
authorization_headers={"Authorization": str(secret_file)},
669670
headers=["Authorization", "x-rh-identity"],
671+
provider_id="provider",
670672
),
671673
]
672674
mock_config = mocker.Mock()
@@ -697,6 +699,7 @@ async def test_get_mcp_tools_propagated_headers_missing_from_request(
697699
name="rbac",
698700
url="http://rbac:8080",
699701
headers=["x-rh-identity", "x-missing"],
702+
provider_id="provider",
700703
),
701704
]
702705
mock_config = mocker.Mock()
@@ -722,6 +725,7 @@ async def test_get_mcp_tools_propagated_headers_no_request_headers(
722725
name="rbac",
723726
url="http://rbac:8080",
724727
headers=["x-rh-identity"],
728+
provider_id="provider",
725729
),
726730
]
727731
mock_config = mocker.Mock()
@@ -743,6 +747,7 @@ async def test_get_mcp_tools_propagated_headers_additive_with_mcp_headers(
743747
url="http://server1:8080",
744748
authorization_headers={"Authorization": "client"},
745749
headers=["x-rh-identity"],
750+
provider_id="provider",
746751
),
747752
]
748753
mock_config = mocker.Mock()
@@ -773,6 +778,7 @@ async def test_get_mcp_tools_mixed_case_precedence(
773778
url="http://rbac:8080",
774779
authorization_headers={"Authorization": str(secret_file)},
775780
headers=["authorization", "x-rh-identity"],
781+
provider_id="provider",
776782
),
777783
]
778784
mock_config = mocker.Mock()

0 commit comments

Comments
 (0)