File size: 988 Bytes
0e39d80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import json
import subprocess
import sys
from pathlib import Path

import pytest

BACKEND = Path(__file__).resolve().parent.parent
WORKSPACE = BACKEND.parent.parent
FIXTURES = Path(__file__).parent / "fixtures"
AI_MASK = WORKSPACE / "AI_mask" / "AI_mask"


@pytest.fixture(scope="session", autouse=True)
def ensure_fixtures():
    manifest = FIXTURES / "manifest.json"
    if not manifest.exists():
        subprocess.run([sys.executable, str(Path(__file__).parent / "generate_fixtures.py")], check=True)
    yield


@pytest.fixture
def fixtures_dir() -> Path:
    return FIXTURES


@pytest.fixture
def manifest(fixtures_dir) -> dict:
    return json.loads((fixtures_dir / "manifest.json").read_text(encoding="utf-8"))


@pytest.fixture
def aadhaar_images() -> list[Path]:
    paths = [AI_MASK / f"a{i}.jpg" for i in range(1, 5)]
    return [p for p in paths if p.exists()]


@pytest.fixture
def pan_image() -> Path | None:
    p = AI_MASK / "p1.jpg"
    return p if p.exists() else None