tests/conftest.py
1.8 KB · 72 lines · python Raw
1 """Shared fixtures for pqc-ai-governance tests."""
2
3 from __future__ import annotations
4
5 import pytest
6
7 from quantumshield.identity.agent import AgentIdentity
8
9 from pqc_ai_governance import (
10 GovernanceNode,
11 GovernanceProposal,
12 NodeRegistry,
13 ProposalKind,
14 )
15
16
17 @pytest.fixture
18 def alice() -> GovernanceNode:
19 return GovernanceNode(identity=AgentIdentity.create("alice"), name="alice", weight=1)
20
21
22 @pytest.fixture
23 def bob() -> GovernanceNode:
24 return GovernanceNode(identity=AgentIdentity.create("bob"), name="bob", weight=1)
25
26
27 @pytest.fixture
28 def carol() -> GovernanceNode:
29 return GovernanceNode(identity=AgentIdentity.create("carol"), name="carol", weight=1)
30
31
32 @pytest.fixture
33 def dave() -> GovernanceNode:
34 return GovernanceNode(identity=AgentIdentity.create("dave"), name="dave", weight=2)
35
36
37 @pytest.fixture
38 def eve() -> GovernanceNode:
39 return GovernanceNode(identity=AgentIdentity.create("eve"), name="eve", weight=1)
40
41
42 @pytest.fixture
43 def nodes(
44 alice: GovernanceNode,
45 bob: GovernanceNode,
46 carol: GovernanceNode,
47 dave: GovernanceNode,
48 eve: GovernanceNode,
49 ) -> list[GovernanceNode]:
50 return [alice, bob, carol, dave, eve]
51
52
53 @pytest.fixture
54 def registry(nodes: list[GovernanceNode]) -> NodeRegistry:
55 reg = NodeRegistry()
56 for n in nodes:
57 reg.register(n)
58 return reg
59
60
61 @pytest.fixture
62 def sample_proposal(alice: GovernanceNode) -> GovernanceProposal:
63 proposal = GovernanceProposal.create(
64 kind=ProposalKind.AUTHORIZE_MODEL,
65 subject_id="did:pqaid:medical-ai-v2",
66 title="Authorize medical-ai-v2",
67 proposer_did=alice.did,
68 description="Permit medical-ai-v2 to run in production.",
69 parameters={"environment": "prod", "max_rate_qps": 50},
70 )
71 return alice.sign_proposal(proposal)
72