added absolute value to handle negative CURRENT_NOW & test case (#730)
This commit is contained in:
parent
b5a232c4a7
commit
8549850d6a
@ -69,7 +69,7 @@ class BatteryCharge(Battery):
|
||||
|
||||
def consumption(self):
|
||||
if "VOLTAGE_NOW" in self.battery_info and "CURRENT_NOW" in self.battery_info:
|
||||
return super().consumption(self.battery_info["VOLTAGE_NOW"] * self.battery_info["CURRENT_NOW"]) # V * A = W
|
||||
return super().consumption(self.battery_info["VOLTAGE_NOW"] * abs(self.battery_info["CURRENT_NOW"])) # V * A = W
|
||||
else:
|
||||
return None
|
||||
|
||||
|
@ -24,6 +24,7 @@ def battery_test(path, format, expected):
|
||||
("test_battery_132", "DIS", "8.370", "1h:17m"),
|
||||
("test_battery_broken1", "FULL", "0.000", "0h:00m"),
|
||||
("test_battery_issue89_2", "DIS", "0.000", "0h:00m"),
|
||||
("test_battery_issue729", "DIS", "4.341", "4h:32m")
|
||||
])
|
||||
def test_basic(path, status, consumption, remaining):
|
||||
battery_test(path, "{status}", status)
|
||||
|
24
tests/test_battery_issue729
Normal file
24
tests/test_battery_issue729
Normal file
@ -0,0 +1,24 @@
|
||||
POWER_SUPPLY_NAME=sbs-104-000b
|
||||
POWER_SUPPLY_STATUS=Discharging
|
||||
POWER_SUPPLY_CAPACITY_LEVEL=Normal
|
||||
POWER_SUPPLY_HEALTH=Unknown
|
||||
POWER_SUPPLY_PRESENT=1
|
||||
POWER_SUPPLY_TECHNOLOGY=Li-ion
|
||||
POWER_SUPPLY_CYCLE_COUNT=149
|
||||
POWER_SUPPLY_VOLTAGE_NOW=7766000
|
||||
POWER_SUPPLY_CURRENT_NOW=-559000
|
||||
POWER_SUPPLY_CAPACITY=67
|
||||
POWER_SUPPLY_TEMP=279
|
||||
POWER_SUPPLY_TIME_TO_EMPTY_AVG=15540
|
||||
POWER_SUPPLY_TIME_TO_FULL_AVG=3932100
|
||||
POWER_SUPPLY_SERIAL_NUMBER=0fdb
|
||||
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=7500000
|
||||
POWER_SUPPLY_VOLTAGE_MAX_DESIGN=7500000
|
||||
POWER_SUPPLY_ENERGY_NOW=18640000
|
||||
POWER_SUPPLY_ENERGY_FULL=28890000
|
||||
POWER_SUPPLY_ENERGY_FULL_DESIGN=30600000
|
||||
POWER_SUPPLY_CHARGE_NOW=2542000
|
||||
POWER_SUPPLY_CHARGE_FULL=3811000
|
||||
POWER_SUPPLY_CHARGE_FULL_DESIGN=4080000
|
||||
POWER_SUPPLY_MANUFACTURER=SDI
|
||||
POWER_SUPPLY_MODEL_NAME=4302D40
|
Loading…
Reference in New Issue
Block a user