Add tests for battery module
Good news: they're passed before the blob of commits in the last half hours, and they're still passing...
This commit is contained in:
parent
074500007f
commit
08c861d902
32
tests/test_battery.py
Executable file
32
tests/test_battery.py
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import unittest
|
||||
|
||||
from i3pystatus import battery
|
||||
|
||||
def factory(path, format, expected):
|
||||
def test():
|
||||
bc = battery.BatteryChecker(path=path, format=format)
|
||||
bc.run()
|
||||
print(bc.output["full_text"])
|
||||
assert bc.output["full_text"] == expected
|
||||
test.description = path + ":" + format
|
||||
return test
|
||||
|
||||
def basic_test_generator():
|
||||
cases = [
|
||||
("test_battery_basic1", "FULL", "0.000", ""),
|
||||
("test_battery_basic2", "FULL", "0.000", ""),
|
||||
("test_battery_basic3", "DIS", "15.624", "4h:04m"),
|
||||
("test_battery_basic4", "DIS", "17.510", "1h:46m"),
|
||||
("test_battery_basic5", "DIS", "11.453", "4h:52m"),
|
||||
("test_battery_basic6", "CHR", "30.764", "0h:20m"),
|
||||
]
|
||||
for path, status, consumption, remaining in cases:
|
||||
yield factory(path, "{status}", status)
|
||||
yield factory(path, "{consumption:.3f}", consumption)
|
||||
yield factory(path, "{remaining_hm}", remaining)
|
||||
|
||||
|
||||
#suite = unittest.TestLoader().loadTestsFromName(__name__)
|
||||
#unittest.TextTestRunner(verbosity=2).run(suite)
|
15
tests/test_battery_basic1
Normal file
15
tests/test_battery_basic1
Normal file
@ -0,0 +1,15 @@
|
||||
POWER_SUPPLY_NAME=BAT0
|
||||
POWER_SUPPLY_STATUS=Unknown
|
||||
POWER_SUPPLY_PRESENT=1
|
||||
POWER_SUPPLY_TECHNOLOGY=Li-ion
|
||||
POWER_SUPPLY_CYCLE_COUNT=0
|
||||
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
|
||||
POWER_SUPPLY_VOLTAGE_NOW=12514000
|
||||
POWER_SUPPLY_POWER_NOW=0
|
||||
POWER_SUPPLY_ENERGY_FULL_DESIGN=84240000
|
||||
POWER_SUPPLY_ENERGY_FULL=64360000
|
||||
POWER_SUPPLY_ENERGY_NOW=64300000
|
||||
POWER_SUPPLY_CAPACITY=99
|
||||
POWER_SUPPLY_MODEL_NAME=42T4650
|
||||
POWER_SUPPLY_MANUFACTURER=Panasonic
|
||||
POWER_SUPPLY_SERIAL_NUMBER= 176
|
15
tests/test_battery_basic2
Normal file
15
tests/test_battery_basic2
Normal file
@ -0,0 +1,15 @@
|
||||
POWER_SUPPLY_NAME=BAT0
|
||||
POWER_SUPPLY_STATUS=Full
|
||||
POWER_SUPPLY_PRESENT=1
|
||||
POWER_SUPPLY_TECHNOLOGY=Li-ion
|
||||
POWER_SUPPLY_CYCLE_COUNT=0
|
||||
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
|
||||
POWER_SUPPLY_VOLTAGE_NOW=12512000
|
||||
POWER_SUPPLY_CURRENT_NOW=0
|
||||
POWER_SUPPLY_CHARGE_FULL_DESIGN=4698000
|
||||
POWER_SUPPLY_CHARGE_FULL=4698000
|
||||
POWER_SUPPLY_CHARGE_NOW=4698000
|
||||
POWER_SUPPLY_CAPACITY=100
|
||||
POWER_SUPPLY_MODEL_NAME=Primary
|
||||
POWER_SUPPLY_MANUFACTURER=Hewlett-Packard
|
||||
POWER_SUPPLY_SERIAL_NUMBER=61597 2011/02/23
|
15
tests/test_battery_basic3
Normal file
15
tests/test_battery_basic3
Normal file
@ -0,0 +1,15 @@
|
||||
POWER_SUPPLY_NAME=BAT0
|
||||
POWER_SUPPLY_STATUS=Discharging
|
||||
POWER_SUPPLY_PRESENT=1
|
||||
POWER_SUPPLY_TECHNOLOGY=Li-ion
|
||||
POWER_SUPPLY_CYCLE_COUNT=0
|
||||
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
|
||||
POWER_SUPPLY_VOLTAGE_NOW=12274000
|
||||
POWER_SUPPLY_POWER_NOW=15624000
|
||||
POWER_SUPPLY_ENERGY_FULL_DESIGN=84240000
|
||||
POWER_SUPPLY_ENERGY_FULL=64360000
|
||||
POWER_SUPPLY_ENERGY_NOW=63560000
|
||||
POWER_SUPPLY_CAPACITY=98
|
||||
POWER_SUPPLY_MODEL_NAME=42T4650
|
||||
POWER_SUPPLY_MANUFACTURER=Panasonic
|
||||
POWER_SUPPLY_SERIAL_NUMBER= 176
|
15
tests/test_battery_basic4
Normal file
15
tests/test_battery_basic4
Normal file
@ -0,0 +1,15 @@
|
||||
POWER_SUPPLY_NAME=BAT0
|
||||
POWER_SUPPLY_STATUS=Discharging
|
||||
POWER_SUPPLY_PRESENT=1
|
||||
POWER_SUPPLY_TECHNOLOGY=Li-ion
|
||||
POWER_SUPPLY_CYCLE_COUNT=0
|
||||
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
|
||||
POWER_SUPPLY_VOLTAGE_NOW=11512000
|
||||
POWER_SUPPLY_CURRENT_NOW=1521000
|
||||
POWER_SUPPLY_CHARGE_FULL_DESIGN=4698000
|
||||
POWER_SUPPLY_CHARGE_FULL=4698000
|
||||
POWER_SUPPLY_CHARGE_NOW=2698000
|
||||
POWER_SUPPLY_CAPACITY=100
|
||||
POWER_SUPPLY_MODEL_NAME=Primary
|
||||
POWER_SUPPLY_MANUFACTURER=Hewlett-Packard
|
||||
POWER_SUPPLY_SERIAL_NUMBER=61597 2011/02/23
|
16
tests/test_battery_basic5
Normal file
16
tests/test_battery_basic5
Normal file
@ -0,0 +1,16 @@
|
||||
POWER_SUPPLY_NAME=BAT0
|
||||
POWER_SUPPLY_STATUS=Discharging
|
||||
POWER_SUPPLY_PRESENT=1
|
||||
POWER_SUPPLY_TECHNOLOGY=Li-ion
|
||||
POWER_SUPPLY_CYCLE_COUNT=0
|
||||
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
|
||||
POWER_SUPPLY_VOLTAGE_NOW=12249000
|
||||
POWER_SUPPLY_CURRENT_NOW=935000
|
||||
POWER_SUPPLY_CHARGE_FULL_DESIGN=4698000
|
||||
POWER_SUPPLY_CHARGE_FULL=4698000
|
||||
POWER_SUPPLY_CHARGE_NOW=4560000
|
||||
POWER_SUPPLY_CAPACITY=97
|
||||
POWER_SUPPLY_MODEL_NAME=Primary
|
||||
POWER_SUPPLY_MANUFACTURER=Hewlett-Packard
|
||||
POWER_SUPPLY_SERIAL_NUMBER=61597 2011/02/23
|
||||
|
16
tests/test_battery_basic6
Normal file
16
tests/test_battery_basic6
Normal file
@ -0,0 +1,16 @@
|
||||
POWER_SUPPLY_NAME=BAT0
|
||||
POWER_SUPPLY_STATUS=Charging
|
||||
POWER_SUPPLY_PRESENT=1
|
||||
POWER_SUPPLY_TECHNOLOGY=Li-ion
|
||||
POWER_SUPPLY_CYCLE_COUNT=0
|
||||
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
|
||||
POWER_SUPPLY_VOLTAGE_NOW=12390000
|
||||
POWER_SUPPLY_POWER_NOW=30764000
|
||||
POWER_SUPPLY_ENERGY_FULL_DESIGN=84240000
|
||||
POWER_SUPPLY_ENERGY_FULL=64360000
|
||||
POWER_SUPPLY_ENERGY_NOW=53810000
|
||||
POWER_SUPPLY_CAPACITY=83
|
||||
POWER_SUPPLY_MODEL_NAME=42T4650
|
||||
POWER_SUPPLY_MANUFACTURER=Panasonic
|
||||
POWER_SUPPLY_SERIAL_NUMBER= 176
|
||||
|
Loading…
Reference in New Issue
Block a user