Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,16 @@ def _wire_credential(svc_cls, *, account_key=None, account_name="myacct",
credential_cls_name="DefaultAzureCredential"):
svc = _wire(svc_cls)
svc.account_name = account_name
# Use a dedicated stub class per credential type so that ``type(cred).__name__``
# reflects the desired credential class without mutating the shared ``MagicMock``
# class metadata (which would leak across tests and make order-dependent failures).
if credential_cls_name == "AccountKey":
cred = MagicMock()
cred_cls = type("StorageSharedKeyCredential", (), {})
cred = cred_cls()
cred.account_key = account_key
type(cred).__name__ = "StorageSharedKeyCredential"
else:
cred = MagicMock(spec=[])
type(cred).__name__ = credential_cls_name
cred_cls = type(credential_cls_name, (), {})
cred = cred_cls()
svc.credential = cred
return svc

Expand Down
3 changes: 0 additions & 3 deletions src/backend-api/src/tests/sas/storage/blob/test_config.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
"""Tests for libs/sas/storage/blob/config.py."""

import pytest

from libs.sas.storage.blob import config as blob_config_module
from libs.sas.storage.blob.config import (
BlobHelperConfig,
create_config,
default_config,
get_config,
set_config,
)
Expand Down
15 changes: 10 additions & 5 deletions src/backend-api/src/tests/sas/storage/blob/test_helper_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,21 @@ def test_delete_container_blobs_present_message_no_force(self, blob_service_mock

def _wire_credential(blob_service_mock, *, account_key=None, account_name="myacct",
credential_cls_name="DefaultAzureCredential"):
"""Make the helper's blob_service_client respond like an Azure SDK client."""
"""Make the helper's blob_service_client respond like an Azure SDK client.

Uses a dedicated stub class per credential type so that ``type(cred).__name__``
reflects the desired credential class without mutating the shared ``MagicMock``
class metadata (which would leak across tests).
"""
h = _make_helper(blob_service_mock)
h.blob_service_client.account_name = account_name
if credential_cls_name == "AccountKey":
cred = MagicMock()
cred_cls = type("StorageSharedKeyCredential", (), {})
cred = cred_cls()
cred.account_key = account_key
type(cred).__name__ = "StorageSharedKeyCredential"
else:
cred = MagicMock(spec=[])
type(cred).__name__ = credential_cls_name
cred_cls = type(credential_cls_name, (), {})
cred = cred_cls()
h.blob_service_client.credential = cred
return h

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
# Licensed under the MIT License.

import asyncio
from datetime import datetime
from types import SimpleNamespace
from unittest.mock import AsyncMock, MagicMock
from unittest.mock import AsyncMock

from libs.agent_framework.agent_speaking_capture import AgentSpeakingCaptureMiddleware

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from __future__ import annotations

import inspect
from unittest.mock import MagicMock, patch

import pytest
Expand Down Expand Up @@ -71,7 +70,7 @@ def test_init_loads_app_config_when_url_set(self, patches_chain, tmp_path):
env_file = tmp_path / ".env"
env_file.write_text("X=1")
_App = _build_concrete()
app = _App(env_file_path=str(env_file))
_App(env_file_path=str(env_file))
patches_chain["ac_helper"].assert_called_once()
# The helper instance had its method invoked
helper_instance = patches_chain["ac_helper"].return_value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,6 @@ def test_output_cleanup_no_account(self):

def test_output_cleanup_refuses_broad_prefix(self):
s = _service()
tp = _task_param()
# Force output_file_folder to broad path matching "<pid>"
tp = Analysis_TaskParam(
process_id="p1",
Expand Down Expand Up @@ -784,9 +783,6 @@ def test_start_service_runs_and_completes(self):
s._ensure_queues_exist = AsyncMock()
s._control_watcher_loop = AsyncMock()

async def _no_op_worker(self_, worker_id):
return None

# Patch worker loop to immediate return
s._worker_loop = lambda wid: asyncio.sleep(0) # type: ignore[assignment]
_run(s.start_service())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Licensed under the MIT License.

import asyncio
from datetime import UTC, datetime
from types import SimpleNamespace
from unittest.mock import AsyncMock, MagicMock, patch

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import asyncio
from unittest.mock import AsyncMock, MagicMock, patch

import pytest

import utils.agent_telemetry as at
from utils.agent_telemetry import ProcessStatus, TelemetryManager

Expand Down
Loading