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
29 changes: 27 additions & 2 deletions azure-quantum/tests/unit/local/mock_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,12 @@ def get_sas_uri(
*,
blob_details: object,
) -> SasUriResponse:
# Return a dummy SAS URI suitable for tests that might exercise storage
return SasUriResponse({"sasUri": "https://example.com/container?sas-token"})
# Return a dummy SAS URI suitable for tests that might exercise storage.
# Include container/blob names (when provided) to make debugging easier.
container_name = getattr(blob_details, "container_name", None) or "container"
blob_name = getattr(blob_details, "blob_name", None)
path = container_name if not blob_name else f"{container_name}/{blob_name}"
return SasUriResponse({"sasUri": f"https://example.com/{path}?sas-token"})


class MockWorkspaceMgmtClient:
Expand Down Expand Up @@ -562,6 +566,27 @@ def _create_client(self) -> WorkspaceClient: # type: ignore[override]
auth_policy = self._connection_params.get_auth_policy()
return MockWorkspaceClient(authentication_policy=auth_policy)

def get_container_uri(
self,
job_id: Optional[str] = None,
container_name: Optional[str] = None,
container_name_format: Optional[str] = "job-{job_id}",
) -> str:
"""Return a stable, offline container SAS URI.

The real Workspace implementation may attempt to create/check containers
via azure-storage-blob. For local/offline unit tests we avoid any network
calls and just return a mock SAS URI from the mocked `{workspace}/storage`
operation.
"""
if container_name is None:
if job_id is not None:
container_name = container_name_format.format(job_id=job_id)
else:
container_name = f"{self.name}-data"

return self._get_linked_storage_sas_uri(container_name)


def seed_jobs(ws: WorkspaceMock) -> None:
base = datetime.now(UTC) - timedelta(days=10)
Expand Down
Loading
Loading