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"
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/"
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()
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()
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"
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"
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/"
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"
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/"
def qute_pastebin_version(_url): """Handler that pastebins the version string.""" version.pastebin_version() return 'text/plain', b'Paste called.'