Coverage for backend / tests / test_utils / test_aws_storage.py: 100%
22 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-02 15:51 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-05-02 15:51 +0000
1from pydantic import SecretStr
2import pytest
4from app.utils.aws_storage import AWSStorage, AWSStorageError
7@pytest.mark.asyncio
8async def test_init():
9 async with AWSStorage(
10 "a_key_id", SecretStr("a_secret_key"), "bucket", "region", "arn"
11 ) as storage:
12 assert storage._client is not None
15@pytest.mark.asyncio
16async def test_double_init():
17 with pytest.raises(AWSStorageError, match="Client already initialized"):
18 async with AWSStorage(
19 "a_key_id", SecretStr("a_secret_key"), "bucket", "region", "arn"
20 ) as storage:
21 async with storage:
22 pass # pragma: no cover
25@pytest.mark.asyncio
26async def test_generate_site_id_not_initialized():
27 storage = AWSStorage(
28 "a_key_id", SecretStr("a_secret_key"), "bucket", "region", "arn"
29 )
30 with pytest.raises(AWSStorageError, match="Client not initialized"):
31 await storage._generate_site_id()
34@pytest.mark.asyncio
35async def test_get_file_not_initialized():
36 storage = AWSStorage(
37 "a_key_id", SecretStr("a_secret_key"), "bucket", "region", "arn"
38 )
39 with pytest.raises(AWSStorageError, match="Client not initialized"):
40 await storage.get_file("site_id", "file_name")