def exec_test(): yield from asyncio.sleep(2) urls = [mock.get_request(i).url for i in range(0, 7)] self.assertTrue( "/wot/certifiers-of/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ" in urls, msg="Not found in {0}".format(urls), ) self.assertTrue( "/wot/lookup/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ" in urls, msg="Not found in {0}".format(urls) ) self.assertTrue( "/wot/certified-by/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ" in urls, msg="Not found in {0}".format(urls), ) # requests 1 to 3 are for getting certifiers-of and certified-by # on john, + a lookup QTest.keyClicks(identities_tab.edit_textsearch, "doe") QTest.mouseClick(identities_tab.button_search, Qt.LeftButton) yield from asyncio.sleep(2) req = 7 self.assertEqual(mock.get_request(req).method, "GET") self.assertEqual( mock.get_request(req).url, "/blockchain/memberships/FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn" ) req += 1 self.assertEqual(identities_tab.table_identities.model().rowCount(), 1) yield from asyncio.sleep(2) self.lp.call_soon(close_dialog)
async def exec_test(): srv, port, url = await self.mock_nice_blockchain.create_server() self.addCleanup(srv.close) identities_tab.change_account(self.account, self.password_asker) identities_tab.change_community(self.community) await asyncio.sleep(1) urls = [self.mock_nice_blockchain.get_request(i).url for i in range(0, 7)] self.assertTrue('/wot/certifiers-of/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ' in urls, msg="Not found in {0}".format(urls)) self.assertTrue('/wot/lookup/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ' in urls, msg="Not found in {0}".format(urls)) self.assertTrue('/wot/certified-by/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ' in urls, msg="Not found in {0}".format(urls)) # requests 1 to 3 are for getting certifiers-of and certified-by # on john, + a lookup QTest.keyClicks(identities_tab.ui.edit_textsearch, "doe") QTest.mouseClick(identities_tab.ui.button_search, Qt.LeftButton) await asyncio.sleep(2) req = 8 self.assertEqual(self.mock_nice_blockchain.get_request(req).method, 'GET') self.assertEqual(self.mock_nice_blockchain.get_request(req).url, '/blockchain/memberships/FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn') req += 1 self.assertEqual(identities_tab.ui.table_identities.model().rowCount(), 1) await asyncio.sleep(2) self.lp.call_soon(close_dialog)
async def exec_test(): srv, port, url = await mock.create_server() self.addCleanup(srv.close) await asyncio.sleep(1) QTest.mouseClick(process_community.lineedit_server, Qt.LeftButton) QTest.keyClicks(process_community.lineedit_server, "127.0.0.1") QTest.mouseDClick(process_community.spinbox_port, Qt.LeftButton) process_community.spinbox_port.setValue(port) self.assertEqual(process_community.stacked_pages.currentWidget(), process_community.page_node, msg="Current widget : {0}".format(process_community.stacked_pages.currentWidget().objectName())) self.assertEqual(process_community.lineedit_server.text(), "127.0.0.1") self.assertEqual(process_community.spinbox_port.value(), port) QTest.mouseClick(process_community.button_connect, Qt.LeftButton) await asyncio.sleep(2) self.assertEqual(mock.get_request(0).method, 'GET') self.assertEqual(mock.get_request(0).url, '/network/peering') self.assertEqual(mock.get_request(1).method, 'GET') self.assertEqual(mock.get_request(1).url, '/wot/certifiers-of/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ') for i in range(2, 5): self.assertEqual(mock.get_request(i).method, 'GET') self.assertEqual(mock.get_request(i).url, '/wot/lookup/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ') self.assertEqual(process_community.stacked_pages.currentWidget(), process_community.page_node, msg="Current widget : {0}".format(process_community.stacked_pages.currentWidget().objectName())) self.assertEqual(process_community.label_error.text(), "Could not find your identity on the network.") process_community.close()
def test_click_selects_first(self): self.qpart.text = 'aaaa\nbbbb\ncccX\ndddd\ncccY' QTest.keyClicks(self.qpart, "ccc") QTest.mouseClick(self.qpart, Qt.LeftButton) QTest.keyClick(self.qpart, Qt.Key_Enter) self.assertEqual(self.qpart.text, 'cccY\naaaa\nbbbb\ncccX\ndddd\ncccY')
def write_to_input_line(self, text): '''emulate writing to inputline and press return''' pv = self.pile_viewer il = pv.inputline QTest.keyPress(pv, ':') QTest.keyClicks(il, text) QTest.keyPress(il, Qt.Key_Return)
def runInDialog(dialog): QTest.keyClicks(QApplication.instance().focusWidget(), '/dev/null') def runInNextDialog(nextDialog): self.assertTrue(nextDialog.windowTitle(), 'Not this time') self.keyClick(Qt.Key_Return) self.openDialog(lambda: self.keyClick(Qt.Key_Return), runInNextDialog)
def test_threshold(self): self._assertNotVisible() self.qpart.completionThreshold = 8 QTest.keyClicks(self.qpart, "complet") self._assertNotVisible() QTest.keyClicks(self.qpart, "a") self._assertVisible()
def testChangeArgs(self): main_win, w = self.createWidget() QTest.keyClicks(w.args_line, "-foo -bar") QTest.keyClick(w.args_line, Qt.Key_Enter) self.assertEqual(w.args_line.text(), "-foo -bar") cmd, args = w.buildCommand("input.i") self.assertIn("-foo", args) self.assertIn("-bar", args)
def test_set_Npcp1(self): """Check that the Widget allow to update Npcp1""" # Clear the field before writing the new value self.widget_1.si_Npcpp.clear() value = int(uniform(5, 100)) QTest.keyClicks(self.widget_1.si_Npcpp, str(value)) self.widget_1.si_Npcpp.editingFinished.emit() # To trigger the slot self.assertEqual(self.test_obj.stator.winding.Npcpp, value)
def test_dwell_dialog(dwell_time): #Open the dialog for inputing the dwell time. assert win_obj.diag.dialog_dwell_win.isVisible() == True assert win_obj.diag.input_text.isVisible() == True assert str( win_obj.diag.label.text()) == 'Enter the pixel dwell time (us):' QTest.keyClicks(win_obj.diag.input_text, str(dwell_time)) assert win_obj.diag.input_text.text() == str(dwell_time) QTest.mouseClick(win_obj.diag.ok, QtCore.Qt.LeftButton)
def test_set_RRint(self): """Check that the Widget allow to update RRint""" # Clear the field before writing the new value self.widget.lf_RRint.clear() value = round(uniform(0, 1), 4) QTest.keyClicks(self.widget.lf_RRint, str(value)) self.widget.lf_RRint.editingFinished.emit() # To trigger the slot self.assertEqual(self.test_obj.rotor.Rint, value)
def test_integration(self): solver = gui.PolynomSolver() QTest.qWaitForWindowExposed(solver) QTest.keyClicks(solver._inputLine, '-2 20 -50', delay=100) # Wait 100ms QTest.mouseClick(solver._processButton, Qt.Qt.LeftButton, pos=Qt.QPoint(1, 1)) self.assertEqual(solver._resultWidget.text(), "5.000")
def click(self, keys): if isinstance(keys, str): for key in keys: if key.isupper() or key in '$%^<>': QTest.keyClick(self.qpart, key, Qt.ShiftModifier) else: QTest.keyClicks(self.qpart, key) else: QTest.keyClick(self.qpart, keys)
def test_set_W0(self): """Check that the Widget allow to update W0""" # Clear the field before writing the new value self.widget.lf_W0.clear() QTest.keyClicks(self.widget.lf_W0, "0.31") self.widget.lf_W0.editingFinished.emit() # To trigger the slot self.assertEqual(self.widget.hole.W0, 0.31) self.assertEqual(self.test_obj.hole[0].W0, 0.31)
def test_set_name(self): """Check that the Widget allow to update name""" # Clear the field before writing the new value self.widget.le_name.clear() value = round(uniform(0, 1), 4) QTest.keyClicks(self.widget.le_name, "test_" + str(value)) self.widget.le_name.editingFinished.emit() # To trigger the slot self.assertEqual(self.test_obj.name, "test_" + str(value))
def test_set_H4(self): """Check that the Widget allow to update H4""" self.widget.lf_H4.clear() value = round(uniform(0, 1), 4) QTest.keyClicks(self.widget.lf_H4, str(value)) self.widget.lf_H4.editingFinished.emit() # To trigger the slot self.assertEqual(self.widget.hole.H4, value) self.assertEqual(self.test_obj.hole[0].H4, value)
def runInDialog(dialog): QTest.keyClicks(QApplication.instance().focusWidget(), NEW_PATH) def nextRunInDialog(nextDialog): self.assertEqual(nextDialog.windowTitle(), 'Failed to rename file') self.keyClick(Qt.Key_Return) self.openDialog(lambda: self.keyClick(Qt.Key_Return), nextRunInDialog)
def test_ok_settings(form): form.config.line_edit_password.clear() QTest.keyClicks(form.config.line_edit_password, "bar") ok_button = form.config.button_box.button(form.config.button_box.Ok) QTest.mouseClick(ok_button, Qt.LeftButton) parser = configparser.ConfigParser() parser.read(form.config.path) assert (form.config.line_edit_password.text() == parser['resticqt'] ['password'])
def test_execution(self): print("TEST EXECUTION") QTest.mouseClick(self.main_window.refresh_button, Qt.LeftButton) QTest.qWait(1000) QTest.keyClicks(self.main_window.xlabel_lineedit, "test X label") QTest.mouseClick(self.main_window.execute_button, Qt.LeftButton) QTest.qWait(220000) self.assertEqual(len(self.main_window.controller_model.output_manager.df.index), 10) self.assertEqual(self.main_window.controller_model.output_manager.params["xlabel"], "test X label")
def test_set_G(self): """Check that the Widget allow to update G""" self.widget.lf_G.clear() # Clear the field before writing value = round(uniform(0, 1), 4) QTest.keyClicks(self.widget.lf_G, str(value)) self.widget.lf_G.editingFinished.emit() # To trigger the slot self.assertEqual(self.widget.mat.struct.Gxy, value) self.assertEqual(self.widget.mat.struct.Gyz, value) self.assertEqual(self.widget.mat.struct.Gxz, value)
def test_repeat(self): class TestSettings: orderedListMode = 'repeat' useFakeVim = False editor = ReTextEdit(self, settings=TestSettings()) editor.tab = self.DummyReTextTab() QTest.keyClicks(editor, '1. Hello') QTest.keyClick(editor, Qt.Key.Key_Return) QTest.keyClicks(editor, 'World') self.assertEqual(editor.document().toPlainText(), '1. Hello\n1. World')
def test_line_sampling_dialog(sample_rate): #Open the dialog for the line sampling (Hz): assert win_obj.diag.line_sampling_win.isVisible() == True assert win_obj.diag.input_text.isVisible() == True assert str( win_obj.diag.label.text()) == 'Enter the line sampling (Hz):' QTest.keyClicks(win_obj.diag.input_text, str(sample_rate)) assert win_obj.diag.input_text.text() == str(sample_rate) QTest.mouseClick(win_obj.diag.ok, QtCore.Qt.LeftButton) assert win_obj.diag.line_sampling_win.isVisible() == False
def exec_test(): yield from asyncio.sleep(1) QTest.mouseClick(certification_dialog.radio_pubkey, Qt.LeftButton) QTest.keyClicks(certification_dialog.edit_pubkey, "FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn") QTest.mouseClick(certification_dialog.button_box.button(QDialogButtonBox.Ok), Qt.LeftButton) yield from asyncio.sleep(1) topWidgets = QApplication.topLevelWidgets() for w in topWidgets: if type(w) is QMessageBox: QTest.keyClick(w, Qt.Key_Enter)
def edit_line_edit_text(line_edit, text): """Simulates clear and edit of a line edit :param line_edit: widget edit :type line_edit: QtWidgets.QLineEdit :param text: widget to scroll on :type text: str """ QTest.keyClick(line_edit, Qt.Key_A, Qt.ControlModifier) QTest.keyClicks(line_edit, text)
def testMarkerGeographicOnGeodesic(self): CANVAS.setDestinationCrs(QgsCoordinateReferenceSystem("EPSG:32632")) QTest.qWait(100) CANVAS.zoomToFeatureExtent( QgsRectangle(150000, 4800000, 850000, 5500000)) QTest.qWait(100) QTest.mouseClick(self.dw.inputAsDec, Qt.LeftButton) marker = self.coordinator.marker mapToPixel = CANVAS.getCoordinateTransform() # set point to 8°E but 0°N QTest.keyClicks(self.dw.inLeftDec, "8") QTest.qWait(1000) # check non visible self.assertFalse(CANVAS.sceneRect().contains(marker.scenePos())) self.assertTrue(self.dw.messageIcon.isVisible()) # add 45°N QTest.keyClicks(self.dw.inRightDec, "45") QTest.qWait(200) # now point should be visible self.assertTrue(CANVAS.sceneRect().contains(marker.scenePos())) self.assertFalse(self.dw.messageIcon.isVisible()) # check the actual position on the map coords = mapToPixel.toMapCoordinates(marker.pos().x(), marker.pos().y()) expectedPixelPos = mapToPixel.transform(QgsPointXY(421184, 4983436)) self.assertAlmostEqual(expectedPixelPos.x(), marker.pos().x(), 0) self.assertAlmostEqual(expectedPixelPos.y(), marker.pos().y(), 0) # remove latitude coordinates QTest.mouseDClick(self.dw.inRightDec, Qt.LeftButton) QTest.keyClick(self.dw.inRightDec, Qt.Key_Delete) QTest.qWait(200) self.assertFalse(CANVAS.sceneRect().contains(marker.scenePos())) self.assertTrue(self.dw.messageIcon.isVisible()) # set 80°N QTest.keyClicks(self.dw.inRightDec, "80") QTest.qWait(200) # check non visible self.assertFalse(CANVAS.sceneRect().contains(marker.scenePos())) self.assertTrue(self.dw.messageIcon.isVisible()) # clear input and set coordinates on western hemisphere but with correct Latitude QTest.mouseClick(self.dw.clearInput, Qt.LeftButton) QTest.mouseClick(self.dw.leftDirButton, Qt.LeftButton) QTest.keyClicks(self.dw.inLeftDec, "8") QTest.keyClicks(self.dw.inRightDec, "45") # check non visible self.assertFalse(CANVAS.sceneRect().contains(marker.scenePos())) self.assertTrue(self.dw.messageIcon.isVisible())
def test_down_selects_first(self): self.qpart.text = 'aaaa\nbbbb\ncccX\ndddd\ncccY' while self.app.hasPendingEvents(): self.app.processEvents() QTest.keyClicks(self.qpart, "ccc") QTest.keyClick(self.qpart, Qt.Key_Down) QTest.keyClick(self.qpart, Qt.Key_Enter) QTest.keyClick(self.qpart, Qt.Key_Enter) self.assertEqual(self.qpart.text, 'cccX\naaaa\nbbbb\ncccX\ndddd\ncccY')
def update_email(self): if 'mail.ru' not in self.user[user_keys.user_username]: return yield self.goto_url('https://twitter.com/settings/account') try: new_email = ''.join([ c for c in self.user[user_keys.user_username].lower() if not c.isdigit() ]) print 'new_email:', new_email new_email = new_email.split('@')[0] + '@socialcss.com' print 'new_email:', new_email md = {'filter': {'derived_to': new_email}} d = client.mail_listener(mail_domain='mail.scewpt.com', message_filter_dic=md) d.addCallback(client.hearing_back, new_email) d.addErrback(self.error_view) self.page().runJavaScript(js_email_focus) yield task.deferLater(reactor, 1, defer.succeed, True) QTest.keyClicks(qt5.app.opengl, new_email, Qt.NoModifier, 20) yield task.deferLater(reactor, 2, defer.succeed, True) self.page().runJavaScript(js_email) yield task.deferLater(reactor, 2, defer.succeed, True) QTest.keyClicks(qt5.app.opengl, self.user[user_keys.user_password], Qt.NoModifier, 20) yield task.deferLater(reactor, 2, defer.succeed, True) self.page().runJavaScript(js_save) result = yield d print 'result:', result['file_dest'] email_html = etree.HTML( emails.get_html_from_msg(result['file_dest'])) print 'email_html:', email_html for el in email_html.cssselect('a[href]'): if etree.tostring( el, method="text", encoding='UTF-8').lower().strip() == 'confirm now': yield self.goto_url(el.attrib['href']) new_user = {} new_user.update(self.user._data) self.user.delete() new_user[user_keys.user_username] = new_email if self.available: UserAvailable().put_item(data=new_user) else: User().put_item(data=new_user) except Exception as e: print 'update email exception:', e
def test_7(self): """Smartly indent python""" self.qpart.detectSyntax(language='Python') QTest.keyClicks(self.qpart, "def main():") QTest.keyClick(self.qpart, Qt.Key_Enter) self.assertEqual(self.qpart.cursorPosition, (1, 4)) QTest.keyClicks(self.qpart, "return 7") QTest.keyClick(self.qpart, Qt.Key_Enter) self.assertEqual(self.qpart.cursorPosition, (2, 0))
def test_valid_password(self): """ This test tests password validation. """ # Tom wants to create new database self.dbs.panel.addButton.click() # First he types name QTest.keyClicks(self.name, "somedb") # Then he types password to first password input QTest.keyClicks(self.pass_input, "password123") # The error message appears saying that both passwords aren't equal, # because first input is filled and the second is not self.assertTrue( self.passEqError.visibility, "The error message does not appear when one of password" "fields is filled but another is not!", ) # Tom then fills second password field with the same password QTest.keyClicks(self.pass_repeat_input, "password123") # The error disappears self.assertFalse( self.passEqError.visibility, "The error message does not disappear when all " "password fields are filled!", ) # He then erase both password fields self.pass_input.setText("") self.pass_repeat_input.setText("") # Another error appears saying that he needs to fill password fields self.assertTrue( self.passFilledError.visibility, "The error message does not appear when password fields" "are erased!", ) # Tom fills them again QTest.keyClicks(self.pass_input, "password123") QTest.keyClicks(self.pass_repeat_input, "password123") # End there is no errors self.assertFalse( self.passEqError.visibility, "Password error appears when both passwords are equal!", ) self.assertFalse( self.passFilledError.visibility, "Password filled error appears when both passwords are filled!", )
def test_reset_by_edit(self): self.qpart.show() self.qpart.text = 'abcd\nef\nghkl\nmnop' QTest.keyClick(self.qpart, Qt.Key_Right) QTest.keyClick(self.qpart, Qt.Key_Right, Qt.AltModifier | Qt.ShiftModifier) QTest.keyClick(self.qpart, Qt.Key_Right, Qt.AltModifier | Qt.ShiftModifier) QTest.keyClick(self.qpart, Qt.Key_Down, Qt.AltModifier | Qt.ShiftModifier) QTest.keyClick(self.qpart, Qt.Key_Down, Qt.AltModifier | Qt.ShiftModifier) QTest.keyClicks(self.qpart, 'x') QTest.keyClick(self.qpart, Qt.Key_Backspace) self.assertEqual(self.qpart.text, 'abcd\nef\nghkl\nmnop')
def test_tab_completes(self): self.qpart.text = 'aaaaa\naaaaaXXXXX\n' base._processPendingEvents(self.app) self.qpart.cursorPosition = (2, 0) QTest.keyClicks(self.qpart, "aaa") QTest.keyClick(self.qpart, Qt.Key_Tab) self.assertEqual(self.qpart.text, 'aaaaa\naaaaaXXXXX\naaaaa') QTest.keyClick(self.qpart, Qt.Key_Tab) self.assertEqual(self.qpart.text, 'aaaaa\naaaaaXXXXX\naaaaaXXXXX')
def test_set_Wfra(self): """Check that the Widget allow to update Wfra""" # Clear the field before writing the new value self.widget.lf_Wfra.clear() value = round(uniform(0, 1), 4) QTest.keyClicks(self.widget.lf_Wfra, str(value)) self.widget.lf_Wfra.editingFinished.emit() # To trigger the slot self.assertEqual(self.test_obj.frame.Rint, self.test_obj.stator.Rext) self.assertEqual(self.test_obj.frame.Rext, self.test_obj.stator.Rext + value)
def enter_credentials(): yield task.deferLater(reactor, 1, defer.succeed, True) print 'got here:', qt5.app.opengl # QTest.keyClick(qt5.app.opengl, Qt.Key_Tab, Qt.NoModifier, 10) QTest.keyClicks(qt5.app.opengl, '*****@*****.**', Qt.NoModifier, 10) QTest.keyClick(qt5.app.opengl, Qt.Key_Tab, Qt.NoModifier, 100) QTest.keyClicks(qt5.app.opengl, 'Tererdfcv1!I', Qt.NoModifier, 10) QTest.keyClick(qt5.app.opengl, Qt.Key_Tab, Qt.NoModifier, 100) QTest.keyClick(qt5.app.opengl, Qt.Key_Tab, Qt.NoModifier, 100) QTest.keyClick(qt5.app.opengl, Qt.Key_Enter, Qt.NoModifier, 100)
def test_text1(self): self.set_form_to_zero() self.form.ui.testText1.clear() QTest.keyClicks(self.form.ui.testText1, 'abcdef') self.assertEqual(self.form.ui.testText1.text(), 'abcde') self.form.ui.testText1.clear() QTest.keyClicks(self.form.ui.testText1, 'abc') QTest.mouseClick(self.form.ui.pushButton, Qt.LeftButton) self.assertEqual(self.form.text1, 'abc')
def test_set_qs(self): """Check that the Widget allow to update qs""" self.widget.si_qs.clear() # Clear the field before writing value = int(uniform(3, 100)) QTest.keyClicks(self.widget.si_qs, str(value)) self.widget.si_qs.editingFinished.emit() # To trigger the slot self.assertEqual(self.test_obj.stator.winding.qs, value) self.assertEqual( self.widget.out_shape.text(), "Winding Matrix shape: [2, 1, 36, " + str(value) + "]", )
def exec_test(): yield from asyncio.sleep(1) self.account.wallets[0].caches[self.community.currency].available_sources = yield from self.wallet.sources(self.community) QTest.mouseClick(transfer_dialog.radio_pubkey, Qt.LeftButton) QTest.keyClicks(transfer_dialog.edit_pubkey, "FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn") transfer_dialog.spinbox_amount.setValue(10) QTest.mouseClick(transfer_dialog.button_box.button(QDialogButtonBox.Ok), Qt.LeftButton) yield from asyncio.sleep(1) topWidgets = QApplication.topLevelWidgets() for w in topWidgets: if type(w) is QMessageBox: QTest.keyClick(w, Qt.Key_Enter)
def test_down_selects_second(self): self.qpart.text = 'aaaa\nbbbb\ncccX\ndddd\ncccY' base._processPendingEvents(self.app) QTest.keyClicks(self.qpart, "ccc") QTest.keyClick(self.qpart, Qt.Key_Down) QTest.keyClick(self.qpart, Qt.Key_Down) QTest.keyClick(self.qpart, Qt.Key_Enter) QTest.keyClick(self.qpart, Qt.Key_Enter) self.assertEqual(self.qpart.text, 'cccY\naaaa\nbbbb\ncccX\ndddd\ncccY')
def keyClicks(self, text, modifiers=Qt.NoModifier, widget=None): """Alias for ``QTest.keyClicks``. If widget is none - focused widget will be keyclicked""" if widget is None: widget = QApplication.instance().focusWidget() if widget is None: widget = core.mainWindow() assert widget is not None QTest.keyClicks(widget, text, modifiers)
def click(key): clockBefore = time.clock() if isinstance(key, str): QTest.keyClicks(q, key) else: QTest.keyClick(q, key) while app.hasPendingEvents(): app.processEvents() clockAfter = time.clock() ms = int((clockAfter - clockBefore) * 1000) clickTimes[ms] = clickTimes.get(ms, 0) + 1
def test_completion_enabled(self): self._assertNotVisible() self.qpart.completionEnabled = True QTest.keyClicks(self.qpart, "comple") self._assertVisible() for i in range(len('comple')): QTest.keyClick(self.qpart, Qt.Key_Backspace) self._assertNotVisible() self.qpart.completionEnabled = False QTest.keyClicks(self.qpart, "comple") self._assertNotVisible()
async def exec_test(): certification_dialog.model.connection.password = bob.password QTest.keyClicks(certification_dialog.search_user.view.combobox_search.lineEdit(), "nothing") await asyncio.sleep(1) certification_dialog.search_user.view.search("") await asyncio.sleep(1) assert certification_dialog.user_information.model.identity is None assert not certification_dialog.view.button_process.isEnabled() certification_dialog.search_user.view.combobox_search.lineEdit().clear() QTest.keyClicks(certification_dialog.search_user.view.combobox_search.lineEdit(), alice.key.pubkey) await asyncio.sleep(0.5) certification_dialog.search_user.view.search("") await asyncio.sleep(1) certification_dialog.search_user.view.node_selected.emit(0) await asyncio.sleep(0.5) assert certification_dialog.user_information.model.identity.uid == "alice" await asyncio.sleep(0.5) assert certification_dialog.view.button_process.isEnabled() QTest.mouseClick(certification_dialog.view.button_process, Qt.LeftButton) await asyncio.sleep(0.5) QTest.mouseClick(certification_dialog.view.button_accept, Qt.LeftButton) await asyncio.sleep(0.5) QTest.keyClicks(certification_dialog.password_input.view.edit_secret_key, bob.salt) QTest.keyClicks(certification_dialog.password_input.view.edit_password, bob.password) assert certification_dialog.view.button_box.button(QDialogButtonBox.Ok).isEnabled() QTest.mouseClick(certification_dialog.view.button_box.button(QDialogButtonBox.Ok), Qt.LeftButton) await asyncio.sleep(0.5) click_on_top_message_box_button(QMessageBox.Yes) await asyncio.sleep(0.5) assert isinstance(fake_server_with_blockchain.forge.pool[0], Certification)
async def exec_test(): srv, port, url = await self.mock_nice_blockchain.create_server() self.addCleanup(srv.close) identities_tab.change_account(self.account, self.password_asker) identities_tab.change_community(self.community) await asyncio.sleep(1) QTest.keyClicks(identities_tab.ui.edit_textsearch, "doe") QTest.mouseClick(identities_tab.ui.button_search, Qt.LeftButton) await asyncio.sleep(2) self.assertEqual(identities_tab.ui.table_identities.model().rowCount(), 1) await asyncio.sleep(2) self.lp.call_soon(close_dialog)
def test_manual(self): self._window.show() self.qpart.text = 'aaaaa\naaaaaXXXXX\n' base._processPendingEvents(self.app) self.qpart.cursorPosition = (2, 0) QTest.keyClicks(self.qpart, "a") QTest.keyPress(self.qpart, Qt.Key_Space, Qt.ControlModifier, 100) QTest.keyClicks(self.qpart, "a") QTest.keyClick(self.qpart, Qt.Key_Tab) self.assertEqual(self.qpart.text, 'aaaaa\naaaaaXXXXX\naaaaa')
def test_limeJuiceLineEdit(self): '''测试用例 test_limeJuiceLineEdit ''' print('*** testCase test_limeJuiceLineEdit begin ***') self.form.setWindowTitle('开始测试用例 test_limeJuiceLineEdit ') '''测试修改juice line edit部件的最大最小值 测试它的最小和最大值作为读者的练习。 ''' self.setFormToZero() # 清除lineEdit小部件值,然后在lineEdit小部件中键入“3.5” self.form.ui.limeJuiceLineEdit.clear() QTest.keyClicks(self.form.ui.limeJuiceLineEdit, "3.5") # 用鼠标左键按OK按钮 okWidget = self.form.ui.okBtn QTest.mouseClick(okWidget, Qt.LeftButton) self.assertEqual(self.form.getJiggers() , 3.5) print('*** testCase test_limeJuiceLineEdit end ***')
async def exec_test(): QTest.keyClicks(process_account.edit_account_name, "test") self.assertEqual(process_account.stacked_pages.currentWidget(), process_account.page_init, msg="Current widget : {0}".format(process_account.stacked_pages.currentWidget().objectName())) QTest.mouseClick(process_account.button_next, Qt.LeftButton) await asyncio.sleep(1) self.assertEqual(process_account.stacked_pages.currentWidget(), process_account.page_gpg, msg="Current widget : {0}".format(process_account.stacked_pages.currentWidget().objectName())) QTest.keyClicks(process_account.edit_salt, "testsakia") self.assertFalse(process_account.button_next.isEnabled()) self.assertFalse(process_account.button_generate.isEnabled()) QTest.keyClicks(process_account.edit_password, "testsakia") self.assertFalse(process_account.button_next.isEnabled()) self.assertFalse(process_account.button_generate.isEnabled()) QTest.keyClicks(process_account.edit_password_repeat, "wrongpassword") self.assertFalse(process_account.button_next.isEnabled()) self.assertFalse(process_account.button_generate.isEnabled()) process_account.edit_password_repeat.setText("") QTest.keyClicks(process_account.edit_password_repeat, "testsakia") self.assertTrue(process_account.button_next.isEnabled()) self.assertTrue(process_account.button_generate.isEnabled()) QTest.mouseClick(process_account.button_generate, Qt.LeftButton) self.assertEqual(process_account.label_info.text(), "B7J4sopyfqzi3uh4Gzsdnp1XHc87NaxY7rqW2exgivCa") QTest.mouseClick(process_account.button_next, Qt.LeftButton) await asyncio.sleep(1) self.assertEqual(process_account.stacked_pages.currentWidget(), process_account.page__communities, msg="Current widget : {0}".format(process_account.stacked_pages.currentWidget().objectName())) process_account.password_asker.password = "******" process_account.password_asker.remember = True await asyncio.sleep(1) QTest.mouseClick(process_account.button_next, Qt.LeftButton) self.assertEqual(len(self.application.accounts), 1) await asyncio.sleep(0.1) self.assertEqual(self.application.current_account.name, "test") self.assertEqual(self.application.preferences['account'], "test") self.assertEqual(len(self.application.current_account.wallets), 1) await asyncio.sleep(1)
async def exec_test(): srv, port, url = await mock.create_server() self.addCleanup(srv.close) await asyncio.sleep(1) QTest.mouseClick(process_community.lineedit_server, Qt.LeftButton) QTest.keyClicks(process_community.lineedit_server, "127.0.0.1") QTest.mouseDClick(process_community.spinbox_port, Qt.LeftButton) process_community.spinbox_port.setValue(port) self.assertEqual(process_community.stacked_pages.currentWidget(), process_community.page_node, msg="Current widget : {0}".format(process_community.stacked_pages.currentWidget().objectName())) self.assertEqual(process_community.lineedit_server.text(), "127.0.0.1") self.assertEqual(process_community.spinbox_port.value(), port) QTest.mouseClick(process_community.button_register, Qt.LeftButton) await asyncio.sleep(1) self.assertEqual(mock.get_request(0).method, 'GET') self.assertEqual(mock.get_request(0).url, '/network/peering') self.assertEqual(process_community._step_init.node.endpoint.port, port) self.assertEqual(mock.get_request(1).method, 'GET') self.assertEqual(mock.get_request(1).url, '/wot/certifiers-of/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ') for i in range(2, 5): self.assertEqual(mock.get_request(i).method, 'GET') self.assertEqual(mock.get_request(i).url, '/wot/lookup/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ') await asyncio.sleep(5) self.assertEqual(mock.get_request(5).method, 'GET') self.assertEqual(mock.get_request(5).url, '/wot/lookup/john') for i in range(6, 8): self.assertEqual(mock.get_request(i).method, 'GET') self.assertEqual(mock.get_request(i).url, '/wot/lookup/john') self.assertEqual(mock.get_request(8).url[:8], '/wot/add') self.assertEqual(mock.get_request(8).method, 'POST') self.assertEqual(process_community.label_error.text(), "Broadcasting identity...") await asyncio.sleep(1) self.assertEqual(process_community.stacked_pages.currentWidget(), process_community.page_add_nodes, msg="Current widget : {0}".format(process_community.stacked_pages.currentWidget().objectName())) QTest.mouseClick(process_community.button_next, Qt.LeftButton)
def test_too_long_list(self): self._window.show() self.qpart.text = '\n'.join(['asdf' + str(i) \ for i in range(100)]) + '\n' base._processPendingEvents(self.app) self.qpart.cursorPosition = (100, 0) QTest.keyClicks(self.qpart, "asdf") self.assertIsNotNone(self.qpart._completer._widget) self.qpart.text = '\n'.join(['asdf' + str(i) \ for i in range(1000)]) + '\n' base._processPendingEvents(self.app) self.qpart.cursorPosition = (1000, 0) QTest.keyClicks(self.qpart, "asdf") self.assertIsNone(self.qpart._completer._widget) QTest.keyPress(self.qpart, Qt.Key_Space, Qt.ControlModifier, 100) self.assertIsNotNone(self.qpart._completer._widget)
async def exec_test(): srv, port, url = await mock.create_server() self.addCleanup(srv.close) await asyncio.sleep(1) QTest.mouseClick(process_community.lineedit_server, Qt.LeftButton) QTest.keyClicks(process_community.lineedit_server, "127.0.0.1") QTest.mouseDClick(process_community.spinbox_port, Qt.LeftButton) process_community.spinbox_port.setValue(port) self.assertEqual(process_community.stacked_pages.currentWidget(), process_community.page_node, msg="Current widget : {0}".format(process_community.stacked_pages.currentWidget().objectName())) self.assertEqual(process_community.lineedit_server.text(), "127.0.0.1") self.assertEqual(process_community.spinbox_port.value(), port) QTest.mouseClick(process_community.button_connect, Qt.LeftButton) await asyncio.sleep(1) self.assertEqual(mock.get_request(0).method, 'GET') self.assertEqual(mock.get_request(0).url, '/network/peering') self.assertEqual(process_community.label_error.text(), """Your pubkey or UID is different on the network. Yours : wrong_uid, the network : john""") process_community.close()
def testPythonConsoleWidget(self): w = PythonConsoleWidget() w.show() w.setVariable("foo", "bar") self.assertNotIn("bar", w.output.toPlainText()) QTest.keyClicks(w.input_line, "peacock['foo']") QTest.keyClick(w.input_line, Qt.Key_Return) self.assertIn("bar", w.output.toPlainText()) w.output.clear() QTest.keyClick(w.input_line, Qt.Key_Up) QTest.keyClick(w.input_line, Qt.Key_Return) self.assertIn("bar", w.output.toPlainText()) w.saveHistory() del w w = PythonConsoleWidget() w.show() w.setVariable("foo", "bar") QTest.keyClick(w.input_line, Qt.Key_Up) QTest.keyClick(w.input_line, Qt.Key_Return) self.assertIn("bar", w.output.toPlainText())