Skip to content

Commit

Permalink
Merge pull request #299 from ales-erjavec/fixes/test-overlay
Browse files Browse the repository at this point in the history
[FIX] Fix test_overlay
  • Loading branch information
ales-erjavec authored May 24, 2024
2 parents 6967b60 + 4a878c7 commit ac0d421
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions orangecanvas/utils/tests/test_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import unittest.mock

from AnyQt.QtCore import Qt, QEvent
from AnyQt.QtTest import QTest
from AnyQt.QtTest import QTest, QSignalSpy
from AnyQt.QtWidgets import QWidget, QApplication

from orangecanvas.gui.test import QAppTestCase
Expand All @@ -13,6 +13,7 @@

class TestOverlay(QAppTestCase):
def setUp(self) -> None:
super().setUp()
self.container = QWidget()
self.overlay = NotificationOverlay(self.container)
self.server = NotificationServer()
Expand All @@ -30,6 +31,7 @@ def tearDown(self) -> None:
self.overlay = None
self.notif = None
self.server = None
super().tearDown()

def test_notification_widget(self):
stdb = NotificationWidget.Ok | NotificationWidget.Close
Expand Down Expand Up @@ -77,8 +79,7 @@ def test_two_overlays(self):
self.server.newNotification.connect(overlay2.addNotification)
self.server.nextNotification.connect(overlay2.nextWidget)

mock = unittest.mock.MagicMock()
self.notif.accepted.connect(mock)
spy = QSignalSpy(self.notif.accepted)

self.server.registerNotification(self.notif)

Expand All @@ -94,7 +95,7 @@ def test_two_overlays(self):
button = w2.button(NotificationWidget.Ok)
QTest.mouseClick(button, Qt.LeftButton)

mock.assert_called_once_with()
self.assertSequenceEqual(list(spy), [[]])

self.assertFalse(w1.isVisible())
self.assertFalse(w2.isVisible())
Expand Down

0 comments on commit ac0d421

Please sign in to comment.