-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Sanghun Lee <[email protected]> Backported-from: main (24.12) Backported-to: 24.09 Backport-of: 3047
- Loading branch information
1 parent
76dc7b7
commit e5972cb
Showing
7 changed files
with
377 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix regression of outdated `vfolder` GQL resolver. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from types import SimpleNamespace | ||
from unittest.mock import AsyncMock, MagicMock | ||
|
||
import pytest | ||
|
||
from ai.backend.manager.models.base import batch_result_in_scalar_stream | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_batch_result_in_scalar_stream(): | ||
key_list = [1, 2, 3] | ||
|
||
mock_rows = [SimpleNamespace(id=1, data="data1"), SimpleNamespace(id=3, data="data3")] | ||
|
||
async def mock_stream_scalars(query): | ||
for row in mock_rows: | ||
yield row | ||
|
||
mock_db_sess = MagicMock() | ||
mock_db_sess.stream_scalars = AsyncMock(side_effect=mock_stream_scalars) | ||
|
||
def mock_from_row(graph_ctx, row): | ||
return {"id": row.id, "data": row.data} | ||
|
||
mock_obj_type = MagicMock() | ||
mock_obj_type.from_row.side_effect = mock_from_row | ||
|
||
key_getter = lambda row: row.id | ||
graph_ctx = None | ||
result = await batch_result_in_scalar_stream( | ||
graph_ctx, | ||
mock_db_sess, | ||
query=None, # We use mocking instead of using query here | ||
obj_type=mock_obj_type, | ||
key_list=key_list, | ||
key_getter=key_getter, | ||
) | ||
|
||
expected_result = [{"id": 1, "data": "data1"}, None, {"id": 3, "data": "data3"}] | ||
assert result == expected_result |
Oops, something went wrong.