je_web_runner.api.test_data

Façade: DB fixtures / fixture record / form autofill.

exception je_web_runner.api.test_data.DbFixtureError

Bases: WebRunnerException

Raised when a fixture file or shape is invalid.

class je_web_runner.api.test_data.FieldMatch(field: 'Dict[str, Any]', fixture_key: 'str', value: 'Any', confidence: 'float', reason: 'str')

Bases: object

confidence: float
field: Dict[str, Any]
fixture_key: str
reason: str
value: Any
class je_web_runner.api.test_data.FixtureRecorder(path: str | Path, mode: RecorderMode = RecorderMode.AUTO)

Bases: object

Persist and replay key/value fixtures from a single JSON file.

flush() None
get(key: str) Any
has(key: str) bool
replay_or_record(key: str, producer: Callable[[], Any]) Any

REPLAY 模式:取出存檔;RECORD:每次重錄;AUTO:缺則錄、有則放。 RECORD always re-runs producer and saves; REPLAY reads only and raises if missing; AUTO replays when available, records otherwise.

set(key: str, value: Any) None
exception je_web_runner.api.test_data.FixtureRecorderError

Bases: WebRunnerException

Raised when the recorder file cannot be read / written.

exception je_web_runner.api.test_data.FormAutoFillError

Bases: WebRunnerException

Raised when input shape is invalid.

class je_web_runner.api.test_data.RecorderMode(value)

Bases: Enum

AUTO = 'auto'
RECORD = 'record'
REPLAY = 'replay'
je_web_runner.api.test_data.classify_field(field: Dict[str, Any]) str | None

data-testid > id > name > placeholder > label > type Pick the first matching alias group; return the canonical key or None.

je_web_runner.api.test_data.load_fixture_file(path: str | Path) Dict[str, List[Dict[str, Any]]]

Read a JSON fixture file and validate its shape.

je_web_runner.api.test_data.load_into_connection(connection: Any, fixture: Dict[str, List[Dict[str, Any]]], quote: str = '"', only_tables: Sequence[str] | None = None) Dict[str, int]

對每個表 batch insert 所有 rows,回傳 {table: rows_inserted} Insert every fixture row using INSERT INTO <t> (...) VALUES (...) with bound parameters. Returns the count of rows inserted per table.

je_web_runner.api.test_data.match_fields(fields: Iterable[Dict[str, Any]], fixture: Dict[str, Any]) List[FieldMatch]

Return a FieldMatch for every field that maps to a fixture key.

je_web_runner.api.test_data.open_recorder(path: str | Path, mode: RecorderMode | str = RecorderMode.AUTO) FixtureRecorder

Convenience factory accepting string mode names.

je_web_runner.api.test_data.plan_fill_actions(fields: Iterable[Dict[str, Any]], fixture: Dict[str, Any], submit_locator: Dict[str, str] | None = None) List[List[Any]]

把比對結果展開成 WR_save_test_object + WR_element_input 序列 Convert matches into an executable action list. submit_locator optional {strategy, value} adds a final click.

je_web_runner.api.test_data.truncate_tables(connection: Any, tables: Iterable[str], quote: str = '"') None

DELETE FROM each table; cheap teardown for in-test fixture reload.

je_web_runner.api.test_data.validate_shape(data: Any) Dict[str, List[Dict[str, Any]]]

Make sure the loaded object matches {table: [rows]}.