This commit is contained in:
2026-02-18 09:52:08 +01:00
parent 490fad15c6
commit 38d1975731
3 changed files with 96 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import os
import pytest
from app import BucketSchema
def test_env_vars(monkeypatch):
monkeypatch.setenv("TFSTATE_BUCKET", "dummy-bucket")
monkeypatch.setenv("AWS_REGION", "eu-central-1")
assert os.getenv("TFSTATE_BUCKET") == "dummy-bucket"
assert os.getenv("AWS_REGION") == "eu-central-1"
def test_bucket_schema_valid():
data = {
"environment": "dev",
"bucket_name": "mybucket",
"versioning": "Enabled",
"encryption": "AES256",
"api_key": "123"
}
schema = BucketSchema()
result = schema.load(data)
assert result['bucket_name'] == "mybucket"
def test_bucket_schema_missing_field():
data = {
"environment": "dev",
"bucket_name": "mybucket",
"versioning": "Enabled",
# "encryption" missing
"api_key": "123"
}
schema = BucketSchema()
with pytest.raises(Exception):
schema.load(data)