tests/conftest.py
1.9 KB · 78 lines · python Raw
1 """Pytest fixtures."""
2
3 from __future__ import annotations
4
5 import pytest
6 from quantumshield.identity.agent import AgentIdentity
7
8 from pqc_content_provenance import (
9 AIGeneratedAssertion,
10 ContentManifest,
11 GenerationContext,
12 ManifestSigner,
13 ModelAttribution,
14 UsageAssertion,
15 )
16
17
18 @pytest.fixture
19 def model_identity() -> AgentIdentity:
20 return AgentIdentity.create("llama-3-signer")
21
22
23 @pytest.fixture
24 def signer(model_identity: AgentIdentity) -> ManifestSigner:
25 return ManifestSigner(model_identity)
26
27
28 @pytest.fixture
29 def attacker_identity() -> AgentIdentity:
30 return AgentIdentity.create("attacker")
31
32
33 @pytest.fixture
34 def sample_attribution() -> ModelAttribution:
35 return ModelAttribution(
36 model_did="did:pqaid:deadbeef",
37 model_name="Llama-3-8B-Instruct",
38 model_version="1.0",
39 registry_url="https://quantamrkt.com/models/meta-llama-Llama-3-8B-Instruct",
40 model_manifest_hash="a" * 64,
41 )
42
43
44 @pytest.fixture
45 def sample_context() -> GenerationContext:
46 return GenerationContext(
47 prompt_hash="b" * 64,
48 parameters={"temperature": 0.7, "top_p": 0.9},
49 generated_at="2026-04-20T12:00:00Z",
50 )
51
52
53 @pytest.fixture
54 def sample_content() -> bytes:
55 return b"This is AI-generated text about post-quantum cryptography."
56
57
58 @pytest.fixture
59 def sample_manifest(sample_content, sample_attribution, sample_context) -> ContentManifest:
60 return ContentManifest.create(
61 content=sample_content,
62 content_type="text/plain",
63 model_attribution=sample_attribution,
64 generation_context=sample_context,
65 assertions=[
66 AIGeneratedAssertion(
67 model_name="Llama-3-8B-Instruct",
68 model_version="1.0",
69 generator_type="text",
70 ),
71 UsageAssertion(
72 license="cc-by-4.0",
73 commercial_use=True,
74 attribution_required=True,
75 ),
76 ],
77 )
78