def test_text_battery_empty(monkeypatch): loaded_bat = BatteryStatus( state=BatteryState.EMPTY, percent=0.5, power=15., time=1729, ) with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery() text = batt.poll() assert text == "Empty" with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery(show_short_text=False) text = batt.poll() assert text == "x 50% 0:28 15.00 W" loaded_bat = BatteryStatus( state=BatteryState.UNKNOWN, percent=0., power=15., time=1729, ) with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery() text = batt.poll() assert text == "Empty"
def test_text_battery_error(monkeypatch): with monkeypatch.context() as m: m.setattr(battery, "load_battery", DummyErrorBattery) batt = Battery() text = batt.poll() assert text == "Error: err"
def test_text_battery_full(monkeypatch): loaded_bat = BatteryStatus( state=BatteryState.FULL, percent=0.5, power=15., time=1729, ) with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery() text = batt.poll() assert text == "Full" with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery(show_short_text=False) text = batt.poll() assert text == "= 50% 0:28 15.00 W"
def test_text_battery_hidden(monkeypatch): loaded_bat = BatteryStatus( state=BatteryState.DISCHARGING, percent=0.5, power=15., time=1729, ) with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery(hide_threshold=0.6) text = batt.poll() assert text != "" with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery(hide_threshold=0.4) text = batt.poll() assert text == ""
def test_text_battery_discharging(monkeypatch): loaded_bat = BatteryStatus( state=BatteryState.DISCHARGING, percent=0.5, power=15., time=1729, ) with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery() text = batt.poll() assert text == "V 50% 0:28 15.00 W"
def test_text_battery_unknown(monkeypatch): loaded_bat = BatteryStatus( state=BatteryState.UNKNOWN, percent=0.5, power=15., time=1729, ) with monkeypatch.context() as m: m.setattr(battery, "load_battery", dummy_load_battery(loaded_bat)) batt = Battery() text = batt.poll() assert text == "? 50% 0:28 15.00 W"