From de31170fbd9b53823b312be74ea37c6bbaef79f6 Mon Sep 17 00:00:00 2001 From: Inso <insomniak.fr@gmail.com> Date: Sun, 6 Sep 2015 10:38:05 +0200 Subject: [PATCH] Opening async dialog in test --- src/cutecoin/gui/process_cfg_community.py | 1 - .../tests/process_cfg_community/test_add_community.py | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cutecoin/gui/process_cfg_community.py b/src/cutecoin/gui/process_cfg_community.py index 73e8415f..55481d5b 100644 --- a/src/cutecoin/gui/process_cfg_community.py +++ b/src/cutecoin/gui/process_cfg_community.py @@ -270,7 +270,6 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog): action.setEnabled(False) menu.exec_(QCursor.pos()) - @asyncio.coroutine def async_exec(self): future = asyncio.Future() self.finished.connect(lambda r: future.set_result(r)) diff --git a/src/cutecoin/tests/process_cfg_community/test_add_community.py b/src/cutecoin/tests/process_cfg_community/test_add_community.py index 1e7d74db..0a14ac2c 100644 --- a/src/cutecoin/tests/process_cfg_community/test_add_community.py +++ b/src/cutecoin/tests/process_cfg_community/test_add_community.py @@ -5,7 +5,7 @@ import asyncio import quamash import logging import time -from PyQt5.QtWidgets import QMessageBox +from PyQt5.QtWidgets import QDialog from PyQt5.QtCore import QLocale, Qt from PyQt5.QtTest import QTest from cutecoin.tests.mocks.bma import new_blockchain @@ -45,15 +45,16 @@ class ProcessAddCommunity(unittest.TestCase): process_community = ProcessConfigureCommunity(self.application, self.account, None, self.password_asker) + @asyncio.coroutine - def open_dialog(): + def open_dialog(process_community): result = yield from process_community.async_exec() + self.assertEqual(result, QDialog.Accepted) @asyncio.coroutine def exec_test(): mock = new_blockchain.get_mock() logging.debug(mock.pretend_url) - asyncio.async(open_dialog()) yield from asyncio.sleep(1) self.network_manager.set_mock_path(mock.pretend_url) QTest.mouseClick(process_community.lineedit_server, Qt.LeftButton) @@ -82,8 +83,10 @@ class ProcessAddCommunity(unittest.TestCase): self.assertEqual(process_community.stacked_pages.currentWidget(), process_community.page_add_nodes) + QTest.mouseClick(process_community.button_next, Qt.LeftButton) - self.lp.run_until_complete(asyncio.wait_for(exec_test(), timeout=10)) + asyncio.async(exec_test()) + self.lp.run_until_complete(open_dialog(process_community)) if __name__ == '__main__': logging.basicConfig( stream=sys.stderr ) -- GitLab