Exemplo n.º 1
0
def test_pastebin_version(pbclient, message_mock, monkeypatch, qtbot):
    """Test version.pastebin_version() sets the url."""
    monkeypatch.setattr('qutebrowser.utils.version.version', lambda: "dummy")
    monkeypatch.setattr('qutebrowser.utils.utils.log_clipboard', True)

    version.pastebin_version(pbclient)
    pbclient.success.emit("test")

    msg = message_mock.getmsg(usertypes.MessageLevel.info)
    assert msg.text == "Version url test yanked to clipboard."
    assert version.pastebin_url == "test"
Exemplo n.º 2
0
def test_pastebin_version(pbclient, message_mock, monkeypatch, qtbot):
    """Test version.pastebin_version() sets the url."""
    monkeypatch.setattr(version, 'version_info', lambda: 'dummy')
    monkeypatch.setattr(utils, 'log_clipboard', True)

    version.pastebin_version(pbclient)
    pbclient.success.emit("https://www.example.com/\n")

    msg = message_mock.getmsg(usertypes.MessageLevel.info)
    expected_text = "Version url https://www.example.com/ yanked to clipboard."
    assert msg.text == expected_text
    assert version.pastebin_url == "https://www.example.com/"
Exemplo n.º 3
0
def version(win_id, paste=False):
    """Show version information.

    Args:
        paste: Paste to pastebin.
    """
    tabbed_browser = objreg.get('tabbed-browser', scope='window',
                                window=win_id)
    tabbed_browser.openurl(QUrl('qute://version'), newtab=True)

    if paste:
        pastebin_version()
Exemplo n.º 4
0
def test_pastebin_version(pbclient, message_mock, monkeypatch, qtbot):
    """Test version.pastebin_version() sets the url."""
    monkeypatch.setattr('qutebrowser.utils.version.version',
                        lambda: "dummy")
    monkeypatch.setattr('qutebrowser.utils.utils.log_clipboard', True)

    version.pastebin_version(pbclient)
    pbclient.success.emit("test")

    msg = message_mock.getmsg(usertypes.MessageLevel.info)
    assert msg.text == "Version url test yanked to clipboard."
    assert version.pastebin_url == "test"
Exemplo n.º 5
0
def version(win_id: int, paste: bool = False) -> None:
    """Show version information.

    Args:
        paste: Paste to pastebin.
    """
    tabbed_browser = objreg.get('tabbed-browser', scope='window',
                                window=win_id)
    tabbed_browser.load_url(QUrl('qute://version/'), newtab=True)

    if paste:
        pastebin_version()
Exemplo n.º 6
0
def test_pastebin_version_error(pbclient, caplog, message_mock, monkeypatch):
    """Test version.pastebin_version() with errors."""
    monkeypatch.setattr(version, 'version_info', lambda: 'dummy')

    version.pastebin_url = None
    with caplog.at_level(logging.ERROR):
        version.pastebin_version(pbclient)
        pbclient._client.error.emit("test")

    assert version.pastebin_url is None

    msg = message_mock.getmsg(usertypes.MessageLevel.error)
    assert msg.text == "Failed to pastebin version info: test"
Exemplo n.º 7
0
def test_pastebin_version_error(pbclient, caplog, message_mock, monkeypatch):
    """Test version.pastebin_version() with errors."""
    monkeypatch.setattr('qutebrowser.utils.version.version',
                        lambda: "dummy")

    version.pastebin_url = None
    with caplog.at_level(logging.ERROR):
        version.pastebin_version(pbclient)
        pbclient._client.error.emit("test")

    assert version.pastebin_url is None

    msg = message_mock.getmsg(usertypes.MessageLevel.error)
    assert msg.text == "Failed to pastebin version info: test"
Exemplo n.º 8
0
def test_pastebin_version_twice(pbclient, monkeypatch):
    """Test whether calling pastebin_version twice sends no data."""
    monkeypatch.setattr(version, 'version_info', lambda: 'dummy')

    version.pastebin_version(pbclient)
    pbclient.success.emit("https://www.example.com/\n")

    pbclient.url = None
    pbclient.data = None
    version.pastebin_url = "https://www.example.org/"

    version.pastebin_version(pbclient)
    assert pbclient.url is None
    assert pbclient.data is None
    assert version.pastebin_url == "https://www.example.org/"
Exemplo n.º 9
0
def test_pastebin_version_twice(pbclient, monkeypatch):
    """Test whether calling pastebin_version twice sends no data."""
    monkeypatch.setattr('qutebrowser.utils.version.version', lambda: "dummy")

    version.pastebin_version(pbclient)
    pbclient.success.emit("test")

    pbclient.url = None
    pbclient.data = None
    version.pastebin_url = "test2"

    version.pastebin_version(pbclient)
    assert pbclient.url is None
    assert pbclient.data is None
    assert version.pastebin_url == "test2"
Exemplo n.º 10
0
def test_pastebin_version_twice(pbclient, monkeypatch):
    """Test whether calling pastebin_version twice sends no data."""
    monkeypatch.setattr('qutebrowser.utils.version.version',
                        lambda: "dummy")

    version.pastebin_version(pbclient)
    pbclient.success.emit("https://www.example.com/\n")

    pbclient.url = None
    pbclient.data = None
    version.pastebin_url = "https://www.example.org/"

    version.pastebin_version(pbclient)
    assert pbclient.url is None
    assert pbclient.data is None
    assert version.pastebin_url == "https://www.example.org/"
Exemplo n.º 11
0
def qute_pastebin_version(_url):
    """Handler that pastebins the version string."""
    version.pastebin_version()
    return 'text/plain', b'Paste called.'
Exemplo n.º 12
0
def qute_pastebin_version(_url):
    """Handler that pastebins the version string."""
    version.pastebin_version()
    return 'text/plain', b'Paste called.'