test_every_registry_value_satisfies_its_generated_check¶
Tests › tests/test_vocabulary.py
What this test is for
Why it exists
Round-trip: every registered value is accepted by the clause generated for it, and a non-member is rejected. Catches a registry that is a superset of what the SQL actually admits.
Given
conn = sqlite3.connect(":memory:")for (table, column), vocab in COLUMNS.items(): conn.execute(f"CREATE TABLE probe (c TEXT {vocab.check('c')})") for value in vocab.values: conn.execute("INSERT INTO probe VALUES (?)", (value,)) with pytest.raises(sqlite3.IntegrityError, match="CHECK constraint failed"): conn.execute("INSERT INTO probe VALUES ('__not_a_member__')") assert conn.execute("SELECT COUNT(*) FROM probe").fetchone()[0] == len(vocab.values), ( f"{table}.{column} lost a value round-tripping" ) conn.execute("DROP TABLE probe")conn.close()
When
- —
Then
- —
tests/test_vocabulary.py:346 · its file's page
What it checks (1)
assert conn.execute("SELECT COUNT(*) FROM probe").fetchone()[0] == len(vocab.values), ( f"{table}.{column} lost a value round-tripping" )not attributed
What it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Also reaches 1 requirement
Its run touches their code; that is reach, not proof.
- REQ-DDB-SCHEMA-012 measured