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.load_url(QUrl('glimpse://version/'), newtab=True) if paste: pastebin_version()
def test_pastebin_version(pbclient, message_mock, monkeypatch, qtbot): """Test version.pastebin_version() sets the url.""" monkeypatch.setattr('glimpsebrowser.utils.version.version', lambda: "dummy") monkeypatch.setattr('glimpsebrowser.utils.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 test_pastebin_version_error(pbclient, caplog, message_mock, monkeypatch): """Test version.pastebin_version() with errors.""" monkeypatch.setattr('glimpsebrowser.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('glimpsebrowser.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 glimpse_pastebin_version(_url): """Handler that pastebins the version string.""" version.pastebin_version() return 'text/plain', b'Paste called.'