From 5db1bce65fcd509a7624dc2843173921b79e7d7b Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Sat, 15 Apr 2023 12:16:19 +0200 Subject: tests: Fix discharge rates in test_battery_state_guessing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit up_device_battery_estimate_power() expects a charge/discharge rate of 0.5W to be significant, but the existing code yielded a rate of -0.000240W. Fix the units so that the amount of change in energy_now is at least 1W/s converted to µWh. --- src/linux/integration-test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/linux/integration-test.py b/src/linux/integration-test.py index 42bf736..790d8c2 100755 --- a/src/linux/integration-test.py +++ b/src/linux/integration-test.py @@ -615,7 +615,8 @@ class Tests(dbusmock.DBusTestCase): # Discharge for 20s: for i in range(25): time.sleep(1) - energy_now -= 10.0 / 3600 + # 1W usage over 1 second + energy_now -= 1.0 * 1000000 / 3600 self.testbed.set_attribute(bat0, 'energy_now', str(int(energy_now))) self.assertDevs({ 'battery_BAT0': { 'State' : UP_DEVICE_STATE_DISCHARGING }, 'line_power_AC' : {} }) @@ -630,7 +631,8 @@ class Tests(dbusmock.DBusTestCase): # Charge for a while for i in range(25): time.sleep(1) - energy_now += 10.0 / 3600 + # 1W charge over 1 second + energy_now += 1.0 * 1000000 / 3600 self.testbed.set_attribute(bat0, 'energy_now', str(int(energy_now))) self.assertDevs({ 'battery_BAT0': { 'State' : UP_DEVICE_STATE_CHARGING }, 'line_power_AC' : {} }) -- cgit v1.2.1