Skip to content

Commit 7ffb3bc

Browse files
Add thorough zipped content verification in blueprint tests
- Update test_upload_directory and test_validate_directory to inspect ZIP bytes - Verify file presence and content in the generated archives - Ensure robust testing of directory zipping logic Co-authored-by: rnovatorov <20299819+rnovatorov@users.noreply.github.com>
1 parent 19afd7e commit 7ffb3bc

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tests/unit/test_http/test_api/test_blueprints/test_client.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Unit tests for the Blueprints HTTP API client."""
22

3+
import io
4+
import zipfile
35
from unittest.mock import AsyncMock, MagicMock
46

57
import httpx
@@ -103,10 +105,14 @@ async def test_upload_directory(blueprints_client, mock_client, tmp_path):
103105
blueprint = await blueprints_client.upload_directory(path=bp_dir)
104106

105107
assert blueprint.id == "bp_123"
106-
assert mock_client.post.call_count == 1
108+
mock_client.post.assert_called_once()
107109
args, kwargs = mock_client.post.call_args
108110
assert args[0] == "v3/blueprints/upload"
109-
assert isinstance(kwargs["content"], bytes)
111+
112+
zipped_content = kwargs["content"]
113+
with zipfile.ZipFile(io.BytesIO(zipped_content)) as zf:
114+
assert "main.lua" in zf.namelist()
115+
assert zf.read("main.lua") == b"print('hello')"
110116

111117

112118
@pytest.mark.asyncio
@@ -205,7 +211,11 @@ async def test_validate_directory(blueprints_client, mock_client, tmp_path):
205211

206212
await blueprints_client.validate_directory(path=bp_dir)
207213

208-
assert mock_client.post.call_count == 1
214+
mock_client.post.assert_called_once()
209215
args, kwargs = mock_client.post.call_args
210216
assert args[0] == "v3/blueprints/validate"
211-
assert isinstance(kwargs["content"], bytes)
217+
218+
zipped_content = kwargs["content"]
219+
with zipfile.ZipFile(io.BytesIO(zipped_content)) as zf:
220+
assert "main.lua" in zf.namelist()
221+
assert zf.read("main.lua") == b"print('hello')"

0 commit comments

Comments
 (0)