diff --git a/src/isar_robot/telemetry.py b/src/isar_robot/telemetry.py index 5cae5155..241a79aa 100644 --- a/src/isar_robot/telemetry.py +++ b/src/isar_robot/telemetry.py @@ -13,12 +13,16 @@ def _get_battery_level() -> float: - return 100 - random.randrange(0, 100) * 0.5 + # Return random float in the range [50, 100] + return random.randint(500, 1000) / 10.0 def _get_pressure_level() -> float: + # Return random float in the range [0.011, 0.079] + min_pressure = 11 # millibar + max_pressure = 79 # millibar millibar_to_bar: float = 1 / 1000 - return (80 - random.randrange(10, 80) * 0.5) * millibar_to_bar + return random.randint(min_pressure, max_pressure) * millibar_to_bar def _get_obstacle_status() -> bool: diff --git a/tests/test_telemetry.py b/tests/test_telemetry.py new file mode 100644 index 00000000..c2c2a97a --- /dev/null +++ b/tests/test_telemetry.py @@ -0,0 +1,15 @@ +from isar_robot.telemetry import _get_pressure_level, _get_battery_level + + +def test_get_battery_level(): + for _ in range(100): + pressure_level: float = _get_battery_level() + assert pressure_level >= 50 + assert pressure_level <= 100 + + +def test_get_pressure_level(): + for _ in range(100): + pressure_level: float = _get_pressure_level() + assert pressure_level >= 0.011 + assert pressure_level <= 0.079