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:
2026-06-05 15:43:35 +03:00
parent 7f1937f10b
commit fbe0ba122c
16 changed files with 278 additions and 169 deletions

View File

@@ -69,20 +69,36 @@ async def get_client(
slot = _registry.get(env_id)
if slot is not None:
return slot.async_client
# Convert Environment model or dict to config dict
if hasattr(env, "model_dump"):
# Convert Environment model to config dict with the format expected by AsyncAPIClient
if hasattr(env, "url") and hasattr(env, "username"):
# Environment model — build config like SupersetClientBase.__init__ does
config = {
"base_url": env.url,
"auth": {
"username": env.username,
"password": env.password,
"provider": "db",
"refresh": "true",
},
}
verify_ssl = getattr(env, "verify_ssl", True)
timeout = getattr(env, "timeout", request_timeout)
elif hasattr(env, "model_dump"):
config = env.model_dump()
elif hasattr(env, "dict"):
config = env.dict()
verify_ssl = config.get("verify_ssl", True)
timeout = request_timeout
elif isinstance(env, dict):
config = env
verify_ssl = config.get("verify_ssl", True)
timeout = request_timeout
else:
config = {}
verify_ssl = config.get("verify_ssl", True)
verify_ssl = True
timeout = request_timeout
async_client = AsyncAPIClient(
config=config,
verify_ssl=verify_ssl,
timeout=request_timeout,
timeout=timeout,
)
semaphore = asyncio.Semaphore(connection_pool_size)
lock = asyncio.Lock()