Skip to content
Snippets Groups Projects
Commit b1f7cc8f authored by Florian Thöni's avatar Florian Thöni
Browse files

Genericate function for click button in test helper + usage in test_certification_dialog

parent ddb0f283
No related branches found
No related tags found
1 merge request!684READY:Test helpers : Message box, click yes vs enter
...@@ -3,9 +3,9 @@ import pytest ...@@ -3,9 +3,9 @@ import pytest
from duniterpy.documents import Certification from duniterpy.documents import Certification
from PyQt5.QtCore import QLocale, Qt, QEvent from PyQt5.QtCore import QLocale, Qt, QEvent
from PyQt5.QtTest import QTest from PyQt5.QtTest import QTest
from PyQt5.QtWidgets import QDialogButtonBox from PyQt5.QtWidgets import QDialogButtonBox, QMessageBox
from sakia.gui.sub.certification.controller import CertificationController from sakia.gui.sub.certification.controller import CertificationController
from ..helpers import yes_on_top_message_box from ..helpers import click_on_top_message_box_button
@pytest.mark.asyncio @pytest.mark.asyncio
...@@ -43,7 +43,7 @@ async def test_certification_init_community(application_with_one_connection, fak ...@@ -43,7 +43,7 @@ async def test_certification_init_community(application_with_one_connection, fak
assert certification_dialog.view.button_box.button(QDialogButtonBox.Ok).isEnabled() assert certification_dialog.view.button_box.button(QDialogButtonBox.Ok).isEnabled()
QTest.mouseClick(certification_dialog.view.button_box.button(QDialogButtonBox.Ok), Qt.LeftButton) QTest.mouseClick(certification_dialog.view.button_box.button(QDialogButtonBox.Ok), Qt.LeftButton)
await asyncio.sleep(0.1) await asyncio.sleep(0.1)
yes_on_top_message_box() click_on_top_message_box_button(QMessageBox.Yes)
await asyncio.sleep(0.2) await asyncio.sleep(0.2)
assert isinstance(fake_server_with_blockchain.forge.pool[0], Certification) assert isinstance(fake_server_with_blockchain.forge.pool[0], Certification)
......
...@@ -3,6 +3,13 @@ from PyQt5.QtCore import Qt ...@@ -3,6 +3,13 @@ from PyQt5.QtCore import Qt
from PyQt5.QtTest import QTest from PyQt5.QtTest import QTest
def click_on_top_message_box_button(button):
topWidgets = QApplication.topLevelWidgets()
for w in topWidgets:
if isinstance(w, QMessageBox):
QTest.mouseClick(w.button(button), Qt.LeftButton)
def click_on_top_message_box(): def click_on_top_message_box():
topWidgets = QApplication.topLevelWidgets() topWidgets = QApplication.topLevelWidgets()
for w in topWidgets: for w in topWidgets:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment