tests/conftest.py
| 1 | """Pytest fixtures.""" |
| 2 | |
| 3 | import pytest |
| 4 | from quantumshield.identity.agent import AgentIdentity |
| 5 | |
| 6 | from pqc_training_data import ( |
| 7 | CommitmentBuilder, |
| 8 | CommitmentSigner, |
| 9 | DataRecord, |
| 10 | ) |
| 11 | |
| 12 | |
| 13 | @pytest.fixture |
| 14 | def signer_identity() -> AgentIdentity: |
| 15 | return AgentIdentity.create("training-ingest") |
| 16 | |
| 17 | |
| 18 | @pytest.fixture |
| 19 | def signer(signer_identity: AgentIdentity) -> CommitmentSigner: |
| 20 | return CommitmentSigner(signer_identity) |
| 21 | |
| 22 | |
| 23 | @pytest.fixture |
| 24 | def sample_records() -> list[DataRecord]: |
| 25 | return [ |
| 26 | DataRecord(content=f"doc-{i}".encode(), metadata={"doc_id": i}) |
| 27 | for i in range(5) |
| 28 | ] |
| 29 | |
| 30 | |
| 31 | @pytest.fixture |
| 32 | def odd_records() -> list[DataRecord]: |
| 33 | return [ |
| 34 | DataRecord(content=f"odd-{i}".encode(), metadata={"doc_id": i}) |
| 35 | for i in range(7) # odd count exercises promotion |
| 36 | ] |
| 37 | |
| 38 | |
| 39 | @pytest.fixture |
| 40 | def single_record() -> DataRecord: |
| 41 | return DataRecord(content=b"only-doc", metadata={"kind": "single"}) |
| 42 | |
| 43 | |
| 44 | @pytest.fixture |
| 45 | def signed_commitment(signer, sample_records): |
| 46 | builder = CommitmentBuilder("demo-dataset", "1.0.0") |
| 47 | builder.add_records(sample_records) |
| 48 | commitment = builder.build(description="fixture commitment") |
| 49 | return signer.sign(commitment) |
| 50 | |