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_battery_background(fake_qtile, fake_window, monkeypatch): ok = BatteryStatus( state=BatteryState.DISCHARGING, percent=0.5, power=15.0, time=1729, ) low = BatteryStatus( state=BatteryState.DISCHARGING, percent=0.1, power=15.0, time=1729, ) low_background = "ff0000" background = "000000" with monkeypatch.context() as manager: manager.setattr(battery, "load_battery", dummy_load_battery(ok)) batt = Battery(low_percentage=0.2, low_background=low_background, background=background) fakebar = FakeBar([batt], window=fake_window) batt._configure(fake_qtile, fakebar) assert batt.background == background batt._battery._status = low batt.poll() assert batt.background == low_background batt._battery._status = ok batt.poll() assert batt.background == background
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"
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 == ""