Exemplo n.º 1
0
def test_battery_widget_read_battery_infos(one_battery_dir):
    BAT_NAME = "BAT0"
    bw = BatteryWidget()
    read_infos = bw.read_battery_infos(BAT_NAME)
    for key, expected_value in BATTERIES[BAT_NAME].items():
        assert read_infos[key] == expected_value

    expected_remains = (
        60 * BATTERIES[BAT_NAME]["energy_now"]/BATTERIES[BAT_NAME]["power_now"]
    )
    assert int(expected_remains) == read_infos["remains"]
Exemplo n.º 2
0
def test_battery_widget_organize_result_multiple_batteries(
        multiple_batteries_dir):
    bw = BatteryWidget(padding=2)
    infos = {
        bat_name: bw.read_battery_infos(bat_name)
        for bat_name in BATTERIES.keys()
    }
    expected = bw.organize_result(**infos)
    assert expected == (
        "BAT0: {}% - 2:18".format(infos["BAT0"]["capacity"]) +
        "  "
        "BAT1: {}% - 1:00".format(infos["BAT1"]["capacity"])
    )
Exemplo n.º 3
0
def test_battery_widget_update(one_battery_dir):
    BAT_NAME = "BAT0"
    bw = BatteryWidget()
    infos = bw.read_battery_infos(BAT_NAME)
    organized_result = bw.organize_result(**{BAT_NAME: infos})

    p = Panel(instance_per_screen=False, keep_unplugged_screens=True)
    s = Screen("HDMI-0")
    s.add_widget("l", bw)
    p.add_screen(s)
    bw.update()

    assert bw._content == organized_result
Exemplo n.º 4
0
def test_battery_widget_organize_result_one_battery(one_battery_dir):
    BAT_NAME = "BAT0"
    bw = BatteryWidget()
    infos = bw.read_battery_infos(BAT_NAME)
    expected = bw.organize_result(**{BAT_NAME: infos})
    assert expected == "{}% - 2:18".format(infos["capacity"])