97691fd752
---ci--- project: nova-platform phase: 1 milestone: v1.0 status: complete phase_role: execution ---/ci--- P1 complete: contract schema, stack schema, environment schema, resolver, env_check, 10 sample contracts, 36 tests. REQ-01..06, 23..28 covered.
34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
"""Tests for core/environment_check.py — REQ-24."""
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from core.environment_check import check, EnvironmentNotFoundError
|
|
|
|
|
|
class TestCheckHappyPath:
|
|
def test_dev_returns_dict(self, repo_root):
|
|
env = check("dev", repo_root / "core" / "environments")
|
|
assert env["name"] == "dev"
|
|
assert env["region"] == "us-east-1"
|
|
assert env["state_backend"]["bucket"] == "nova-tfstate-dev-us-east-1"
|
|
assert env["state_backend"]["lock_table"] == "nova-tfstate-locks"
|
|
|
|
def test_returns_all_required_fields(self, repo_root):
|
|
env = check("dev", repo_root / "core" / "environments")
|
|
for f in ("name", "account_id", "region", "state_backend", "network"):
|
|
assert f in env, f"missing {f}"
|
|
|
|
|
|
class TestCheckErrors:
|
|
def test_missing_env_raises(self, repo_root, tmp_path):
|
|
with pytest.raises(EnvironmentNotFoundError):
|
|
check("nonexistent", tmp_path)
|
|
|
|
def test_missing_env_message_names_env(self, repo_root, tmp_path):
|
|
try:
|
|
check("qa", tmp_path)
|
|
assert False, "should have raised"
|
|
except EnvironmentNotFoundError as e:
|
|
assert "qa" in str(e) |