Skip to content

Commit 6379103

Browse files
committed
modify test files
1 parent 6e8795c commit 6379103

3 files changed

Lines changed: 27 additions & 26 deletions

File tree

test/backend/app/test_idata_app.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -515,31 +515,30 @@ def test_router_prefix(self):
515515
assert router.prefix == "/idata"
516516

517517
def test_routes_registered(self):
518-
"""Test that all routes are registered."""
519-
app = _build_app()
520-
routes = [route.path for route in app.routes]
521-
522-
assert "/idata/knowledge-space" in routes
523-
assert "/idata/datasets" in routes
518+
"""Test that all routes are registered on the router."""
519+
# Get routes directly from the router
520+
route_paths = [route.path for route in router.routes]
521+
522+
# The routes already include the router prefix
523+
assert "/idata/knowledge-space" in route_paths
524+
assert "/idata/datasets" in route_paths
524525

525526
def test_router_methods(self):
526527
"""Test that routes have correct HTTP methods."""
527-
app = _build_app()
528-
529-
# Find routes by path
528+
# Check routes directly from the router
530529
knowledge_space_route = None
531530
datasets_route = None
532-
533-
for route in app.routes:
534-
if hasattr(route, 'path'):
535-
if route.path == "/idata/knowledge-space":
536-
knowledge_space_route = route
537-
elif route.path == "/idata/datasets":
538-
datasets_route = route
539-
531+
532+
for route in router.routes:
533+
# Match against the full path including prefix
534+
if route.path == "/idata/knowledge-space":
535+
knowledge_space_route = route
536+
elif route.path == "/idata/datasets":
537+
datasets_route = route
538+
540539
assert knowledge_space_route is not None
541540
assert datasets_route is not None
542-
543-
# Check HTTP methods
544-
assert "GET" in [method for method in knowledge_space_route.methods]
545-
assert "GET" in [method for method in datasets_route.methods]
541+
542+
# Check HTTP methods (APIRoute has 'methods' attribute)
543+
assert "GET" in knowledge_space_route.methods
544+
assert "GET" in datasets_route.methods

test/backend/app/test_northbound_base_app.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,14 @@ def test_cors_middleware_configuration(self):
274274

275275
def test_router_inclusion(self):
276276
"""The main northbound router should be included."""
277-
routes = [route.path for route in app.routes]
277+
from fastapi.routing import APIRoute
278+
routes = [route.path for route in app.routes if isinstance(route, APIRoute)]
278279
self.assertIn("/dummy", routes)
279280

280281
def test_a2a_router_inclusion(self):
281282
"""A2A router should be registered under /nb/a2a."""
282-
routes = [route.path for route in app.routes]
283+
from fastapi.routing import APIRoute
284+
routes = [route.path for route in app.routes if isinstance(route, APIRoute)]
283285
self.assertIn("/nb/a2a/{endpoint_id}/.well-known/agent-card.json", routes)
284286
self.assertIn("/nb/a2a/{endpoint_id}/v1", routes)
285287
self.assertIn("/nb/a2a/{endpoint_id}/message:send", routes)

test/backend/services/test_data_process_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ async def read(self):
361361
Image.new('L', (9, 9), color=10),
362362
]
363363

364-
result = asyncio.run(self.service._load_image(session, "http://example.com/a.bin"))
364+
result = asyncio.run(self.service._load_image(session, "https://example.com/a.bin"))
365365

366366
self.assertEqual(result.mode, 'RGB')
367367
temp_file.write.assert_called_once_with(b"not-directly-readable")
@@ -396,14 +396,14 @@ async def read(self):
396396
Image.new('RGBA', (9, 9), color=(1, 2, 3, 4)),
397397
]
398398

399-
result = asyncio.run(self.service._load_image(session, "http://example.com/a.bin"))
399+
result = asyncio.run(self.service._load_image(session, "https://example.com/a.bin"))
400400

401401
self.assertEqual(result.mode, 'RGB')
402402
mock_unlink.assert_called_once_with("temp-image.bin")
403403

404404
def test_load_image_svg_is_filtered(self):
405405
"""SVG URLs are skipped before any HTTP request."""
406-
result = asyncio.run(self.service._load_image(MagicMock(), "http://example.com/a.svg"))
406+
result = asyncio.run(self.service._load_image(MagicMock(), "https://example.com/a.svg"))
407407

408408
self.assertIsNone(result)
409409

0 commit comments

Comments
 (0)