test_validation_at_use¶
Frozen is not enough: the two holes in it, and what closes them.
Every model here is frozen and validates at construction. model_copy goes
around the validators, and a dict on a frozen model goes around the
freeze. These tests pin that both are closed, and that the mechanism does not
change what a model means.
Functions¶
|
|
|
|
|
|
A frozen model whose |
|
|
The freeze is invisible to everything that reads: equality against a |
|
The design cache is keyed on this text. A change to how a model holds |
|
Every entry point that reads a spec revalidates it first, so a spec |
|
|
|
The guard: a dau-core model that is not checkable is a model whose |
A subclass that unfreezes itself is the quiet way back to a mutable |
|
A generator is a field type, so nothing revalidates it on the way in. |
|
The goldens are what hardware is compared against, so a config that |
|
|
|
|
Module Contents¶
- test_validation_at_use._spec() dau_core.composition.ScanCompositionSpec¶
- test_validation_at_use.test_a_copied_model_is_refused_at_the_next_boundary() None¶
model_copyskips every validator, so the copy itself cannot refuse. The boundary it is handed to does: a parent revalidates its children, andcheck()revalidates on demand.
- test_validation_at_use.test_replace_is_the_validated_copy() None¶
- test_validation_at_use.test_a_frozen_model_holds_no_mutable_mapping() None¶
A frozen model whose
configis a plain dict is not frozen: whoever holds the model can rewrite the binding the design was priced under.There is no mutating method to refuse: the field holds a
Mapping, not adictsubclass, so nothing is inherited that could write. A subclass would have been the weaker design –dict.__setitem__(m, k, v)reaches past any override – so that bypass is pinned here too.
- test_validation_at_use.test_a_read_only_mapping_still_behaves_like_the_dict_it_was() None¶
The freeze is invisible to everything that reads: equality against a plain dict, membership, serialization, and the hash a frozen model needs.
- test_validation_at_use.test_the_canonical_form_and_the_cache_key_are_unchanged() None¶
The design cache is keyed on this text. A change to how a model holds its mappings must not move it, so the pinned-hash fixture in test_composition.py keeps meaning what it meant.
- test_validation_at_use.test_the_composition_boundaries_refuse_a_copied_spec() None¶
Every entry point that reads a spec revalidates it first, so a spec that was copied past its validators cannot be hashed, priced or advertised.
- test_validation_at_use.test_a_polymorphic_field_keeps_its_subclass() None¶
CoreGeneratoris a field type, so it must NOT revalidate instances: a subclass handed toCoreDefinition.generatorwould be validated against the base and lose its own fields. The generated cores in the registry are the proof – they load – and check() on the concrete subclass is what validates one.
- test_validation_at_use.test_every_model_validates_at_use() None¶
The guard: a dau-core model that is not checkable is a model whose copies nothing refuses.
- test_validation_at_use.test_the_base_refuses_an_unfrozen_subclass() None¶
A subclass that unfreezes itself is the quiet way back to a mutable model, so the base’s config is what a new model inherits.
- test_validation_at_use.test_a_copied_generator_cannot_render() None¶
A generator is a field type, so nothing revalidates it on the way in.
render()is therefore its own boundary: a copied operating point must not reach HDL, because that HDL’s digest would then identify it.
- test_validation_at_use.test_a_golden_refuses_a_copied_config() None¶
The goldens are what hardware is compared against, so a config that construction would have refused must not produce a reference answer. The check runs once per call, outside the row loop.
- test_validation_at_use.test_staging_the_hdl_refuses_a_copied_spec() None¶
core_namesdecides which sources a build compiles. A spec copied past its validators must not make that decision.
- test_validation_at_use.test_a_record_batch_is_validated_against_checked_limits() None¶