From 30d0633a3e99b25cdb4c88ee3f27c4b607052c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Th=C3=B6ni?= <florian.thoni@teamwork.net> Date: Mon, 1 May 2017 16:45:31 +0200 Subject: [PATCH] In test_connection_cfg_dialog Some click seemed to be useless on the page_services that has not buttons. Create an helper accept_dialog function that takes a title and accept the relevant dialog. --- tests/functional/test_connection_cfg_dialog.py | 9 +++------ tests/helpers.py | 7 +++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/functional/test_connection_cfg_dialog.py b/tests/functional/test_connection_cfg_dialog.py index 4e08b99f..8c9d9865 100644 --- a/tests/functional/test_connection_cfg_dialog.py +++ b/tests/functional/test_connection_cfg_dialog.py @@ -5,7 +5,7 @@ from PyQt5.QtCore import Qt from PyQt5.QtTest import QTest from sakia.data.processors import ConnectionsProcessor, BlockchainProcessor from sakia.gui.dialogs.connection_cfg import ConnectionConfigController -from tests.helpers import click_on_top_message_box, select_file_dialog +from tests.helpers import click_on_top_message_box, select_file_dialog, accept_dialog def assert_key_parameters_behaviour(connection_config_dialog, user): @@ -59,12 +59,11 @@ async def test_register_empty_blockchain(application, fake_server, bob, tmpdir): await asyncio.sleep(1) select_file_dialog(str(revocation_file)) await asyncio.sleep(1) - click_on_top_message_box() await asyncio.sleep(1) revocation_file.ensure() assert connection_config_dialog.view.stacked_pages.currentWidget() == connection_config_dialog.view.page_services assert len(ConnectionsProcessor.instanciate(application).connections()) == 1 - click_on_top_message_box() + accept_dialog("Registration") application.loop.call_later(10, close_dialog) asyncio.ensure_future(exec_test()) @@ -90,12 +89,10 @@ async def test_connect(application, fake_server_with_blockchain, bob): assert connection_config_dialog.view.stacked_pages.currentWidget() == connection_config_dialog.view.page_connection assert_key_parameters_behaviour(connection_config_dialog, bob) QTest.mouseClick(connection_config_dialog.view.button_next, Qt.LeftButton) - await asyncio.sleep(1) + await asyncio.sleep(0.1) assert connection_config_dialog.view.stacked_pages.currentWidget() == connection_config_dialog.view.page_services assert len(ConnectionsProcessor.instanciate(application).connections()) == 1 - click_on_top_message_box() - application.loop.call_later(10, close_dialog) asyncio.ensure_future(exec_test()) await connection_config_dialog.async_exec() diff --git a/tests/helpers.py b/tests/helpers.py index b0342e2d..2eac034d 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -10,6 +10,13 @@ def click_on_top_message_box_button(button): if isinstance(w, QMessageBox): QTest.mouseClick(w.button(button), Qt.LeftButton) +def accept_dialog(title): + topWidgets = QApplication.topLevelWidgets() + for w in topWidgets: + if isinstance(w, QDialog) and w.windowTitle() == title: + w.accept() + + def click_on_top_message_box(): topWidgets = QApplication.topLevelWidgets() for w in topWidgets: -- GitLab