In this section
- Test Diagnostics and Studies test · solar-electrical-topology-analysis-engine-text-based / tests/test_diagnostics_and_studies.py lines 1–248
- Test End to End Authority Slice test · solar-electrical-topology-analysis-engine-text-based / tests/test_end_to_end_authority_slice.py lines 1–86
- Test Equipment Profile Exact Arithmetic test · solar-electrical-topology-analysis-engine-text-based / tests/test_equipment_profile_exact_arithmetic.py lines 1–22
- Test Equipment Profiles test · solar-electrical-topology-analysis-engine-text-based / tests/test_equipment_profiles.py lines 1–229
- Test Equipment Profiles Public API test · solar-electrical-topology-analysis-engine-text-based / tests/test_equipment_profiles_public_api.py lines 1–72
Test Diagnostics and Studies
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based that uses SHA-256. It is built from the fail step (`fail`).
testsolar-electrical-topology-analysis-engine-text-based / tests/test_diagnostics_and_studies.py · lines 1–248 of 248 · Entry point · pattern test_public_payload_omits_internal_detail_and_is_deterministic (shared by 2 files)
- What it does
- It tests its inputs. Defines 10 functions or classes, including test_diagnostic_report_accumulates_and_sorts_all_findings, test_public_payload_omits_internal_detail_and_is_deterministic, test_validation_bridge_preserves_multiple_circuit_and_traversal_issues, test_missing_validator_results_are_explicitly_not_checked, test_legacy_exception_is_public_safe. Uses libraries json, pytest, solar_topology.circuit, solar_topology.circuit_traversal, solar_topology.circuit_validation.
- 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 `test_diagnostic_report_accumulates_and_sorts_all_findings`, `test_public_payload_omits_internal_detail_and_is_deterministic`, `test_validation_bridge_preserves_multiple_circuit_and_traversal_issues` and 7 more.
- Why it matters
- Run by Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- json, pytest, solar_topology.circuit, solar_topology.circuit_traversal, solar_topology.circuit_validation, solar_topology.diagnostic_bridges, solar_topology.diagnostics, solar_topology.study_registry
- Used by
- run by Build 025 Small Gates Workflow (workflow run)
- Produces
- test_diagnostic_report_accumulates_and_sorts_all_findings, test_public_payload_omits_internal_detail_and_is_deterministic, test_validation_bridge_preserves_multiple_circuit_and_traversal_issues, test_missing_validator_results_are_explicitly_not_checked, test_legacy_exception_is_public_safe, test_study_registry_blocks_missing_inputs_and_undeclared_criteria, test_study_states_distinguish_ready_not_run_pass_warning_and_fail, test_initial_registry_is_unique_and_deterministic, test_duplicate_diagnostics_and_coverage_are_rejected
- Defines here
- test_diagnostic_report_accumulates_and_sorts_all_findings, test_public_payload_omits_internal_detail_and_is_deterministic, test_validation_bridge_preserves_multiple_circuit_and_traversal_issues, test_missing_validator_results_are_explicitly_not_checked, test_legacy_exception_is_public_safe, fail, test_study_registry_blocks_missing_inputs_and_undeclared_criteria, test_study_states_distinguish_ready_not_run_pass_warning_and_fail, test_initial_registry_is_unique_and_deterministic, test_duplicate_diagnostics_and_coverage_are_rejected
- 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_diagnostics_and_studies.py:1-248 · blob ff4d7b274fbe5bd7682f2d2c6bf8bd98325afae4 · 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 json
import pytest
from solar_topology.circuit import CircuitModel
from solar_topology.circuit_traversal import OrderedCircuitTraversal, TraversalIssue
from solar_topology.circuit_validation import (
CircuitValidationResult,
IssueSeverity,
ValidationIssue,
)
from solar_topology.diagnostic_bridges import (
build_validation_diagnostic_report,
guarded_diagnostic_call,
)
from solar_topology.diagnostics import (
Diagnostic,
DiagnosticCategory,
DiagnosticSeverity,
StudyCoverage,
StudyState,
build_diagnostic_report,
diagnostic_report_hash,
diagnostic_report_json,
)
from solar_topology.study_registry import (
INITIAL_STUDIES,
StudyCategory,
StudyDefinition,
assess_study,
build_study_registry,
study_registry_hash,
study_registry_json,
)
def test_diagnostic_report_accumulates_and_sorts_all_findings():
report = build_diagnostic_report(
[
Diagnostic(
code="Z.TEST",
severity=DiagnosticSeverity.WARNING,
category=DiagnosticCategory.INPUT,
message="second",
),
Diagnostic(
code="A.TEST",
severity=DiagnosticSeverity.ERROR,
category=DiagnosticCategory.TOPOLOGY,
message="first",
),
],
[
StudyCoverage(
study_id="b-study",
state=StudyState.NOT_CHECKED,
reason="not run",
),
StudyCoverage(
study_id="a-study",
state=StudyState.CHECKED_PASS,
),
],
)
assert [item.code for item in report.diagnostics] == ["A.TEST", "Z.TEST"]
assert [item.study_id for item in report.coverage] == ["a-study", "b-study"]
assert report.blocking
assert report.error_count == 1
assert report.warning_count == 1
assert diagnostic_report_hash(report).startswith("sha256:")
def test_public_payload_omits_internal_detail_and_is_deterministic():
report = build_diagnostic_report(
[
Diagnostic(
code="PUBLIC.SAFE",
severity=DiagnosticSeverity.ERROR,
category=DiagnosticCategory.PUBLICATION,
message="public message",
public_detail="safe",
internal_detail="NDA document location",
)
]
)
public_payload = json.loads(diagnostic_report_json(report, public=True))
assert "internal_detail" not in public_payload["diagnostics"][0]
assert diagnostic_report_json(report, public=True) == diagnostic_report_json(
report, public=True
)
def test_validation_bridge_preserves_multiple_circuit_and_traversal_issues():
circuit = CircuitValidationResult(
(
ValidationIssue("DUPLICATE_OBJECT_ID", "duplicate", object_id="o-1"),
ValidationIssue(
"ASSUMED_GEOMETRY",
"assumed",
severity=IssueSeverity.WARNING,
object_id="o-2",
),
)
)
traversal = OrderedCircuitTraversal(
start_terminal_id="a",
end_terminal_id="b",
ordered_terminal_ids=(),
ordered_connection_ids=(),
ordered_segment_ids=(),
issues=(TraversalIssue("BRANCH", "ambiguous branch", terminal_id="t-1"),),
)
report = build_validation_diagnostic_report(
circuit=circuit, traversal=traversal, subject_id="model-1"
)
assert {item.code for item in report.diagnostics} == {
"CIRCUIT.DUPLICATE_OBJECT_ID",
"CIRCUIT.ASSUMED_GEOMETRY",
"TRAVERSAL.BRANCH",
}
assert report.blocking
assert all(item.state == StudyState.CHECKED_FAIL for item in report.coverage)
def test_missing_validator_results_are_explicitly_not_checked():
report = build_validation_diagnostic_report(subject_id="model-1")
assert not report.diagnostics
assert {item.state for item in report.coverage} == {StudyState.NOT_CHECKED}
assert not report.blocking
def test_legacy_exception_is_public_safe():
def fail():
raise RuntimeError("internal path /secret/file")
result, diagnostics = guarded_diagnostic_call(
fail,
code="LEGACY.FAIL",
category=DiagnosticCategory.INTERNAL,
public_message="calculation could not be completed",
)
assert result is None
assert diagnostics[0].message == "calculation could not be completed"
assert "/secret/file" in diagnostics[0].internal_detail
def test_study_registry_blocks_missing_inputs_and_undeclared_criteria():
definition = StudyDefinition(
study_id="limit-study",
category=StudyCategory.STEADY_STATE,
title="Limit study",
method_reference="method:v1",
required_input_ids=("a", "b"),
required_evidence_roles=("basis",),
acceptance_criterion_required=True,
)
missing = assess_study(
definition,
subject_id="circuit-1",
available_input_ids=("a",),
available_evidence_roles=(),
)
assert missing.coverage.state == StudyState.BLOCKED
assert missing.missing_input_ids == ("b",)
assert missing.missing_evidence_roles == ("basis",)
no_criterion = assess_study(
definition,
subject_id="circuit-1",
available_input_ids=("a", "b"),
available_evidence_roles=("basis",),
)
assert no_criterion.coverage.state == StudyState.BLOCKED
assert "criterion" in no_criterion.coverage.reason
def test_study_states_distinguish_ready_not_run_pass_warning_and_fail():
definition = StudyDefinition(
study_id="study",
category=StudyCategory.ELECTRICAL if hasattr(StudyCategory, "ELECTRICAL") else StudyCategory.STEADY_STATE,
title="Study",
method_reference="method:v1",
)
ready = assess_study(
definition,
subject_id=None,
available_input_ids=(),
available_evidence_roles=(),
)
passed = assess_study(
definition,
subject_id=None,
available_input_ids=(),
available_evidence_roles=(),
performed=True,
passed=True,
)
warning = assess_study(
definition,
subject_id=None,
available_input_ids=(),
available_evidence_roles=(),
performed=True,
passed=True,
warning=True,
)
failed = assess_study(
definition,
subject_id=None,
available_input_ids=(),
available_evidence_roles=(),
performed=True,
passed=False,
)
assert ready.coverage.state == StudyState.NOT_CHECKED
assert passed.coverage.state == StudyState.CHECKED_PASS
assert warning.coverage.state == StudyState.CHECKED_WARNING
assert failed.coverage.state == StudyState.CHECKED_FAIL
def test_initial_registry_is_unique_and_deterministic():
assessments = [
assess_study(
definition,
subject_id="generic-circuit",
available_input_ids=(),
available_evidence_roles=(),
)
for definition in reversed(INITIAL_STUDIES)
]
registry = build_study_registry(assessments)
assert len(registry.definitions) == len(INITIAL_STUDIES)
assert study_registry_hash(registry).startswith("sha256:")
assert study_registry_json(registry) == study_registry_json(registry)
def test_duplicate_diagnostics_and_coverage_are_rejected():
diagnostic = Diagnostic(
code="DUP.TEST",
severity=DiagnosticSeverity.ERROR,
category=DiagnosticCategory.INPUT,
message="duplicate",
)
with pytest.raises(ValueError, match="duplicate diagnostics"):
build_diagnostic_report([diagnostic, diagnostic])
coverage = StudyCoverage("study", StudyState.CHECKED_PASS)
with pytest.raises(ValueError, match="duplicate study coverage"):
build_diagnostic_report(coverage=[coverage, coverage])Test End to End Authority Slice
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based that checks Local Authority Bridge and Run Authority Slice, using SHA-256.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_end_to_end_authority_slice.py · lines 1–86 of 86 · Entry point
- What it does
- It tests its inputs. Defines test_end_to_end_authority_slice, test_authority_slice_cli_can_run_without_heavy_subgates, test_end_to_end_harness_uses_existing_authority_paths. Uses libraries __future__, json, 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 2 files: Run Microbuild (solar-electrical-topology-analysis-engine-text-based); Build 025 Small Gates Workflow (solar-electrical-topology-analysis-engine-text-based). Reached from 4 other entry points, including Microbuild Worker Workflow (solar-electrical-topology-analysis-engine-text-based); Test Microbuild Runner (solar-electrical-topology-analysis-engine-text-based); Test Microbuild Workflow (solar-electrical-topology-analysis-engine-text-based).
- What it achieves
- Defines `test_end_to_end_authority_slice`, `test_authority_slice_cli_can_run_without_heavy_subgates` and `test_end_to_end_harness_uses_existing_authority_paths`.
- Why it matters
- Run by Run Microbuild and Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- Local Authority Bridge (import), Run Authority Slice (import), Build Authority Bundle (script call), __future__, json, pathlib, subprocess, sys
- Used by
- run by Run Microbuild (script call), run by Build 025 Small Gates Workflow (workflow run)
- Produces
- test_end_to_end_authority_slice, test_authority_slice_cli_can_run_without_heavy_subgates, test_end_to_end_harness_uses_existing_authority_paths
- Defines here
- test_end_to_end_authority_slice, test_authority_slice_cli_can_run_without_heavy_subgates, test_end_to_end_harness_uses_existing_authority_paths
- 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_end_to_end_authority_slice.py:1-86 · blob 7c993ee0e78a95911a02eb7bb9bf06ea72bbbe60 · 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 json
from pathlib import Path
import subprocess
import sys
from scripts.local_authority_bridge import (
AUTHORITY_BUNDLE_ROUTE,
STUDIO_ROUTE,
)
from scripts.run_authority_slice import (
AUTHORITY_SLICE_VERSION,
BROWSER_MODES,
run_authority_slice,
)
ROOT = Path(__file__).resolve().parents[1]
def test_end_to_end_authority_slice() -> None:
summary = run_authority_slice(
strategy="leapfrog",
browser_checks=True,
clean_wheel=True,
)
assert summary["schema_version"] == AUTHORITY_SLICE_VERSION
assert summary["pass"] is True
assert summary["strategy"] == "leapfrog"
assert summary["command_equals_bridge"] is True
assert summary["bridge_equals_committed_bundle"] is True
assert summary["studio_route"] == STUDIO_ROUTE
assert summary["authority_bundle_route"] == AUTHORITY_BUNDLE_ROUTE
assert summary["module_count"] == 720
assert summary["string_count"] == 24
assert summary["modules_per_string"] == 30
assert summary["dc_nameplate_power_kwp"] == 475.2
assert summary["inverter_apparent_power_kva"] == 352.0
assert summary["browser_modes"] == list(BROWSER_MODES)
assert summary["clean_wheel"] is True
assert summary["equipment_evidence_state"] == "incomplete_evidence"
assert summary["response_hash"].startswith("sha256:")
assert summary["response_bytes_sha256"].startswith("sha256:")
def test_authority_slice_cli_can_run_without_heavy_subgates() -> None:
completed = subprocess.run(
[
sys.executable,
"scripts/run_authority_slice.py",
"--skip-browser-checks",
"--skip-clean-wheel",
],
cwd=ROOT,
check=True,
capture_output=True,
text=True,
)
payload = json.loads(completed.stdout)
assert payload["pass"] is True
assert payload["command_equals_bridge"] is True
assert payload["bridge_equals_committed_bundle"] is True
assert payload["browser_modes"] == []
assert payload["clean_wheel"] is False
def test_end_to_end_harness_uses_existing_authority_paths() -> None:
source = (ROOT / "scripts" / "run_authority_slice.py").read_text(
encoding="utf-8"
)
bridge_source = (
ROOT / "scripts" / "local_authority_bridge.py"
).read_text(encoding="utf-8")
assert "scripts/build_authority_bundle.py" in source
assert "validate_authority_bundle_payload" in source
assert "validate_inverter_block_wheel.py" in source
assert "studio-authority.test.mjs" in source
assert "studio-authority-evidence.test.mjs" in source
assert "authority_response_json" in bridge_source
assert "AUTHORITY_BUNDLE_PATH.read_bytes()" not in bridge_source
assert "eval(" not in source
assert "shell=True" not in sourceTest Equipment Profile Exact Arithmetic
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_equipment_profile_exact_arithmetic.py · lines 1–22 of 22 · Entry point
- What it does
- It tests its inputs. Defines test_reference_block_payload_uses_exact_declared_decimal_values. Uses libraries __future__, solar_topology.equipment_profiles.
- 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 `test_reference_block_payload_uses_exact_declared_decimal_values`.
- Why it matters
- Run by Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- __future__, solar_topology.equipment_profiles
- Used by
- run by Build 025 Small Gates Workflow (workflow run)
- Produces
- test_reference_block_payload_uses_exact_declared_decimal_values
- Defines here
- test_reference_block_payload_uses_exact_declared_decimal_values
- 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_equipment_profile_exact_arithmetic.py:1-22 · blob 4deee7e88f3467e09711bfa9a59346b916f07a22 · 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
from __future__ import annotations
from solar_topology.equipment_profiles import (
GENERIC_REFERENCE_EQUIPMENT_CONTRACT,
reference_equipment_contract_json,
reference_equipment_contract_payload,
)
def test_reference_block_payload_uses_exact_declared_decimal_values() -> None:
contract = GENERIC_REFERENCE_EQUIPMENT_CONTRACT
block = reference_equipment_contract_payload(contract)["reference_block"]
assert contract.string_rated_power_kwp == 19.8
assert contract.dc_nameplate_power_kwp == 475.2
assert contract.dc_ac_nameplate_ratio == 1.35
assert block["string_rated_power_kwp"] == 19.8
assert block["dc_nameplate_power_kwp"] == 475.2
assert block["dc_ac_nameplate_ratio"] == 1.35
serialised = reference_equipment_contract_json(contract)
assert '"dc_nameplate_power_kwp":475.2' in serialised
assert "475.20000000000005" not in serialisedTest Equipment Profiles
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based that uses SHA-256.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_equipment_profiles.py · lines 1–229 of 229 · Entry point
- What it does
- It tests its inputs. Defines 10 functions or classes, including test_reference_equipment_contract_has_exact_product_boundary, test_reference_inverter_exposes_24_unique_physical_input_pairs, test_internal_input_relationships_remain_explicitly_unresolved, test_connector_leads_dimensions_and_electrical_module_data_remain_missing, test_conductor_products_are_referenced_without_silent_promotion. Uses libraries __future__, dataclasses, json, math, pytest.
- 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 `test_reference_equipment_contract_has_exact_product_boundary`, `test_reference_inverter_exposes_24_unique_physical_input_pairs`, `test_internal_input_relationships_remain_explicitly_unresolved` and 7 more.
- Why it matters
- Run by Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- __future__, dataclasses, json, math, pytest, solar_topology.circuit, solar_topology.equipment_profiles, solar_topology.evidence
- Used by
- run by Build 025 Small Gates Workflow (workflow run)
- Produces
- test_reference_equipment_contract_has_exact_product_boundary, test_reference_inverter_exposes_24_unique_physical_input_pairs, test_internal_input_relationships_remain_explicitly_unresolved, test_connector_leads_dimensions_and_electrical_module_data_remain_missing, test_conductor_products_are_referenced_without_silent_promotion, test_missing_evidence_is_deterministic_and_includes_input_mapping, test_contract_serialisation_and_hash_are_deterministic, test_hash_changes_when_a_bound_equipment_value_changes, test_unresolved_value_cannot_claim_verified_evidence, test_serialised_contract_contains_no_identity_fields
- Defines here
- test_reference_equipment_contract_has_exact_product_boundary, test_reference_inverter_exposes_24_unique_physical_input_pairs, test_internal_input_relationships_remain_explicitly_unresolved, test_connector_leads_dimensions_and_electrical_module_data_remain_missing, test_conductor_products_are_referenced_without_silent_promotion, test_missing_evidence_is_deterministic_and_includes_input_mapping, test_contract_serialisation_and_hash_are_deterministic, test_hash_changes_when_a_bound_equipment_value_changes, test_unresolved_value_cannot_claim_verified_evidence, test_serialised_contract_contains_no_identity_fields
- 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_equipment_profiles.py:1-229 · blob ae599fcdf7ffcade82a0f12195ea75943955ac59 · 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
from __future__ import annotations
from dataclasses import replace
import json
import math
import pytest
from solar_topology.circuit import EvidenceClass
from solar_topology.equipment_profiles import (
GENERIC_REFERENCE_EQUIPMENT_CONTRACT,
ConnectorCompatibilityState,
InternalDcTopology,
ModuleTechnology,
QualifiedValue,
ReverseCurrentBlockingState,
build_generic_reference_equipment_contract,
reference_equipment_contract_hash,
reference_equipment_contract_json,
reference_equipment_contract_payload,
reference_equipment_missing_evidence,
validate_reference_equipment_contract,
)
from solar_topology.evidence import VerificationState
from solar_topology.products import EXTERNAL_STRING_6MM2, FACTORY_LEAD_4MM2
from solar_topology.resistance_qualification import (
ResistanceSourceStatus,
assess_resistance_source,
)
def test_reference_equipment_contract_has_exact_product_boundary() -> None:
contract = build_generic_reference_equipment_contract()
assert contract.module.technology.value == str(ModuleTechnology.BIFACIAL)
assert contract.module.rated_power_wp.value == 660.0
assert contract.modules_per_string == 30
assert contract.string_count == 24
assert contract.module_count == 720
assert math.isclose(contract.string_rated_power_kwp, 19.8, abs_tol=1e-12)
assert math.isclose(contract.dc_nameplate_power_kwp, 475.2, abs_tol=1e-12)
assert contract.inverter.apparent_power_kva.value == 352.0
assert math.isclose(contract.dc_ac_nameplate_ratio, 1.35, abs_tol=1e-12)
def test_reference_inverter_exposes_24_unique_physical_input_pairs() -> None:
contract = GENERIC_REFERENCE_EQUIPMENT_CONTRACT
inputs = contract.inverter.dc_inputs
assert contract.inverter.physical_dc_input_count.value == 24
assert len(inputs) == 24
assert [item.input_id for item in inputs] == [
f"dc_input_{index:02d}" for index in range(1, 25)
]
assert len({item.positive_terminal_id for item in inputs}) == 24
assert len({item.negative_terminal_id for item in inputs}) == 24
assert len(
{
terminal
for item in inputs
for terminal in (item.positive_terminal_id, item.negative_terminal_id)
}
) == 48
assert all(item.mppt_id.value is None for item in inputs)
assert all(
item.mppt_id.verification_state is VerificationState.UNKNOWN
for item in inputs
)
def test_internal_input_relationships_remain_explicitly_unresolved() -> None:
inverter = GENERIC_REFERENCE_EQUIPMENT_CONTRACT.inverter
assert inverter.mppt_count.value is None
assert inverter.internal_dc_topology.value == str(InternalDcTopology.UNKNOWN)
assert inverter.reverse_current_blocking.value == str(
ReverseCurrentBlockingState.UNKNOWN
)
assert inverter.pce_backfeed_current_a.value is None
assert inverter.maximum_dc_voltage_v.value is None
assert inverter.maximum_dc_input_power_kwp.value is None
for item in (
inverter.mppt_count,
inverter.internal_dc_topology,
inverter.reverse_current_blocking,
inverter.pce_backfeed_current_a,
inverter.maximum_dc_voltage_v,
inverter.maximum_dc_input_power_kwp,
):
assert not item.verified
def test_connector_leads_dimensions_and_electrical_module_data_remain_missing() -> None:
contract = GENERIC_REFERENCE_EQUIPMENT_CONTRACT
connector = contract.connector
module = contract.module
assert connector.mating_compatibility.value == str(
ConnectorCompatibilityState.UNKNOWN
)
assert connector.contact_resistance_ohm_per_mated_pair.value is None
assert connector.rated_current_a.value is None
assert connector.rated_voltage_v.value is None
assert contract.factory_leads.positive_lead_length_m.value is None
assert contract.factory_leads.negative_lead_length_m.value is None
assert module.voc_v.value is None
assert module.isc_a.value is None
assert module.vmp_v.value is None
assert module.imp_a.value is None
assert module.maximum_overcurrent_protection_rating_a.value is None
assert module.bifaciality_factor.value is None
assert module.width_m.value is None
assert module.length_m.value is None
def test_conductor_products_are_referenced_without_silent_promotion() -> None:
contract = GENERIC_REFERENCE_EQUIPMENT_CONTRACT
assert contract.factory_leads.conductor_product_id == FACTORY_LEAD_4MM2.product_id
assert contract.field_conductor.conductor_product_id == EXTERNAL_STRING_6MM2.product_id
assert assess_resistance_source(
FACTORY_LEAD_4MM2.resolved_resistance
).status is ResistanceSourceStatus.CANDIDATE
assert assess_resistance_source(
EXTERNAL_STRING_6MM2.resolved_resistance
).status is ResistanceSourceStatus.CANDIDATE
payload = reference_equipment_contract_payload(contract)
assert payload["factory_leads"]["resistance_source_status"] == "candidate"
assert payload["field_conductor"]["resistance_source_status"] == "candidate"
def test_missing_evidence_is_deterministic_and_includes_input_mapping() -> None:
missing = reference_equipment_missing_evidence(
GENERIC_REFERENCE_EQUIPMENT_CONTRACT
)
assert missing == tuple(sorted(missing))
assert "inverter.dc_inputs.dc_input_01.mppt_id" in missing
assert "inverter.dc_inputs.dc_input_24.mppt_id" in missing
assert "inverter.internal_dc_topology" in missing
assert "inverter.reverse_current_blocking" in missing
assert "inverter.pce_backfeed_current_a" in missing
assert "connector.mating_compatibility" in missing
assert "factory_leads.conductor_resistance_source" in missing
assert "field_conductor.conductor_resistance_source" in missing
assert "module.rated_power_wp" not in missing
assert "inverter.apparent_power_kva" not in missing
assert "inverter.physical_dc_input_count" not in missing
def test_contract_serialisation_and_hash_are_deterministic() -> None:
first = build_generic_reference_equipment_contract()
second = build_generic_reference_equipment_contract()
assert first == second
assert reference_equipment_contract_payload(first) == (
reference_equipment_contract_payload(second)
)
assert reference_equipment_contract_json(first) == (
reference_equipment_contract_json(second)
)
assert reference_equipment_contract_hash(first) == (
reference_equipment_contract_hash(second)
)
assert reference_equipment_contract_hash(first).startswith("sha256:")
assert len(reference_equipment_contract_hash(first)) == 71
assert json.loads(reference_equipment_contract_json(first)) == (
reference_equipment_contract_payload(first)
)
def test_hash_changes_when_a_bound_equipment_value_changes() -> None:
contract = build_generic_reference_equipment_contract()
changed_power = replace(
contract.module.rated_power_wp,
value=661.0,
)
changed_module = replace(contract.module, rated_power_wp=changed_power)
changed = replace(contract, module=changed_module)
with pytest.raises(ValueError, match="19.8 kWp"):
validate_reference_equipment_contract(changed)
changed_fixture = replace(
contract,
module=replace(
contract.module,
rated_power_wp=QualifiedValue(
value=660.0,
unit="Wp",
evidence_class=EvidenceClass.USER_CREATED,
verification_state=VerificationState.VERIFIED,
source_reference="product_owner_reference_fixture",
source_revision="2026-08-01-revised",
note="Changed source revision only.",
),
),
)
assert reference_equipment_contract_hash(changed_fixture) != (
reference_equipment_contract_hash(contract)
)
def test_unresolved_value_cannot_claim_verified_evidence() -> None:
invalid = QualifiedValue(
value=None,
unit="V",
evidence_class=EvidenceClass.ASSUMED,
verification_state=VerificationState.VERIFIED,
source_reference=None,
source_revision=None,
)
with pytest.raises(ValueError, match="unresolved qualified value"):
invalid.validate()
def test_serialised_contract_contains_no_identity_fields() -> None:
serialised = reference_equipment_contract_json(
GENERIC_REFERENCE_EQUIPMENT_CONTRACT
).lower()
for prohibited in (
"manufacturer_name",
"project_name",
"client_name",
"site_name",
):
assert prohibited not in serialisedTest Equipment Profiles Public API
A test in the tests folder of Solar Electrical Topology Analysis Engine Text Based.
testsolar-electrical-topology-analysis-engine-text-based / tests/test_equipment_profiles_public_api.py · lines 1–72 of 72 · Entry point
- What it does
- It tests its inputs. Defines test_equipment_contract_is_exposed_by_supported_package_api, test_equipment_contract_exports_are_explicitly_provisional, test_top_level_equipment_contract_reproduces_exact_authority_output. Uses libraries __future__, solar_topology, solar_topology.equipment_profiles.
- 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 `test_equipment_contract_is_exposed_by_supported_package_api`, `test_equipment_contract_exports_are_explicitly_provisional` and `test_top_level_equipment_contract_reproduces_exact_authority_output`.
- Why it matters
- Run by Build 025 Small Gates Workflow.
- Application
- solar-electrical-topology-analysis-engine-text-based · tests · test
- Uses
- __future__, solar_topology, solar_topology.equipment_profiles
- Used by
- run by Build 025 Small Gates Workflow (workflow run)
- Produces
- test_equipment_contract_is_exposed_by_supported_package_api, test_equipment_contract_exports_are_explicitly_provisional, test_top_level_equipment_contract_reproduces_exact_authority_output
- Defines here
- test_equipment_contract_is_exposed_by_supported_package_api, test_equipment_contract_exports_are_explicitly_provisional, test_top_level_equipment_contract_reproduces_exact_authority_output
- 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_equipment_profiles_public_api.py:1-72 · blob 225f6f890d7414cca3d759b0e1615bb591c44769 · 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
from __future__ import annotations
import solar_topology as api
import solar_topology.equipment_profiles as profiles
PUBLIC_NAMES = (
"EQUIPMENT_PROFILE_SCHEMA_VERSION",
"GENERIC_REFERENCE_CONTRACT_REVISION",
"GENERIC_REFERENCE_EQUIPMENT_CONTRACT",
"ConnectorCompatibilityState",
"ConnectorEquipmentProfile",
"DcInputProfile",
"FactoryLeadSetProfile",
"FieldConductorProfile",
"InternalDcTopology",
"InverterEquipmentProfile",
"ModuleEquipmentProfile",
"ModuleTechnology",
"QualifiedValue",
"ReferenceEquipmentContract",
"ReverseCurrentBlockingState",
"build_generic_reference_equipment_contract",
"reference_equipment_contract_hash",
"reference_equipment_contract_json",
"reference_equipment_contract_payload",
"reference_equipment_missing_evidence",
"validate_reference_equipment_contract",
)
def test_equipment_contract_is_exposed_by_supported_package_api() -> None:
assert api.EQUIPMENT_PROFILE_SCHEMA_VERSION == (
profiles.EQUIPMENT_PROFILE_SCHEMA_VERSION
)
assert api.GENERIC_REFERENCE_EQUIPMENT_CONTRACT is (
profiles.GENERIC_REFERENCE_EQUIPMENT_CONTRACT
)
assert api.ReferenceEquipmentContract is profiles.ReferenceEquipmentContract
assert api.build_generic_reference_equipment_contract is (
profiles.build_generic_reference_equipment_contract
)
assert api.reference_equipment_contract_hash is (
profiles.reference_equipment_contract_hash
)
assert all(name in api.__all__ for name in PUBLIC_NAMES)
def test_equipment_contract_exports_are_explicitly_provisional() -> None:
classified = api.explicitly_classified_public_names()
for name in PUBLIC_NAMES:
assert api.public_api_status(name) is api.ApiStatus.PROVISIONAL
assert name in classified
def test_top_level_equipment_contract_reproduces_exact_authority_output() -> None:
contract = api.build_generic_reference_equipment_contract()
authority = profiles.build_generic_reference_equipment_contract()
assert contract == authority
assert api.reference_equipment_contract_payload(contract) == (
profiles.reference_equipment_contract_payload(authority)
)
assert api.reference_equipment_contract_json(contract) == (
profiles.reference_equipment_contract_json(authority)
)
assert api.reference_equipment_contract_hash(contract) == (
profiles.reference_equipment_contract_hash(authority)
)
assert api.reference_equipment_missing_evidence(contract) == (
profiles.reference_equipment_missing_evidence(authority)
)