Skip to content

Commit 3d85b9b

Browse files
committed
wip
1 parent 5b2582f commit 3d85b9b

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

tests/component/vfolder/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from ai.backend.manager.api.rest.types import RouteDeps
3232
from ai.backend.manager.api.rest.vfolder.handler import VFolderHandler
3333
from ai.backend.manager.api.rest.vfolder.registry import register_vfolder_routes
34+
from ai.backend.manager.clients.storage_proxy.session_manager import StorageSessionManager
3435
from ai.backend.manager.config.provider import ManagerConfigProvider
3536
from ai.backend.manager.data.vfolder.types import (
3637
VFolderMountPermission,
@@ -40,7 +41,6 @@
4041
from ai.backend.manager.dependencies.infrastructure.redis import ValkeyClients
4142
from ai.backend.manager.models.domain import domains
4243
from ai.backend.manager.models.resource_policy import keypair_resource_policies
43-
from ai.backend.manager.models.storage import StorageSessionManager
4444
from ai.backend.manager.models.utils import ExtendedAsyncSAEngine
4545
from ai.backend.manager.models.vfolder import (
4646
vfolder_invitations,

tests/component/vfolder/test_vfolder_quota.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from collections.abc import Callable, Coroutine
44
from typing import Any
5+
from unittest.mock import AsyncMock, MagicMock
56

67
import pytest
78

@@ -18,17 +19,34 @@
1819
UpdateQuotaResponse,
1920
)
2021
from ai.backend.common.types import QuotaScopeID, QuotaScopeType
22+
from ai.backend.manager.clients.storage_proxy.session_manager import StorageSessionManager
2123

2224
VFolderFixtureData = dict[str, Any]
2325
VFolderFactory = Callable[..., Coroutine[Any, Any, VFolderFixtureData]]
2426

2527

28+
@pytest.fixture()
29+
def storage_manager() -> StorageSessionManager:
30+
"""Mock StorageSessionManager with configured storage proxy client methods.
31+
32+
Overrides the parent conftest mock so that quota and usage endpoints work
33+
without a live storage-proxy connection.
34+
"""
35+
mock = MagicMock(spec=StorageSessionManager)
36+
mock_client = AsyncMock()
37+
mock_client.get_volume_quota.return_value = {"used_bytes": 0, "limit_bytes": 0}
38+
mock_client.update_volume_quota.return_value = None
39+
mock_client.get_folder_usage.return_value = {"used_bytes": 0, "file_count": 0}
40+
mock_client.get_used_bytes.return_value = {"used_bytes": 0}
41+
mock.get_proxy_and_volume.return_value = ("local", "volume")
42+
mock.get_manager_facing_client.return_value = mock_client
43+
return mock
44+
45+
2646
class TestStorageQuotaScope:
2747
"""Storage quota CRUD and access control via the quota scope API.
28-
All tests are xfail because they require a live storage-proxy connection
29-
that is not available in the CI environment."""
48+
Storage-proxy calls are mocked via the storage_manager fixture in conftest."""
3049

31-
@pytest.mark.xfail(strict=False, reason="Requires live storage-proxy")
3250
async def test_get_quota(
3351
self,
3452
admin_registry: BackendAIClientRegistry,
@@ -46,7 +64,6 @@ async def test_get_quota(
4664
assert isinstance(result, GetQuotaResponse)
4765
assert isinstance(result.data, dict)
4866

49-
@pytest.mark.xfail(strict=False, reason="Requires live storage-proxy")
5067
async def test_update_quota(
5168
self,
5269
admin_registry: BackendAIClientRegistry,
@@ -64,7 +81,6 @@ async def test_update_quota(
6481
)
6582
assert isinstance(result, UpdateQuotaResponse)
6683

67-
@pytest.mark.xfail(strict=False, reason="Requires live storage-proxy")
6884
async def test_get_usage(
6985
self,
7086
admin_registry: BackendAIClientRegistry,
@@ -82,7 +98,6 @@ async def test_get_usage(
8298
assert isinstance(result, GetUsageResponse)
8399
assert isinstance(result.data, dict)
84100

85-
@pytest.mark.xfail(strict=False, reason="Requires live storage-proxy")
86101
async def test_get_used_bytes(
87102
self,
88103
admin_registry: BackendAIClientRegistry,
@@ -100,7 +115,6 @@ async def test_get_used_bytes(
100115
assert isinstance(result, GetUsedBytesResponse)
101116
assert isinstance(result.data, dict)
102117

103-
@pytest.mark.xfail(strict=False, reason="Requires live storage-proxy")
104118
async def test_regular_user_can_get_own_quota(
105119
self,
106120
user_registry: BackendAIClientRegistry,
@@ -121,7 +135,6 @@ async def test_regular_user_can_get_own_quota(
121135
)
122136
assert isinstance(result, GetQuotaResponse)
123137

124-
@pytest.mark.xfail(strict=False, reason="Requires live storage-proxy")
125138
async def test_regular_user_cannot_update_others_quota(
126139
self,
127140
user_registry: BackendAIClientRegistry,

0 commit comments

Comments
 (0)