File size: 1,379 Bytes
6172160
4904e85
 
 
 
 
 
 
6172160
 
4904e85
 
 
 
 
 
6172160
 
4904e85
6172160
4904e85
 
 
 
 
 
6172160
4904e85
6172160
 
4904e85
6172160
4904e85
 
 
 
 
 
 
 
 
 
6172160
4904e85
 
 
 
6172160
4904e85
 
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
"""Tests proving the TDD scaffold test harness itself works (dispatch edition)."""

from __future__ import annotations

import subprocess
import sys
from pathlib import Path

from src.city_schema import CitySchema
from src.models import Action, IncidentState, UnitState

ROOT = Path(__file__).resolve().parents[1]


def test_conftest_fixtures_available(
    seeded_random,
    sample_unit_state,
    sample_incident_state,
    sample_action,
    metro_city_schema,
) -> None:
    import random

    assert isinstance(seeded_random, random.Random)
    expected = random.Random(42).randint(1, 100)
    actual = seeded_random.randint(1, 100)
    assert actual == expected

    UnitState(**sample_unit_state)
    IncidentState(**sample_incident_state)
    Action(**sample_action)
    assert isinstance(metro_city_schema, CitySchema)


def test_helpers_importable() -> None:
    from tests.helpers import assert_invalid_model, assert_valid_model, capture_stdout

    assert callable(capture_stdout)
    assert callable(assert_valid_model)
    assert callable(assert_invalid_model)


def test_pytest_collects_this_file() -> None:
    result = subprocess.run(
        [sys.executable, "-m", "pytest", __file__, "--collect-only", "-q"],
        capture_output=True,
        text=True,
        cwd=str(ROOT),
    )
    assert result.returncode == 0, f"Collection failed: {result.stderr}"