From 087bd7ba9be4fb688ee33ef236bfcc6f3ea80635 Mon Sep 17 00:00:00 2001 From: Max Chesterfield Date: Fri, 22 Aug 2025 14:24:10 +1000 Subject: [PATCH 1/5] not bad. Signed-off-by: Max Chesterfield --- changelog.md | 1 + pyproject.toml | 2 +- .../network/test_network_database_schema.py | 179 +++++++++--------- 3 files changed, 94 insertions(+), 88 deletions(-) diff --git a/changelog.md b/changelog.md index fc82c498..fd15acd6 100644 --- a/changelog.md +++ b/changelog.md @@ -140,6 +140,7 @@ ### Enhancements * `EquipmentTreeBuilder` will now calculate `leaves` when specified to do so. +* Bumped `hypothesis` version for tests to latest (6.138.2), fixed examples generating large numbers of results causing tests to run extremely slow. ### Fixes * Marked some extensions properties and classes with [ZBEX] that were missing them (might still be more). In addition to the ones moved into the extensions diff --git a/pyproject.toml b/pyproject.toml index 8cc33003..b8204b46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,7 @@ "pytest-asyncio==0.26.0", "pytest-timeout==2.4.0", "pytest-subtests", - "hypothesis==6.119.4", # 6.120.0 has issues with one of our large tests + "hypothesis==6.138.2", "grpcio-testing==1.61.3", "pylint==2.14.5", "six==1.16.0", diff --git a/test/database/sqlite/network/test_network_database_schema.py b/test/database/sqlite/network/test_network_database_schema.py index 47984a53..85f599f9 100644 --- a/test/database/sqlite/network/test_network_database_schema.py +++ b/test/database/sqlite/network/test_network_database_schema.py @@ -67,8 +67,13 @@ from zepben.ewb.services.common import resolver -# FIXME: see Line [305] +hypothesis_settings = dict( + deadline=2000, + suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow], + max_examples=4 +) +# FIXME: see Line [305] class PatchedNetworkTraceStepPath(NetworkTraceStep.Path): @property def from_equipment(self): @@ -136,7 +141,7 @@ async def test_load_real_file(self): # Extensions IEC61968 Asset Info # ################################## - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(relay_info=create_relay_info(False)) async def test_schema_relay_info(self, relay_info: RelayInfo): await self._validate_schema(SchemaNetworks().network_services_of(RelayInfo, relay_info)) @@ -145,7 +150,7 @@ async def test_schema_relay_info(self, relay_info: RelayInfo): # Extensions IEC61968 Metering # ################################ - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(pan_demand_response_function=create_pan_demand_response_function(False)) async def test_schema_pan_demand_response_function(self, pan_demand_response_function: PanDemandResponseFunction): await self._validate_schema(SchemaNetworks().network_services_of(PanDemandResponseFunction, pan_demand_response_function)) @@ -154,7 +159,7 @@ async def test_schema_pan_demand_response_function(self, pan_demand_response_fun # Extensions IEC61970 Base Core # ################################# - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(site=create_site(False)) async def test_schema_site(self, site: Site): await self._validate_schema(SchemaNetworks().network_services_of(Site, site)) @@ -163,12 +168,12 @@ async def test_schema_site(self, site: Site): # Extensions IEC61970 Base Feeder # ################################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(loop=create_loop(False)) async def test_schema_loop(self, loop: Loop): await self._validate_schema(SchemaNetworks().network_services_of(Loop, loop)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(lv_feeder=create_lv_feeder(False)) async def test_schema_lv_feeder(self, lv_feeder: LvFeeder): network = SchemaNetworks().network_services_of(LvFeeder, lv_feeder) @@ -181,7 +186,7 @@ async def test_schema_lv_feeder(self, lv_feeder: LvFeeder): # Extensions IEC61970 Base Generation Production # ################################################## - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(ev_charging_unit=create_ev_charging_unit(False)) async def test_schema_ev_charging_unit(self, ev_charging_unit: EvChargingUnit): await self._validate_schema(SchemaNetworks().network_services_of(EvChargingUnit, ev_charging_unit)) @@ -190,22 +195,22 @@ async def test_schema_ev_charging_unit(self, ev_charging_unit: EvChargingUnit): # Extensions IEC61970 Base Protection # ####################################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(distance_relay=create_distance_relay(False)) async def test_schema_distance_relay(self, distance_relay: DistanceRelay): await self._validate_schema(SchemaNetworks().network_services_of(DistanceRelay, distance_relay)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(protection_relay_scheme=create_protection_relay_scheme(False)) async def test_schema_protection_relay_scheme(self, protection_relay_scheme: ProtectionRelayScheme): await self._validate_schema(SchemaNetworks().network_services_of(ProtectionRelayScheme, protection_relay_scheme)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(protection_relay_system=create_protection_relay_system(False)) async def test_schema_protection_relay_system(self, protection_relay_system: ProtectionRelaySystem): await self._validate_schema(SchemaNetworks().network_services_of(ProtectionRelaySystem, protection_relay_system)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(voltage_relay=create_voltage_relay(False)) async def test_schema_voltage_relay(self, voltage_relay: VoltageRelay): await self._validate_schema(SchemaNetworks().network_services_of(VoltageRelay, voltage_relay)) @@ -214,7 +219,7 @@ async def test_schema_voltage_relay(self, voltage_relay: VoltageRelay): # Extensions IEC61970 Base Wires # ################################## - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(battery_control=create_battery_control(False)) async def test_schema_battery_control(self, battery_control: BatteryControl): await self._validate_schema(SchemaNetworks().network_services_of(BatteryControl, battery_control)) @@ -223,52 +228,52 @@ async def test_schema_battery_control(self, battery_control: BatteryControl): # IEC61968 Asset Info # ####################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(cable_info=create_cable_info(False)) async def test_schema_cable_info(self, cable_info: CableInfo): await self._validate_schema(SchemaNetworks().network_services_of(CableInfo, cable_info)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(no_load_test=create_no_load_test(False)) async def test_schema_no_load_test(self, no_load_test: NoLoadTest): await self._validate_schema(SchemaNetworks().network_services_of(NoLoadTest, no_load_test)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(open_circuit_test=create_open_circuit_test(False)) async def test_schema_open_circuit_test(self, open_circuit_test: OpenCircuitTest): await self._validate_schema(SchemaNetworks().network_services_of(OpenCircuitTest, open_circuit_test)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(overhead_wire_info=create_overhead_wire_info(False)) async def test_schema_overhead_wire_info(self, overhead_wire_info: OverheadWireInfo): await self._validate_schema(SchemaNetworks().network_services_of(OverheadWireInfo, overhead_wire_info)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(power_transformer_info=create_power_transformer_info(False)) async def test_schema_power_transformer_info(self, power_transformer_info: PowerTransformerInfo): await self._validate_schema(SchemaNetworks().network_services_of(PowerTransformerInfo, power_transformer_info)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(short_circuit_test=create_short_circuit_test(False)) async def test_schema_short_circuit_test(self, short_circuit_test: ShortCircuitTest): await self._validate_schema(SchemaNetworks().network_services_of(ShortCircuitTest, short_circuit_test)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(shunt_compensator_info=create_shunt_compensator_info(False)) async def test_schema_shunt_compensator_info(self, shunt_compensator_info: ShuntCompensatorInfo): await self._validate_schema(SchemaNetworks().network_services_of(ShuntCompensatorInfo, shunt_compensator_info)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(switch_info=create_switch_info(False)) async def test_schema_switch_info(self, switch_info: SwitchInfo): await self._validate_schema(SchemaNetworks().network_services_of(SwitchInfo, switch_info)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(transformer_end_info=create_transformer_end_info(False)) async def test_schema_transformer_end_info(self, transformer_end_info: TransformerEndInfo): await self._validate_schema(SchemaNetworks().network_services_of(TransformerEndInfo, transformer_end_info)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(transformer_tank_info=create_transformer_tank_info(False)) async def test_schema_transformer_tank_info(self, transformer_tank_info: TransformerTankInfo): await self._validate_schema(SchemaNetworks().network_services_of(TransformerTankInfo, transformer_tank_info)) @@ -277,12 +282,12 @@ async def test_schema_transformer_tank_info(self, transformer_tank_info: Transfo # IEC61968 Assets # ################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(asset_owner=create_asset_owner(False)) async def test_schema_asset_owner(self, asset_owner: AssetOwner): await self._validate_schema(SchemaNetworks().network_services_of(AssetOwner, asset_owner)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(streetlight=create_streetlight(False)) async def test_schema_streetlight(self, streetlight: Streetlight): await self._validate_schema(SchemaNetworks().network_services_of(Streetlight, streetlight)) @@ -291,12 +296,12 @@ async def test_schema_streetlight(self, streetlight: Streetlight): # IEC61968 Common # ################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(location=create_location(False)) async def test_schema_location(self, location: Location): await self._validate_schema(SchemaNetworks().network_services_of(Location, location)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(organisation=create_organisation(False)) async def test_schema_organisation(self, organisation: Organisation): await self._validate_schema(SchemaNetworks().network_services_of(Organisation, organisation)) @@ -305,12 +310,12 @@ async def test_schema_organisation(self, organisation: Organisation): # IEC61968 InfIEC61968 InfAssetInfo # ##################################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(current_transformer_info=create_current_transformer_info(False)) async def test_schema_current_transformer_info(self, current_transformer_info: CurrentTransformerInfo): await self._validate_schema(SchemaNetworks().network_services_of(CurrentTransformerInfo, current_transformer_info)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(potential_transformer_info=create_potential_transformer_info(False)) async def test_schema_potential_transformer_info(self, potential_transformer_info: PotentialTransformerInfo): await self._validate_schema(SchemaNetworks().network_services_of(PotentialTransformerInfo, potential_transformer_info)) @@ -319,7 +324,7 @@ async def test_schema_potential_transformer_info(self, potential_transformer_inf # IEC61968 InfIEC61968 InfAssets # ################################## - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(pole=create_pole(False)) async def test_schema_pole(self, pole: Pole): await self._validate_schema(SchemaNetworks().network_services_of(Pole, pole)) @@ -328,12 +333,12 @@ async def test_schema_pole(self, pole: Pole): # IEC61968 Metering # ##################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(meter=create_meter(False)) async def test_schema_meter(self, meter: Meter): await self._validate_schema(SchemaNetworks().network_services_of(Meter, meter)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(usage_point=create_usage_point(False)) async def test_schema_usage_point(self, usage_point: UsagePoint): await self._validate_schema(SchemaNetworks().network_services_of(UsagePoint, usage_point)) @@ -342,7 +347,7 @@ async def test_schema_usage_point(self, usage_point: UsagePoint): # IEC61968 Operations # ####################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(operational_restriction=create_operational_restriction(False)) async def test_schema_operational_restriction(self, operational_restriction: OperationalRestriction): await self._validate_schema(SchemaNetworks().network_services_of(OperationalRestriction, operational_restriction)) @@ -351,17 +356,17 @@ async def test_schema_operational_restriction(self, operational_restriction: Ope # IEC61970 Base Auxiliary Equipment # ##################################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(current_transformer=create_current_transformer(False)) async def test_schema_current_transformer(self, current_transformer: CurrentTransformer): await self._validate_schema(SchemaNetworks().network_services_of(CurrentTransformer, current_transformer)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(fault_indicator=create_fault_indicator(False)) async def test_schema_fault_indicator(self, fault_indicator: FaultIndicator): await self._validate_schema(SchemaNetworks().network_services_of(FaultIndicator, fault_indicator)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(potential_transformer=create_potential_transformer(False)) async def test_schema_potential_transformer(self, potential_transformer: PotentialTransformer): await self._validate_schema(SchemaNetworks().network_services_of(PotentialTransformer, potential_transformer)) @@ -370,17 +375,17 @@ async def test_schema_potential_transformer(self, potential_transformer: Potenti # IEC61970 Base Core # ###################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(base_voltage=create_base_voltage(False)) async def test_schema_base_voltage(self, base_voltage: BaseVoltage): await self._validate_schema(SchemaNetworks().network_services_of(BaseVoltage, base_voltage)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(connectivity_node=create_connectivity_node(False)) async def test_schema_connectivity_node(self, connectivity_node: ConnectivityNode): await self._validate_schema(SchemaNetworks().network_services_of(ConnectivityNode, connectivity_node)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(feeder=create_feeder(False)) async def test_schema_feeder(self, feeder: Feeder): # Need to set feeder directions to match database load. @@ -402,22 +407,22 @@ async def test_schema_feeder(self, feeder: Feeder): await self._validate_schema(network_service) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(geographical_region=create_geographical_region(False)) async def test_schema_geographical_region(self, geographical_region: GeographicalRegion): await self._validate_schema(SchemaNetworks().network_services_of(GeographicalRegion, geographical_region)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(sub_geographical_region=create_sub_geographical_region(False)) async def test_schema_sub_geographical_region(self, sub_geographical_region: SubGeographicalRegion): await self._validate_schema(SchemaNetworks().network_services_of(SubGeographicalRegion, sub_geographical_region)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(substation=create_substation(False)) async def test_schema_substation(self, substation: Substation): await self._validate_schema(SchemaNetworks().network_services_of(Substation, substation)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(terminal=create_terminal(False)) async def test_schema_terminal(self, terminal: Terminal): await self._validate_schema(SchemaNetworks().network_services_of(Terminal, terminal)) @@ -426,7 +431,7 @@ async def test_schema_terminal(self, terminal: Terminal): # IEC61970 Base Equivalents # ############################# - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(equivalent_branch=create_equivalent_branch(False)) async def test_schema_equivalent_branch(self, equivalent_branch: EquivalentBranch): await self._validate_schema(SchemaNetworks().network_services_of(EquivalentBranch, equivalent_branch)) @@ -435,17 +440,17 @@ async def test_schema_equivalent_branch(self, equivalent_branch: EquivalentBranc # IEC61970 Base Generation Production # ####################################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(battery_unit=create_battery_unit(False)) async def test_schema_battery_unit(self, battery_unit: BatteryUnit): await self._validate_schema(SchemaNetworks().network_services_of(BatteryUnit, battery_unit)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(photo_voltaic_unit=create_photo_voltaic_unit(False)) async def test_schema_photo_voltaic_unit(self, photo_voltaic_unit: PhotoVoltaicUnit): await self._validate_schema(SchemaNetworks().network_services_of(PhotoVoltaicUnit, photo_voltaic_unit)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(power_electronics_wind_unit=create_power_electronics_wind_unit(False)) async def test_schema_power_electronics_wind_unit(self, power_electronics_wind_unit: PowerElectronicsWindUnit): await self._validate_schema(SchemaNetworks().network_services_of(PowerElectronicsWindUnit, power_electronics_wind_unit)) @@ -454,22 +459,22 @@ async def test_schema_power_electronics_wind_unit(self, power_electronics_wind_u # IEC61970 Base Meas # ###################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(accumulator=create_accumulator(False)) async def test_schema_accumulator(self, accumulator: Accumulator): await self._validate_schema(SchemaNetworks().network_services_of(Accumulator, accumulator)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(analog=create_analog(False)) async def test_schema_analog(self, analog: Analog): await self._validate_schema(SchemaNetworks().network_services_of(Analog, analog)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(control=create_control(False)) async def test_schema_control(self, control: Control): await self._validate_schema(SchemaNetworks().network_services_of(Control, control)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(discrete=create_discrete(False)) async def test_schema_discrete(self, discrete: Discrete): await self._validate_schema(SchemaNetworks().network_services_of(Discrete, discrete)) @@ -478,7 +483,7 @@ async def test_schema_discrete(self, discrete: Discrete): # IEC61970 Base Protection # ############################ - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(current_relay=create_current_relay(False)) async def test_schema_current_relay(self, current_relay: CurrentRelay): await self._validate_schema(SchemaNetworks().network_services_of(CurrentRelay, current_relay)) @@ -487,12 +492,12 @@ async def test_schema_current_relay(self, current_relay: CurrentRelay): # IEC61970 Base Scada # ####################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(remote_control=create_remote_control(False)) async def test_schema_remote_control(self, remote_control: RemoteControl): await self._validate_schema(SchemaNetworks().network_services_of(RemoteControl, remote_control)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(remote_source=create_remote_source(False)) async def test_schema_remote_source(self, remote_source: RemoteSource): await self._validate_schema(SchemaNetworks().network_services_of(RemoteSource, remote_source)) @@ -501,49 +506,49 @@ async def test_schema_remote_source(self, remote_source: RemoteSource): # IEC61970 Base Wires # ####################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(ac_line_segment=create_ac_line_segment(False)) async def test_schema_ac_line_segment(self, ac_line_segment: AcLineSegment): await self._validate_schema(SchemaNetworks().network_services_of(AcLineSegment, ac_line_segment)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(breaker=create_breaker(False)) async def test_schema_breaker(self, breaker: Breaker): await self._validate_schema(SchemaNetworks().network_services_of(Breaker, breaker)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(busbar_section=create_busbar_section(False)) async def test_schema_busbar_section(self, busbar_section: BusbarSection): await self._validate_schema(SchemaNetworks().network_services_of(BusbarSection, busbar_section)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(clamp=create_clamp(False)) async def test_schema_clamp(self, clamp: Clamp): await self._validate_schema(SchemaNetworks().network_services_of(Clamp, clamp)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(cut=create_cut(False)) async def test_schema_cut(self, cut: Cut): await self._validate_schema(SchemaNetworks().network_services_of(Cut, cut)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(disconnector=create_disconnector(False)) async def test_schema_disconnector(self, disconnector: Disconnector): await self._validate_schema(SchemaNetworks().network_services_of(Disconnector, disconnector)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(energy_consumer=create_energy_consumer(False)) async def test_schema_energy_consumer(self, energy_consumer: EnergyConsumer): # Need to assure the correct number of phases to prevent errors. assume(len(Counter(map(lambda it: it.phase, energy_consumer.phases))) == len(list(energy_consumer.phases))) await self._validate_schema(SchemaNetworks().network_services_of(EnergyConsumer, energy_consumer)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(energy_consumer_phase=create_energy_consumer_phase(False)) async def test_schema_energy_consumer_phase(self, energy_consumer_phase: EnergyConsumerPhase): await self._validate_schema(SchemaNetworks().network_services_of(EnergyConsumerPhase, energy_consumer_phase)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(energy_source=create_energy_source(False)) async def test_schema_energy_source(self, energy_source: EnergySource): # Need to assure the correct number of phases to prevent errors. @@ -555,122 +560,122 @@ async def test_schema_energy_source(self, energy_source: EnergySource): await self._validate_schema(network_service) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(energy_source_phase=create_energy_source_phase(False)) async def test_schema_energy_source_phase(self, energy_source_phase: EnergyConsumerPhase): await self._validate_schema(SchemaNetworks().network_services_of(EnergySourcePhase, energy_source_phase)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(fuse=create_fuse(False)) async def test_schema_fuse(self, fuse: Fuse): await self._validate_schema(SchemaNetworks().network_services_of(Fuse, fuse)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(ground=create_ground(False)) async def test_schema_ground(self, ground: Ground): await self._validate_schema(SchemaNetworks().network_services_of(Ground, ground)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(ground_disconnector=create_ground_disconnector(False)) async def test_schema_ground_disconnector(self, ground_disconnector: GroundDisconnector): await self._validate_schema(SchemaNetworks().network_services_of(GroundDisconnector, ground_disconnector)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(grounding_impedance=create_grounding_impedance(False)) async def test_schema_grounding_impedance(self, grounding_impedance: GroundingImpedance): await self._validate_schema(SchemaNetworks().network_services_of(GroundingImpedance, grounding_impedance)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(jumper=create_jumper(False)) async def test_schema_jumper(self, jumper: Jumper): await self._validate_schema(SchemaNetworks().network_services_of(Jumper, jumper)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(junction=create_junction(False)) async def test_schema_junction(self, junction: Junction): await self._validate_schema(SchemaNetworks().network_services_of(Junction, junction)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(linear_shunt_compensator=create_linear_shunt_compensator(False)) async def test_schema_linear_shunt_compensator(self, linear_shunt_compensator: LinearShuntCompensator): await self._validate_schema(SchemaNetworks().network_services_of(LinearShuntCompensator, linear_shunt_compensator)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(load_break_switch=create_load_break_switch(False)) async def test_schema_load_break_switch(self, load_break_switch: LoadBreakSwitch): await self._validate_schema(SchemaNetworks().network_services_of(LoadBreakSwitch, load_break_switch)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(per_length_phase_impedance=create_per_length_phase_impedance(False)) async def test_schema_per_length_phase_impedance(self, per_length_phase_impedance: PerLengthPhaseImpedance): await self._validate_schema(SchemaNetworks().network_services_of(PerLengthPhaseImpedance, per_length_phase_impedance)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(per_length_sequence_impedance=create_per_length_sequence_impedance(False)) async def test_schema_per_length_sequence_impedance(self, per_length_sequence_impedance: PerLengthSequenceImpedance): await self._validate_schema(SchemaNetworks().network_services_of(PerLengthSequenceImpedance, per_length_sequence_impedance)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(petersen_coil=create_petersen_coil(False)) async def test_schema_petersen_coil(self, petersen_coil: PetersenCoil): await self._validate_schema(SchemaNetworks().network_services_of(PetersenCoil, petersen_coil)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(power_electronics_connection=create_power_electronics_connection(False)) async def test_schema_power_electronics_connection(self, power_electronics_connection: PowerElectronicsConnection): await self._validate_schema(SchemaNetworks().network_services_of(PowerElectronicsConnection, power_electronics_connection)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(power_electronics_connection_phase=create_power_electronics_connection_phase(False)) async def test_schema_power_electronics_connection_phase(self, power_electronics_connection_phase: PowerElectronicsConnectionPhase): await self._validate_schema(SchemaNetworks().network_services_of(PowerElectronicsConnectionPhase, power_electronics_connection_phase)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(power_transformer=create_power_transformer(False)) async def test_schema_power_transformer(self, power_transformer: PowerTransformer): await self._validate_schema(SchemaNetworks().network_services_of(PowerTransformer, power_transformer)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(power_transformer_end=create_power_transformer_end(False)) async def test_schema_power_transformer_end(self, power_transformer_end: PowerTransformerEnd): await self._validate_schema(SchemaNetworks().network_services_of(PowerTransformerEnd, power_transformer_end)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(ratio_tap_changer=create_ratio_tap_changer(False)) async def test_schema_ratio_tap_changer(self, ratio_tap_changer: RatioTapChanger): await self._validate_schema(SchemaNetworks().network_services_of(RatioTapChanger, ratio_tap_changer)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(reactive_capability_curve=create_reactive_capability_curve(False)) async def test_schema_reactive_capability_curve(self, reactive_capability_curve: ReactiveCapabilityCurve): await self._validate_schema(SchemaNetworks().network_services_of(ReactiveCapabilityCurve, reactive_capability_curve)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(recloser=create_recloser(False)) async def test_schema_recloser(self, recloser: Recloser): await self._validate_schema(SchemaNetworks().network_services_of(Recloser, recloser)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(series_compensator=create_series_compensator(False)) async def test_schema_series_compensator(self, series_compensator: SeriesCompensator): await self._validate_schema(SchemaNetworks().network_services_of(SeriesCompensator, series_compensator)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(static_var_compensator=create_static_var_compensator(False)) async def test_schema_static_var_compensator(self, static_var_compensator: StaticVarCompensator): await self._validate_schema(SchemaNetworks().network_services_of(StaticVarCompensator, static_var_compensator)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(synchronous_machine=create_synchronous_machine(False)) async def test_schema_synchronous_machine(self, synchronous_machine: SynchronousMachine): await self._validate_schema(SchemaNetworks().network_services_of(SynchronousMachine, synchronous_machine)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(tap_changer_control=create_tap_changer_control(False)) async def test_schema_tap_changer_control(self, tap_changer_control: TapChangerControl): await self._validate_schema(SchemaNetworks().network_services_of(TapChangerControl, tap_changer_control)) - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(transformer_star_impedance=create_transformer_star_impedance(False)) async def test_schema_transformer_star_impedance(self, transformer_star_impedance: TransformerStarImpedance): await self._validate_schema(SchemaNetworks().network_services_of(TransformerStarImpedance, transformer_star_impedance)) @@ -679,7 +684,7 @@ async def test_schema_transformer_star_impedance(self, transformer_star_impedanc # IEC61970 InfIEC61970 Feeder # ############################### - @settings(deadline=2000, suppress_health_check=[HealthCheck.function_scoped_fixture, HealthCheck.too_slow]) + @settings(**hypothesis_settings) @given(circuit=create_circuit(False)) async def test_schema_circuit(self, circuit: Circuit): await self._validate_schema(SchemaNetworks().network_services_of(Circuit, circuit)) From e336653f791dd43bfe11d7f6042ac01e3d84ac69 Mon Sep 17 00:00:00 2001 From: Max Chesterfield Date: Fri, 22 Aug 2025 14:58:50 +1000 Subject: [PATCH 2/5] everything seems happy? Signed-off-by: Max Chesterfield --- pyproject.toml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b8204b46..925c47a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,10 +24,11 @@ ] dependencies = [ "zepben.protobuf==1.0.0", - "typing_extensions==4.12.2", - "requests>=2.26.0, <3.0.0", - "urllib3>=1.26.6, <1.27.0", - "PyJWT>=2.1.0, <2.2.0", + "typing_extensions==4.14.1", + "requests==2.32.5", + "urllib3==2.5.0", + "PyJWT==2.10.1", + "dataclassy==0.6.2", ] classifiers = [ "Programming Language :: Python :: 3", @@ -43,11 +44,11 @@ [project.optional-dependencies] test = [ - "pytest>=7.4.4, <9", + "pytest==8.4.1", "pytest-cov==6.1.1", "pytest-asyncio==0.26.0", "pytest-timeout==2.4.0", - "pytest-subtests", + "pytest-subtests==0.14.2", "hypothesis==6.138.2", "grpcio-testing==1.61.3", "pylint==2.14.5", From 051896c55292c4b39023e1c90ecae1e9e8f0b29c Mon Sep 17 00:00:00 2001 From: Max Chesterfield Date: Fri, 22 Aug 2025 15:12:29 +1000 Subject: [PATCH 3/5] moar Signed-off-by: Max Chesterfield --- changelog.md | 1 + pyproject.toml | 4 ++-- test/cim/iec61970/base/wires/test_regulating_control.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index fd15acd6..d59770d8 100644 --- a/changelog.md +++ b/changelog.md @@ -141,6 +141,7 @@ ### Enhancements * `EquipmentTreeBuilder` will now calculate `leaves` when specified to do so. * Bumped `hypothesis` version for tests to latest (6.138.2), fixed examples generating large numbers of results causing tests to run extremely slow. +* Bumped every other dependency to the latest version aside from dataclassy. ### Fixes * Marked some extensions properties and classes with [ZBEX] that were missing them (might still be more). In addition to the ones moved into the extensions diff --git a/pyproject.toml b/pyproject.toml index 925c47a0..01fc985c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,8 +45,8 @@ [project.optional-dependencies] test = [ "pytest==8.4.1", - "pytest-cov==6.1.1", - "pytest-asyncio==0.26.0", + "pytest-cov==6.2.1", + "pytest-asyncio==1.1.0", "pytest-timeout==2.4.0", "pytest-subtests==0.14.2", "hypothesis==6.138.2", diff --git a/test/cim/iec61970/base/wires/test_regulating_control.py b/test/cim/iec61970/base/wires/test_regulating_control.py index 593b3459..a8eb0fe7 100644 --- a/test/cim/iec61970/base/wires/test_regulating_control.py +++ b/test/cim/iec61970/base/wires/test_regulating_control.py @@ -24,7 +24,7 @@ "terminal": builds(Terminal), "ct_primary": floats(min_value=FLOAT_MIN, max_value=FLOAT_MAX), "min_target_deadband": floats(min_value=FLOAT_MIN, max_value=FLOAT_MAX), - "regulating_conducting_equipment": lists(builds(PowerElectronicsConnection)) + "regulating_conducting_equipment": lists(builds(PowerElectronicsConnection), max_size=2) } regulating_control_args = [*power_system_resource_args, False, RegulatingControlModeKind.voltage, PhaseCode.ABC, 1.1, 2.2, True, 3.3, 4.4, 5.5, Terminal(), 6.6, From 54434055d6d2185f95c8a3e9ce58cc735009d8c0 Mon Sep 17 00:00:00 2001 From: Max Chesterfield Date: Fri, 29 Aug 2025 11:14:58 +1000 Subject: [PATCH 4/5] herp Signed-off-by: Max Chesterfield --- test/services/network/translator/test_network_translator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/services/network/translator/test_network_translator.py b/test/services/network/translator/test_network_translator.py index b23812eb..5a185c33 100644 --- a/test/services/network/translator/test_network_translator.py +++ b/test/services/network/translator/test_network_translator.py @@ -228,7 +228,7 @@ @pytest.mark.timeout(100000) @given(**types_to_test) -@settings(suppress_health_check=[HealthCheck.too_slow, HealthCheck.large_base_example, HealthCheck.data_too_large]) +@settings(suppress_health_check=[HealthCheck.too_slow, HealthCheck.large_base_example, HealthCheck.data_too_large], stateful_step_count=2) def test_network_service_translations(**kwargs): # # NOTE: To prevent the `assume` required for the location from making this test take way too long, it has been separated out. From 8e774a463493db328155f34935e4c55632ff5165 Mon Sep 17 00:00:00 2001 From: Max Chesterfield Date: Mon, 13 Oct 2025 11:46:01 +1100 Subject: [PATCH 5/5] fix changelog entry going to wrong version after merge Signed-off-by: Max Chesterfield --- changelog.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index d59770d8..6139b2ab 100644 --- a/changelog.md +++ b/changelog.md @@ -7,7 +7,8 @@ * None. ### Enhancements -* None. +* Bumped `hypothesis` version for tests to latest (6.138.2), fixed examples generating large numbers of results causing tests to run extremely slow. +* Bumped every other dependency to the latest version aside from dataclassy. ### Fixes * Moved ZepbenTokenAuth to use python dataclasses instead of `zepben.ewb.dataclassy`, existing code should work as is. @@ -140,8 +141,6 @@ ### Enhancements * `EquipmentTreeBuilder` will now calculate `leaves` when specified to do so. -* Bumped `hypothesis` version for tests to latest (6.138.2), fixed examples generating large numbers of results causing tests to run extremely slow. -* Bumped every other dependency to the latest version aside from dataclassy. ### Fixes * Marked some extensions properties and classes with [ZBEX] that were missing them (might still be more). In addition to the ones moved into the extensions