import all
This commit is contained in:
commit
881baaa1ed
25 files changed
+1779
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import pytest
|
||||
import asyncio
|
||||
from unittest.mock import AsyncMock, patch
|
||||
from asquare import acat2id
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_acat2id_returns_item_ids():
|
||||
mock_result = AsyncMock()
|
||||
mock_result.model_dump_json.return_value = (
|
||||
'{"objects": [{"id": "item1"}, {"id": "item2"}]}'
|
||||
)
|
||||
with patch("asquare.client.catalog.search", return_value=mock_result):
|
||||
item_ids = await acat2id("test_cat_id")
|
||||
assert item_ids == ["item1", "item2"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_acat2id_empty_objects():
|
||||
mock_result = AsyncMock()
|
||||
mock_result.model_dump_json.return_value = '{"objects": []}'
|
||||
with patch("asquare.client.catalog.search", return_value=mock_result):
|
||||
item_ids = await acat2id("empty_cat_id")
|
||||
assert item_ids == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_acat2id_no_objects_key():
|
||||
mock_result = AsyncMock()
|
||||
mock_result.model_dump_json.return_value = "{}"
|
||||
with patch("asquare.client.catalog.search", return_value=mock_result):
|
||||
item_ids = await acat2id("no_objects_cat_id")
|
||||
assert item_ids == []
|
||||
Reference in new issue
Block a user