summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2023-04-15 12:16:19 +0200
committerBastien Nocera <hadess@hadess.net>2023-04-15 12:16:19 +0200
commit5db1bce65fcd509a7624dc2843173921b79e7d7b (patch)
treea3e959b110c653b27816cf344d3478868a7e1538
parentb3c439ab4aa086f4e42cc9b5f3d73e48c0346641 (diff)
downloadupower-5db1bce65fcd509a7624dc2843173921b79e7d7b.tar.gz
tests: Fix discharge rates in test_battery_state_guessing
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.
-rwxr-xr-xsrc/linux/integration-test.py6
1 files 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' : {} })