File size: 1,770 Bytes
4e75170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""tests/conftest.py — shared pytest fixtures"""
from __future__ import annotations

import io
import sys
from pathlib import Path

import numpy as np
import pytest
from PIL import Image

# Ensure repo root is on path
sys.path.insert(0, str(Path(__file__).parent.parent))


@pytest.fixture
def fake_image_bytes() -> bytes:
    """Returns JPEG bytes of a random 224×224 RGB image."""
    arr = (np.random.rand(224, 224, 3) * 255).astype(np.uint8)
    img = Image.fromarray(arr)
    buf = io.BytesIO()
    img.save(buf, format="JPEG")
    return buf.getvalue()


@pytest.fixture
def fake_image_bytes_png() -> bytes:
    arr = (np.random.rand(224, 224, 3) * 255).astype(np.uint8)
    img = Image.fromarray(arr)
    buf = io.BytesIO()
    img.save(buf, format="PNG")
    return buf.getvalue()


@pytest.fixture
def fake_landmark_sequence() -> "np.ndarray":
    """Returns (64, 68, 3) float32 landmark array with random values in [0,1]."""
    return np.random.rand(64, 68, 3).astype(np.float32)


@pytest.fixture
def fake_lip_mfcc():
    """Returns (lip_frames, mfcc) as numpy arrays."""
    lip  = np.random.rand(25, 64, 96, 3).astype(np.float32)
    mfcc = np.random.rand(40, 50).astype(np.float32)
    return lip, mfcc


@pytest.fixture
def engine_result_fake():
    from src.types import EngineResult
    return EngineResult(
        engine="fingerprint",
        verdict="FAKE",
        confidence=0.92,
        explanation="Test explanation.",
        processing_time_ms=50.0,
    )


@pytest.fixture
def engine_result_real():
    from src.types import EngineResult
    return EngineResult(
        engine="fingerprint",
        verdict="REAL",
        confidence=0.85,
        explanation="No synthetic fingerprints found.",
        processing_time_ms=50.0,
    )