コード例 #1
0
ファイル: test_check_updates.py プロジェクト: tusqasi/qtile
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*"
コード例 #2
0
ファイル: test_check_updates.py プロジェクト: tinruufu/qtile
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"
コード例 #3
0
ファイル: test_check_updates.py プロジェクト: yobleck/qtile
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 = Bar([cu2], 24)
    fakebar.window = fake_window
    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
コード例 #4
0
ファイル: test_check_updates.py プロジェクト: tusqasi/qtile
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
コード例 #5
0
ファイル: test_check_updates.py プロジェクト: tinruufu/qtile
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
コード例 #6
0
ファイル: test_check_updates.py プロジェクト: tusqasi/qtile
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"
コード例 #7
0
ファイル: test_check_updates.py プロジェクト: tinruufu/qtile
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"
コード例 #8
0
ファイル: test_check_updates.py プロジェクト: tinruufu/qtile
def test_unknown_distro():
    """ test an unknown distribution """
    cu = CheckUpdates(distro=wrong_distro)
    text = cu.poll()
    assert text == "N/A"