35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from fixture_loading import ENVELOPES, load_yaml
|
|
|
|
from emergent_security.envelope import DefaultEnvelope
|
|
from emergent_security.scales import RiskScales
|
|
from emergent_security.tenant import PlatformTenantEnvelope, TenantContext, TenantGovernance
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def scales() -> RiskScales:
|
|
return RiskScales.load(ENVELOPES / "scales.yaml")
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def default_envelope() -> DefaultEnvelope:
|
|
return DefaultEnvelope.load(ENVELOPES / "default-envelope.yaml")
|
|
|
|
|
|
@pytest.fixture
|
|
def tenant_context_from():
|
|
"""Build a TenantContext from a fixture context dict (paths relative to envelopes/)."""
|
|
|
|
def build(context: dict) -> TenantContext | None:
|
|
if "platform_envelope" not in context:
|
|
return None
|
|
platform = PlatformTenantEnvelope.from_dict(load_yaml(ENVELOPES / context["platform_envelope"]))
|
|
governance = None
|
|
if "tenant_governance" in context:
|
|
governance = TenantGovernance.from_dict(load_yaml(ENVELOPES / context["tenant_governance"]))
|
|
return TenantContext(platform=platform, governance=governance)
|
|
|
|
return build
|