Beispiel #1
0
def test_no_update_available_without_no_update_string(fake_qtile, fake_window):
    """test output with no update (without dedicated string nor color)"""
    cu3 = CheckUpdates(distro=good_distro, custom_command=cmd_0_line)
    fakebar = FakeBar([cu3], window=fake_window)
    cu3._configure(fake_qtile, fakebar)
    text = cu3.poll()
    assert text == ""
Beispiel #2
0
def test_update_available(fake_qtile, fake_window):
    """test output with update (check number of updates and color)"""
    cu2 = CheckUpdates(distro=good_distro,
                       custom_command=cmd_1_line,
                       colour_have_updates="#123456")
    fakebar = FakeBar([cu2], window=fake_window)
    cu2._configure(fake_qtile, fakebar)
    text = cu2.poll()
    assert text == "Updates: 1"
    assert cu2.layout.colour == cu2.colour_have_updates
Beispiel #3
0
def test_no_update_available_without_no_update_string(fake_qtile):
    """ test output with no update (without dedicated string nor color) """
    cu3 = CheckUpdates(distro=good_distro, custom_command=cmd_0_line)
    fakebar = Bar([cu3], 24)
    fakebar.window = FakeWindow()
    fakebar.width = 10
    fakebar.height = 10
    fakebar.draw = no_op
    cu3._configure(fake_qtile, fakebar)
    text = cu3.poll()
    assert text == ""
Beispiel #4
0
def test_update_process_error(fake_qtile, fake_window):
    """test output where update check gives error"""
    cu7 = CheckUpdates(
        distro=good_distro,
        custom_command=cmd_error,
        no_update_string="ERROR",
    )
    fakebar = FakeBar([cu7], window=fake_window)
    cu7._configure(fake_qtile, fakebar)
    text = cu7.poll()
    assert text == "ERROR"
Beispiel #5
0
def test_update_available_with_restart_indicator(monkeypatch, fake_qtile,
                                                 fake_window):
    """test output with no indicator where restart needed"""
    cu5 = CheckUpdates(
        distro=good_distro,
        custom_command=cmd_1_line,
        restart_indicator="*",
    )
    monkeypatch.setattr("os.path.exists", lambda x: True)
    fakebar = FakeBar([cu5], window=fake_window)
    cu5._configure(fake_qtile, fakebar)
    text = cu5.poll()
    assert text == "Updates: 1*"
Beispiel #6
0
def test_update_process_error(fake_qtile):
    """ test output where update check gives error"""
    cu7 = CheckUpdates(distro=good_distro,
                       custom_command=cmd_error,
                       no_update_string="ERROR",
                       )
    fakebar = Bar([cu7], 24)
    fakebar.window = FakeWindow()
    fakebar.width = 10
    fakebar.height = 10
    fakebar.draw = no_op
    cu7._configure(fake_qtile, fakebar)
    text = cu7.poll()
    assert text == "ERROR"
Beispiel #7
0
def test_no_update_available_with_no_update_string_and_color_no_updates(
        fake_qtile, fake_window):
    """test output with no update (with dedicated string and color)"""
    cu4 = CheckUpdates(
        distro=good_distro,
        custom_command=cmd_0_line,
        no_update_string=nus,
        colour_no_updates="#654321",
    )
    fakebar = FakeBar([cu4], window=fake_window)
    cu4._configure(fake_qtile, fakebar)
    text = cu4.poll()
    assert text == nus
    assert cu4.layout.colour == cu4.colour_no_updates
Beispiel #8
0
def test_update_available(fake_qtile):
    """ test output with update (check number of updates and color) """
    cu2 = CheckUpdates(distro=good_distro,
                       custom_command=cmd_1_line,
                       colour_have_updates="#123456"
                       )
    fakebar = Bar([cu2], 24)
    fakebar.window = FakeWindow()
    fakebar.width = 10
    fakebar.height = 10
    fakebar.draw = no_op
    cu2._configure(fake_qtile, fakebar)
    text = cu2.poll()
    assert text == "Updates: 1"
    assert cu2.layout.colour == cu2.colour_have_updates
Beispiel #9
0
def test_no_update_available_with_no_update_string_and_color_no_updates(fake_qtile):
    """ test output with no update (with dedicated string and color) """
    cu4 = CheckUpdates(distro=good_distro,
                       custom_command=cmd_0_line,
                       no_update_string=nus,
                       colour_no_updates="#654321"
                       )
    fakebar = Bar([cu4], 24)
    fakebar.window = FakeWindow()
    fakebar.width = 10
    fakebar.height = 10
    fakebar.draw = no_op
    cu4._configure(fake_qtile, fakebar)
    text = cu4.poll()
    assert text == nus
    assert cu4.layout.colour == cu4.colour_no_updates
Beispiel #10
0
def test_line_truncations(fake_qtile, monkeypatch, fake_window):
    """test update count is reduced"""

    # Mock output to return 5 lines of text
    def mock_process(*args, **kwargs):
        return "1\n2\n3\n4\n5\n"

    # Fedora is set up to remove 1 from line count
    cu8 = CheckUpdates(distro="Fedora")

    monkeypatch.setattr(cu8, "call_process", mock_process)
    fakebar = FakeBar([cu8], window=fake_window)
    cu8._configure(fake_qtile, fakebar)
    text = cu8.poll()

    # Should have 4 updates
    assert text == "Updates: 4"
Beispiel #11
0
def test_line_truncations(fake_qtile, monkeypatch):
    """ test update count is reduced"""

    # Mock output to return 5 lines of text
    def mock_process(*args, **kwargs):
        return "1\n2\n3\n4\n5\n"

    # Fedora is set up to remove 3 from line count
    cu8 = CheckUpdates(distro="Fedora")

    monkeypatch.setattr(cu8, "call_process", mock_process)
    fakebar = Bar([cu8], 24)
    fakebar.window = FakeWindow()
    fakebar.width = 10
    fakebar.height = 10
    fakebar.draw = no_op
    cu8._configure(fake_qtile, fakebar)
    text = cu8.poll()

    # Should have 2 updates
    assert text == "Updates: 2"