In this section
- Test Build 020 Validation Gate test · solar-electrical-topology-analysis-engine-text-based / tests/test_build_020_validation_gate.py lines 1–50
- Test Capsule Links test · solar-electrical-topology-analysis-engine-text-based / tests/test_capsule_links.py lines 1–84
- Test Cartridges test · solar-electrical-topology-analysis-engine-text-based / tests/test_cartridges.py lines 1–301
Test Build 020 Validation Gate
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_build_020_validation_gate.py · lines 1–50 of 50 · Entry point
- What it does
- It tests its inputs. Defines test_package_import_smoke, test_initial_studies_have_sorted_unique_contract_fields, test_malformed_definition_reports_study_and_field. Uses libraries importlib, pytest, solar_topology.study_registry.
- Why it exists in the grid workflow
- Domain stage field_execution (path word 'gate'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work.
- Downstream impact
- Used directly by 1 file: Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- Defines `test_package_import_smoke`, `test_initial_studies_have_sorted_unique_contract_fields` and `test_malformed_definition_reports_study_and_field`.
- Why it matters
- Run by Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- importlib, pytest, solar_topology.study_registry
- Used by
- run by Build 025 Small Gates Workflow (workflow run)
- Produces
- test_package_import_smoke, test_initial_studies_have_sorted_unique_contract_fields, test_malformed_definition_reports_study_and_field
- Defines here
- test_package_import_smoke, test_initial_studies_have_sorted_unique_contract_fields, test_malformed_definition_reports_study_and_field
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 tests/test_build_020_validation_gate.py:1-50 · blob 6933a03b16bd091744b833a14cc0dd5684e13e1f · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: production_core
import importlib
import pytest
from solar_topology.study_registry import (
INITIAL_STUDIES,
StudyCategory,
StudyDefinition,
)
def test_package_import_smoke():
package = importlib.import_module("solar_topology")
assert package is not None
def test_initial_studies_have_sorted_unique_contract_fields():
for definition in INITIAL_STUDIES:
assert definition.required_input_ids == tuple(
sorted(set(definition.required_input_ids))
), definition.study_id
assert definition.required_evidence_roles == tuple(
sorted(set(definition.required_evidence_roles))
), definition.study_id
@pytest.mark.parametrize(
("field_name", "values"),
[
("required_input_ids", ("z-input", "a-input")),
("required_input_ids", ("a-input", "a-input")),
("required_evidence_roles", ("z-role", "a-role")),
("required_evidence_roles", ("a-role", "a-role")),
],
)
def test_malformed_definition_reports_study_and_field(field_name, values):
kwargs = {field_name: values}
with pytest.raises(ValueError) as exc_info:
StudyDefinition(
study_id="malformed-study",
category=StudyCategory.EVIDENCE,
title="Malformed study fixture",
method_reference="test:build-020",
**kwargs,
)
message = str(exc_info.value)
assert "malformed-study" in message
assert field_name in message
assert "expected=" in messageTest Capsule Links
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_capsule_links.py · lines 1–84 of 84 · Entry point
- What it does
- It tests its inputs. Defines load_checker, test_title_verified_compatibility_pointer_mapping, test_all_quantum_spawn_and_trueself_markdown_links_resolve, test_capsule_link_check_command_passes. Uses libraries __future__, importlib.util, pathlib, subprocess, sys. Side effects: reads or writes files; starts processes.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (repository name word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- Downstream impact
- Used directly by 1 file: Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- Defines `load_checker`, `test_title_verified_compatibility_pointer_mapping`, `test_all_quantum_spawn_and_trueself_markdown_links_resolve` and 1 more.
- Why it matters
- Run by Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- __future__, importlib.util, pathlib, subprocess, sys
- Used by
- run by Build 025 Small Gates Workflow (workflow run)
- Produces
- load_checker, test_title_verified_compatibility_pointer_mapping, test_all_quantum_spawn_and_trueself_markdown_links_resolve, test_capsule_link_check_command_passes
- Defines here
- load_checker, test_title_verified_compatibility_pointer_mapping, test_all_quantum_spawn_and_trueself_markdown_links_resolve, test_capsule_link_check_command_passes
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 tests/test_capsule_links.py:1-84 · blob 928933522d5d8761b48f00b26949270c664dd8ee · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
from __future__ import annotations
import importlib.util
from pathlib import Path
import subprocess
import sys
ROOT = Path(__file__).resolve().parents[1]
SCRIPT = ROOT / "scripts" / "check_capsule_links.py"
EXPECTED_POINTERS = {
"202607311620-system-architecture.md": (
"202607311615-system-architecture.md",
"System Architecture",
),
"202607311640-geometry-authority.md": (
"202607311619-geometry-authority.md",
"Geometry Authority",
),
"202607311700-array-engine.md": (
"202607311624-array-engine.md",
"Array Engine and Topology Authority",
),
"202607311720-physics-emc-lightning.md": (
"202607311627-physics-emc-lightning.md",
"Physics, EMC and Lightning",
),
"202607311740-standards-validation.md": (
"202607311628-standards-validation.md",
"Standards and Validation",
),
"202607311820-respawn-instructions.md": (
"202607311652-respawn-instructions.md",
"Respawn Instructions and Operating Protocol",
),
}
def load_checker():
spec = importlib.util.spec_from_file_location("check_capsule_links", SCRIPT)
assert spec is not None and spec.loader is not None
module = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = module
spec.loader.exec_module(module)
return module
def test_title_verified_compatibility_pointer_mapping() -> None:
checker = load_checker()
root = ROOT / "docs" / "quantum-spawn"
for pointer_name, (target_name, expected_title) in EXPECTED_POINTERS.items():
pointer = root / pointer_name
target = root / target_name
assert pointer.is_file()
assert target.is_file()
assert expected_title in pointer.read_text(encoding="utf-8")
assert checker.canonical_title(target) == expected_title
assert checker.check_compatibility_pointer(
pointer,
pointer.read_text(encoding="utf-8"),
) == ()
commercial = root / "202607311640-commercial-strategy.md"
assert commercial.is_file()
assert checker.canonical_title(commercial) != "Geometry Authority"
def test_all_quantum_spawn_and_trueself_markdown_links_resolve() -> None:
checker = load_checker()
issues = checker.check_capsule_links()
assert issues == (), "\n".join(issue.message() for issue in issues)
def test_capsule_link_check_command_passes() -> None:
completed = subprocess.run(
[sys.executable, str(SCRIPT), "--check"],
cwd=ROOT,
check=False,
text=True,
capture_output=True,
)
assert completed.returncode == 0, completed.stderr
assert "capsule-link integrity passed" in completed.stdoutTest Cartridges
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_cartridges.py · lines 1–301 of 301 · Entry point
- What it does
- It tests its inputs. Defines 17 functions or classes, including external_cable_total, factory_lead_total, connector_count, test_declared_conductor_records_are_not_recreated_from_csa, test_default_row_span_canary_is_39_67_metres. Uses libraries pytest, solar_topology.cartridges, solar_topology.products, solar_topology.segments.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (repository name word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- Downstream impact
- Used directly by 1 file: Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- Defines `external_cable_total`, `factory_lead_total`, `connector_count` and 14 more.
- Why it matters
- Run by Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- pytest, solar_topology.cartridges, solar_topology.products, solar_topology.segments
- Used by
- run by Build 025 Small Gates Workflow (workflow run)
- Produces
- external_cable_total, factory_lead_total, connector_count, test_declared_conductor_records_are_not_recreated_from_csa, test_default_row_span_canary_is_39_67_metres, test_fleet_distribution_uses_actual_string_count, test_archetype_and_full_fleet_are_headless_and_deterministic, test_arbitrary_odd_and_asymmetric_band_lists_are_supported, test_leapfrog_order_returns_to_the_near_end, test_leapfrog_factory_lead_length_gate, test_cartridges_emit_one_shared_segment_contract, test_pair_physics_is_weighted_once_not_once_per_conductor
- Defines here
- external_cable_total, factory_lead_total, connector_count, test_declared_conductor_records_are_not_recreated_from_csa, test_default_row_span_canary_is_39_67_metres, test_fleet_distribution_uses_actual_string_count, test_archetype_and_full_fleet_are_headless_and_deterministic, test_arbitrary_odd_and_asymmetric_band_lists_are_supported, test_leapfrog_order_returns_to_the_near_end, test_leapfrog_factory_lead_length_gate, test_cartridges_emit_one_shared_segment_contract, test_pair_physics_is_weighted_once_not_once_per_conductor, test_connector_resistance_is_carried_by_connector_rows, test_factory_copper_and_connectors_are_cartridge_invariants, test_only_external_row_return_creates_theoretical_saving, test_infeasible_leapfrog_rows_cannot_claim_available_saving, test_measured_reach_override_is_explicit
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- solar-electrical-topology-analysis-engine-text-based@d3b4c497144c2c9b3e8f0e82117e7e9abe4672b9 tests/test_cartridges.py:1-301 · blob 9b974855df8d5ade6eb453b530b4556f89812f6c · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
import pytest
from solar_topology.cartridges import (
LeapfrogCartridge,
SequentialCartridge,
validate_cross_cartridge_invariants,
validate_segment_chains,
)
from solar_topology.products import (
EXTERNAL_STRING_6MM2,
FACTORY_LEAD_4MM2,
)
from solar_topology.segments import (
TopologyInputs,
archetype_strings,
fleet_string_definitions,
string_counts_per_inverter,
)
def external_cable_total(rows):
external_types = {
"external_positive_home_run",
"external_negative_home_run",
"external_sequential_row_return",
}
return sum(
row.conductor_length_m
for row in rows
if row.segment_type in external_types
)
def factory_lead_total(rows):
return sum(
row.conductor_length_m
for row in rows
if row.segment_type in {
"module_factory_positive_lead",
"module_factory_negative_lead",
}
)
def connector_count(rows):
return sum(row.connector_count for row in rows)
def test_declared_conductor_records_are_not_recreated_from_csa():
assert EXTERNAL_STRING_6MM2.conductor_diameter_mm == 3.00
assert EXTERNAL_STRING_6MM2.r20_ohm_per_m == pytest.approx(
3.39e-3
)
assert FACTORY_LEAD_4MM2.conductor_diameter_mm == 2.45
assert FACTORY_LEAD_4MM2.r20_ohm_per_m == pytest.approx(
5.09e-3
)
assert 0.70 <= EXTERNAL_STRING_6MM2.envelope_fill_factor <= 0.95
assert 0.70 <= FACTORY_LEAD_4MM2.envelope_fill_factor <= 0.95
def test_default_row_span_canary_is_39_67_metres():
inputs = TopologyInputs()
assert inputs.module_pitch_m == pytest.approx(1.323)
assert inputs.row_span_m == pytest.approx(39.67)
def test_fleet_distribution_uses_actual_string_count():
counts = string_counts_per_inverter(18_918, 795, 24)
assert len(counts) == 795
assert sum(counts) == 18_918
assert counts.count(24) == 633
assert counts.count(23) == 162
def test_archetype_and_full_fleet_are_headless_and_deterministic():
inputs = TopologyInputs()
assert len(archetype_strings(inputs)) == 24
first = list(fleet_string_definitions(inputs))
second = list(fleet_string_definitions(inputs))
assert first == second
assert len(first) == 18_918
assert first[0].string_id == "INV0001-E-B1-R01"
assert first[-1].inverter_id == 795
def test_arbitrary_odd_and_asymmetric_band_lists_are_supported():
inputs = TopologyInputs(
east_bands=(4, 3, 2),
west_bands=(5, 3, 1),
inverter_count=2,
total_site_string_count=35,
)
definitions = archetype_strings(inputs)
fleet = tuple(fleet_string_definitions(inputs))
assert inputs.archetype_string_count == 18
assert len(definitions) == 18
assert len(fleet) == 35
assert max(definition.band for definition in definitions) == 3
def test_leapfrog_order_returns_to_the_near_end():
cartridge = LeapfrogCartridge()
assert cartridge.module_order(6) == (1, 3, 5, 6, 4, 2)
assert cartridge.module_order(5) == (1, 3, 5, 4, 2)
def test_leapfrog_factory_lead_length_gate():
cartridge = LeapfrogCartridge()
default = cartridge.feasibility(TopologyInputs())
assert default.required_reach_m == pytest.approx(2.646)
assert default.available_reach_m == pytest.approx(0.630)
assert default.feasible is False
short = cartridge.feasibility(
TopologyInputs(
positive_factory_lead_m=1.2,
negative_factory_lead_m=1.2,
)
)
assert short.margin_m == pytest.approx(-0.246)
assert short.extension_required_m == pytest.approx(0.246)
passing = cartridge.feasibility(
TopologyInputs(
positive_factory_lead_m=1.4,
negative_factory_lead_m=1.4,
)
)
assert passing.feasible is True
assert passing.margin_m == pytest.approx(0.154)
def test_cartridges_emit_one_shared_segment_contract():
inputs = TopologyInputs(
inverter_count=1,
total_site_string_count=24,
)
definition = archetype_strings(inputs)[0]
sequential = SequentialCartridge().build_segments(
inputs,
definition,
)
leapfrog = LeapfrogCartridge().build_segments(
inputs,
definition,
)
validate_segment_chains(sequential)
validate_segment_chains(leapfrog)
assert sequential[0].segment_type == "external_positive_home_run"
assert sequential[-1].segment_type == "external_negative_home_run"
assert leapfrog[0].segment_type == "external_positive_home_run"
assert leapfrog[-1].segment_type == "external_negative_home_run"
assert any(
row.segment_type == "external_sequential_row_return"
for row in sequential
)
assert not any(
row.segment_type == "external_sequential_row_return"
for row in leapfrog
)
assert sum(
row.segment_type == "string_turnaround"
for row in leapfrog
) == 1
def test_pair_physics_is_weighted_once_not_once_per_conductor():
inputs = TopologyInputs(
inverter_count=1,
total_site_string_count=24,
)
definition = archetype_strings(inputs)[0]
rows = LeapfrogCartridge().build_segments(inputs, definition)
external = [
row
for row in rows
if row.segment_type in {
"external_positive_home_run",
"external_negative_home_run",
}
]
factory = [
row
for row in rows
if row.segment_type in {
"module_factory_positive_lead",
"module_factory_negative_lead",
}
]
assert len(external) == 2
assert sum(row.loop_parameter_weight for row in external) == 1.0
assert all(row.loop_parameter_weight == 0.5 for row in external)
assert all(row.loop_parameter_weight == 0.0 for row in factory)
assert all(row.formation == "single_pole" for row in factory)
def test_connector_resistance_is_carried_by_connector_rows():
inputs = TopologyInputs(
inverter_count=1,
total_site_string_count=24,
connector_contact_ohm=0.00035,
)
definition = archetype_strings(inputs)[0]
rows = LeapfrogCartridge().build_segments(inputs, definition)
connector_rows = [row for row in rows if row.connector_count]
assert connector_rows
assert connector_count(rows) == 62
assert all(
row.connector_resistance_ohm_each == pytest.approx(0.00035)
for row in connector_rows
)
def test_factory_copper_and_connectors_are_cartridge_invariants():
inputs = TopologyInputs(
inverter_count=1,
total_site_string_count=24,
)
definition = archetype_strings(inputs)[0]
sequential = SequentialCartridge().build_segments(
inputs,
definition,
)
leapfrog = LeapfrogCartridge().build_segments(
inputs,
definition,
)
expected_factory = inputs.modules_per_string * (
inputs.positive_factory_lead_m
+ inputs.negative_factory_lead_m
)
assert factory_lead_total(sequential) == pytest.approx(
expected_factory
)
assert factory_lead_total(leapfrog) == pytest.approx(
expected_factory
)
assert connector_count(sequential) == 62
assert connector_count(leapfrog) == 62
validate_cross_cartridge_invariants(sequential + leapfrog)
def test_only_external_row_return_creates_theoretical_saving():
inputs = TopologyInputs(
inverter_count=1,
total_site_string_count=24,
)
definition = archetype_strings(inputs)[0]
sequential = SequentialCartridge().build_segments(
inputs,
definition,
)
leapfrog = LeapfrogCartridge().build_segments(
inputs,
definition,
)
assert external_cable_total(sequential) == pytest.approx(59.67)
assert external_cable_total(leapfrog) == pytest.approx(20.0)
assert (
external_cable_total(sequential)
- external_cable_total(leapfrog)
) == pytest.approx(inputs.row_span_m)
def test_infeasible_leapfrog_rows_cannot_claim_available_saving():
inputs = TopologyInputs(
inverter_count=1,
total_site_string_count=24,
)
definition = archetype_strings(inputs)[0]
rows = LeapfrogCartridge().build_segments(inputs, definition)
assert rows
assert all(row.saving_available is False for row in rows)
assert all(
row.feasibility_status == "INFEASIBLE_LENGTH_SCREEN"
for row in rows
)
def test_measured_reach_override_is_explicit():
inputs = TopologyInputs(
measured_leapfrog_span_m=2.2,
positive_factory_lead_m=1.2,
negative_factory_lead_m=1.2,
)
feasibility = LeapfrogCartridge().feasibility(inputs)
assert feasibility.basis == "MEASURED_ROUTED_SPAN"
assert feasibility.feasible is True
assert feasibility.margin_m == pytest.approx(0.2)