From b1f7cc8f9b757628c7cb1bd81189d7ae4e5cbf5f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20Th=C3=B6ni?= <florian.thoni@teamwork.net>
Date: Mon, 1 May 2017 14:33:53 +0200
Subject: [PATCH] Genericate function for click button in test helper + usage
 in test_certification_dialog

---
 tests/functional/test_certification_dialog.py | 6 +++---
 tests/helpers.py                              | 7 +++++++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/tests/functional/test_certification_dialog.py b/tests/functional/test_certification_dialog.py
index e6cc8421..a10c086b 100644
--- a/tests/functional/test_certification_dialog.py
+++ b/tests/functional/test_certification_dialog.py
@@ -3,9 +3,9 @@ import pytest
 from duniterpy.documents import Certification
 from PyQt5.QtCore import QLocale, Qt, QEvent
 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 ..helpers import yes_on_top_message_box
+from ..helpers import click_on_top_message_box_button
 
 
 @pytest.mark.asyncio
@@ -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()
         QTest.mouseClick(certification_dialog.view.button_box.button(QDialogButtonBox.Ok), Qt.LeftButton)
         await asyncio.sleep(0.1)
-        yes_on_top_message_box()
+        click_on_top_message_box_button(QMessageBox.Yes)
         await asyncio.sleep(0.2)
         assert isinstance(fake_server_with_blockchain.forge.pool[0], Certification)
 
diff --git a/tests/helpers.py b/tests/helpers.py
index a07b3e42..b0342e2d 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -3,6 +3,13 @@ from PyQt5.QtCore import Qt
 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():
     topWidgets = QApplication.topLevelWidgets()
     for w in topWidgets:
-- 
GitLab