Fix up the tests

This commit is contained in:
Raoul Snyman 2017-12-01 22:31:23 -07:00
parent c7ea4c460e
commit f69757a59d
3 changed files with 54 additions and 11 deletions

View File

@ -1,5 +1,5 @@
[unittest]
verbose = True
verbose = true
plugins = nose2.plugins.mp
[log-capture]
@ -9,19 +9,19 @@ filter = -nose
log-level = ERROR
[test-result]
always-on = True
descriptions = True
always-on = true
descriptions = true
[coverage]
always-on = True
always-on = true
coverage = openlp
coverage-report = html
[multiprocess]
always-on = False
always-on = false
processes = 4
[output-buffer]
always-on = True
stderr = True
stdout = False
always-on = true
stderr = true
stdout = true

View File

@ -28,7 +28,7 @@ from unittest.mock import MagicMock
from PyQt5 import QtCore, QtWidgets
from openlp.core.common.registry import Registry
from openlp.core.display.screens import ScreenList
from openlp.core.display.screens import ScreenList, Screen
SCREEN = {
'primary': False,
@ -62,6 +62,45 @@ class TestScreenList(TestCase):
del self.screens
del self.application
def test_current_display_screen(self):
"""
Test that the "current" property returns the first display screen
"""
# GIVEN: A new ScreenList object with some screens
screen_list = ScreenList()
screen_list.screens = [
Screen(number=0, geometry=QtCore.QRect(0, 0, 1024, 768), is_primary=True),
Screen(number=1, geometry=QtCore.QRect(1024, 0, 1024, 768), is_primary=False, is_display=True)
]
# WHEN: The current property is accessed
screen = screen_list.current
# THEN: It should be the display screen
assert screen.number == 1
assert screen.geometry == QtCore.QRect(1024, 0, 1024, 768)
assert screen.is_primary is False
assert screen.is_display is True
def test_current_primary_screen(self):
"""
Test that the "current" property returns the first primary screen
"""
# GIVEN: A new ScreenList object with some screens
screen_list = ScreenList()
screen_list.screens = [
Screen(number=0, geometry=QtCore.QRect(0, 0, 1024, 768), is_primary=True)
]
# WHEN: The current property is accessed
screen = screen_list.current
# THEN: It should be the display screen
assert screen.number == 0
assert screen.geometry == QtCore.QRect(0, 0, 1024, 768)
assert screen.is_primary is True
assert screen.is_display is False
def test_create_screen_list(self):
"""
Create the screen list

View File

@ -158,8 +158,12 @@ class TestMainWindow(TestCase, TestMixin):
# WHEN: you check the started functions
# THEN: the following registry functions should have been registered
assert len(self.registry.service_list) == 12, \
'The registry should have 12 services, got {}'.format(self.registry.service_list.keys())
expected_service_list = ['application', 'main_window', 'media_controller', 'settings_form', 'plugin_manager',
'image_manager', 'preview_controller', 'live_controller', 'service_manager',
'theme_manager', 'projector_manager']
assert list(self.registry.service_list.keys()) == expected_service_list, \
'The registry should have the following services: {}, got {}'.format(expected_service_list,
self.registry.service_list.keys())
assert len(self.registry.functions_list) == 19, \
'The registry should have 19 functions, got {}'.format(self.registry.functions_list.keys())
assert 'application' in self.registry.service_list, 'The application should have been registered.'