Adding a test

This commit is contained in:
David Andrs 2021-08-10 16:39:39 -06:00 committed by Rebecca
parent becc427e5d
commit 532294ba1c
2 changed files with 17 additions and 2 deletions

View file

@ -87,3 +87,9 @@ def tmpfile(tmpdir):
def item():
from beeref.items import BeePixmapItem
yield BeePixmapItem(QtGui.QImage())
@pytest.fixture(scope="session")
def qapp():
from beeref.__main__ import BeeRefApplication
yield BeeRefApplication([])

View file

@ -1,4 +1,4 @@
from unittest.mock import patch
from unittest.mock import patch, MagicMock
from PyQt6 import QtCore
@ -18,7 +18,16 @@ def test_beeref_mainwindow_init(show_mock, qapp):
show_mock.assert_called()
@patch('PyQt6.QtWidgets.QApplication')
@patch('beeref.view.BeeGraphicsView.open_from_file')
def test_beerefapplication_fileopenevent(open_mock, qapp, main_window):
event = MagicMock()
event.type.return_value = QtCore.QEvent.Type.FileOpen
event.file.return_value = 'test.bee'
assert qapp.event(event) is True
open_mock.assert_called_once_with('test.bee')
@patch('beeref.__main__.BeeRefApplication')
@patch('beeref.__main__.CommandlineArgs')
def test_main(args_mock, app_mock, qapp):
app_mock.return_value = qapp