def test_get_version_error(qtbot): """Test get_version() when error is emitted.""" http_stub = HTTPGetStub(success=False) client = autoupdate.PyPIVersionClient(client=http_stub) with qtbot.assertNotEmitted(client.success): with qtbot.waitSignal(client.error): client.get_version('test')
def test_invalid_json(qtbot, json): """Test on_client_success() with invalid JSON.""" http_stub = HTTPGetStub(json=json) client = autoupdate.PyPIVersionClient(client=http_stub) client.get_version('test') with qtbot.assertNotEmitted(client.success): with qtbot.waitSignal(client.error): client.get_version('test')
def __init__(self, debug, parent=None): """Constructor for CrashDialog. Args: debug: Whether --debug was given. """ super().__init__(parent) # We don't set WA_DeleteOnClose here as on an exception, we'll get # closed anyways, and it only could have unintended side-effects. self._crash_info = [] self._btn_box = None self._btn_report = None self._btn_cancel = None self._lbl = None self._paste_text = None self.setWindowTitle("Whoops!") self.resize(QSize(640, 600)) self._vbox = QVBoxLayout(self) http_client = httpclient.HTTPClient() self._paste_client = pastebin.PastebinClient(http_client, self) self._pypi_client = autoupdate.PyPIVersionClient(self) self._init_text() self._init_contact_input() info = QLabel("What were you doing when this crash/bug happened?") self._vbox.addWidget(info) self._info = QTextEdit(tabChangesFocus=True, acceptRichText=False) self._info.setPlaceholderText("- Opened http://www.example.com/\n" "- Switched tabs\n" "- etc...") self._vbox.addWidget(self._info, 5) self._vbox.addSpacing(15) self._debug_log = QTextEdit(tabChangesFocus=True, acceptRichText=False, lineWrapMode=QTextEdit.NoWrap) self._debug_log.hide() info = QLabel( "<i>You can edit the log below to remove sensitive " "information.</i>", wordWrap=True) info.hide() self._fold = miscwidgets.DetailFold("Show log", self) self._fold.toggled.connect(self._debug_log.setVisible) self._fold.toggled.connect(info.setVisible) if debug: self._fold.toggle() self._vbox.addWidget(self._fold) self._vbox.addWidget(info) self._vbox.addWidget(self._debug_log, 10) self._vbox.addSpacing(15) self._init_checkboxes() self._init_info_text() self._init_buttons()
def test_get_version_success(qtbot): """Test get_version() when success is emitted.""" http_stub = HTTPGetStub(success=True) client = autoupdate.PyPIVersionClient(client=http_stub) with qtbot.assertNotEmitted(client.error): with qtbot.waitSignal(client.success): client.get_version('test') assert http_stub.url == QUrl(client.API_URL.format('test'))
def test_constructor(qapp): client = autoupdate.PyPIVersionClient() assert isinstance(client._client, httpclient.HTTPClient)