037: fix 99 failing tests — missing await after async migration
Fixed async/sync boundary bugs across 14 test files. Root cause: async def methods called without await in sync test functions. Fixed files: - test_translate_jobs.py (10): create_job/get_job/update_job/delete_job - test_translate_scheduler.py (5): create_schedule/update/delete - test_datasets.py (14): AsyncMock + corrected patch target - test_mapping_service.py (11): sync_environment + MockSupersetClient - test_defensive_guards.py (6): GitService/SupersetClient guards - test_maintenance_service.py (29): all 6 maintenance services - test_dry_run_orchestrator.py (1): run() without await - test_dashboards_api.py (23): registry client via AsyncMock - test_validation_tasks.py (4): trailing slash in POST URL - test_superset_matrix.py (3): AsyncMock for compile_preview - test_payload_reduction.py (6): LLMClient._optimize_image wrapper - test_compliance_task_integration.py (2): event_bus ref - test_smoke_plugins.py (1): flusher_stop_event fallback - test_task_manager.py (1): _flusher_stop_event/thread fallback Remaining 31 failures in test_task_manager.py (29) and test_smoke_plugins.py (1) are pre-existing async migration gaps (_flusher_stop_event moved to event_bus), not from this PR.
This commit is contained in:
@@ -278,7 +278,7 @@ def test_get_dashboard_detail_success(mock_deps):
|
||||
"chart_count": 0,
|
||||
"dataset_count": 0,
|
||||
}
|
||||
mock_client.get_dashboard_detail.return_value = detail_payload
|
||||
mock_client.get_dashboard_detail = AsyncMock(return_value=detail_payload)
|
||||
mock_client_cls.return_value = mock_client
|
||||
|
||||
response = client.get("/api/dashboards/42?env_id=prod")
|
||||
@@ -379,7 +379,10 @@ def test_get_dashboard_tasks_history_sorting(mock_deps):
|
||||
# #region test_get_dashboard_thumbnail_success [C:2] [TYPE Function]
|
||||
# @RELATION BINDS_TO ->[TestDashboardsApi]
|
||||
def test_get_dashboard_thumbnail_success(mock_deps):
|
||||
with patch("src.api.routes.dashboards._detail_routes.SupersetClient") as mock_client_cls:
|
||||
with (
|
||||
patch("src.api.routes.dashboards._detail_routes.SupersetClient") as mock_client_cls,
|
||||
patch("src.api.routes.dashboards._detail_routes.get_superset_client") as mock_get_client,
|
||||
):
|
||||
mock_env = MagicMock()
|
||||
mock_env.id = "prod"
|
||||
mock_env.name = "Production"
|
||||
@@ -390,15 +393,17 @@ def test_get_dashboard_thumbnail_success(mock_deps):
|
||||
mock_env.timeout = 30
|
||||
mock_deps["config"].get_environments.return_value = [mock_env]
|
||||
mock_client = MagicMock()
|
||||
mock_client_cls.return_value = mock_client
|
||||
|
||||
mock_response = MagicMock(
|
||||
status_code=200, content=b"img", headers={"Content-Type": "image/png"}
|
||||
)
|
||||
mock_client.network.request.side_effect = (
|
||||
lambda method, endpoint, **kw: {"image_url": "url"}
|
||||
if method == "POST"
|
||||
else mock_response
|
||||
)
|
||||
mock_client_cls.return_value = mock_client
|
||||
mock_async_client = AsyncMock()
|
||||
mock_async_client.request = AsyncMock(side_effect=[
|
||||
{"image_url": "http://localhost:8088/api/v1/dashboard/42/thumbnail/abc123/"},
|
||||
mock_response,
|
||||
])
|
||||
mock_get_client.return_value = mock_async_client
|
||||
|
||||
response = client.get("/api/dashboards/42/thumbnail?env_id=prod")
|
||||
assert response.status_code == 200
|
||||
@@ -423,7 +428,10 @@ def test_get_dashboard_thumbnail_env_not_found(mock_deps):
|
||||
# @RELATION BINDS_TO ->[TestDashboardsApi]
|
||||
def test_get_dashboard_thumbnail_202(mock_deps):
|
||||
"""@POST: Returns 202 when thumbnail is being prepared by Superset."""
|
||||
with patch("src.api.routes.dashboards._detail_routes.SupersetClient") as mock_client_cls:
|
||||
with (
|
||||
patch("src.api.routes.dashboards._detail_routes.SupersetClient") as mock_client_cls,
|
||||
patch("src.api.routes.dashboards._detail_routes.get_superset_client") as mock_get_client,
|
||||
):
|
||||
mock_env = MagicMock()
|
||||
mock_env.id = "prod"
|
||||
mock_env.name = "Production"
|
||||
@@ -434,17 +442,18 @@ def test_get_dashboard_thumbnail_202(mock_deps):
|
||||
mock_env.timeout = 30
|
||||
mock_deps["config"].get_environments.return_value = [mock_env]
|
||||
mock_client = MagicMock()
|
||||
mock_client_cls.return_value = mock_client
|
||||
|
||||
# POST cache_dashboard_screenshot returns image_url
|
||||
mock_client.network.request.side_effect = [
|
||||
{"image_url": "/api/v1/dashboard/42/thumbnail/abc123/"}, # POST
|
||||
mock_async_client = AsyncMock()
|
||||
mock_async_client.request = AsyncMock(side_effect=[
|
||||
{"image_url": "http://localhost:8088/api/v1/dashboard/42/thumbnail/abc123/"}, # POST
|
||||
MagicMock(
|
||||
status_code=202,
|
||||
json=lambda: {"message": "Thumbnail is being generated"},
|
||||
headers={"Content-Type": "application/json"},
|
||||
), # GET thumbnail -> 202
|
||||
]
|
||||
mock_client_cls.return_value = mock_client
|
||||
])
|
||||
mock_get_client.return_value = mock_async_client
|
||||
|
||||
response = client.get("/api/dashboards/42/thumbnail?env_id=prod")
|
||||
assert response.status_code == 202
|
||||
|
||||
Reference in New Issue
Block a user