forked from openlp/openlp
Cleaned pep8 errors
This commit is contained in:
parent
79b4c474d6
commit
4f1a074546
@ -33,7 +33,6 @@ from tests.functional import MagicMock, patch, call
|
||||
|
||||
class TestListPreviewWidget(TestCase):
|
||||
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Mock out stuff for all the tests
|
||||
@ -43,7 +42,6 @@ class TestListPreviewWidget(TestCase):
|
||||
self.mocked_parent.width.return_value = 100
|
||||
self.addCleanup(self.parent_patcher.stop)
|
||||
|
||||
|
||||
def new_list_preview_widget_test(self):
|
||||
"""
|
||||
Test that creating an instance of ListPreviewWidget works
|
||||
@ -56,17 +54,15 @@ class TestListPreviewWidget(TestCase):
|
||||
# THEN: The object is not None, and the _setup() method was called.
|
||||
self.assertIsNotNone(list_preview_widget, 'The ListPreviewWidget object should not be None')
|
||||
self.assertEquals(list_preview_widget.screen_ratio, 1, 'Should not be called')
|
||||
#self.mocked_setup.assert_called_with(1)
|
||||
|
||||
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.Settings')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.viewport')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.resizeRowsToContents')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.setRowHeight')
|
||||
def replace_recalculate_layout_test_text(self, mocked_setRowHeight, mocked_resizeRowsToContents,
|
||||
mocked_viewport, mocked_Settings):
|
||||
mocked_viewport, mocked_Settings):
|
||||
"""
|
||||
Test if "Max height for non-text slides in slide controller" enabled, text-based slides not affected in replace_service_item and __recalculate_layout.
|
||||
Test if "Max height for non-text slides..." enabled, txt slides unchanged in replace_service_item & __recalc...
|
||||
"""
|
||||
# GIVEN: A setting to adjust "Max height for non-text slides in slide controller",
|
||||
# a text ServiceItem and a ListPreviewWidget.
|
||||
@ -98,15 +94,14 @@ class TestListPreviewWidget(TestCase):
|
||||
self.assertEquals(mocked_resizeRowsToContents.call_count, 2, 'Should be called')
|
||||
self.assertEquals(mocked_setRowHeight.call_count, 0, 'Should not be called')
|
||||
|
||||
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.Settings')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.viewport')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.resizeRowsToContents')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.setRowHeight')
|
||||
def replace_recalculate_layout_test_img(self, mocked_setRowHeight, mocked_resizeRowsToContents,
|
||||
mocked_viewport, mocked_Settings):
|
||||
mocked_viewport, mocked_Settings):
|
||||
"""
|
||||
Test if "Max height for non-text slides in slide controller" disabled, image-based slides not resized to the max-height in replace_service_item and __recalculate_layout.
|
||||
Test if "Max height for non-text slides..." disabled, img slides unchanged in replace_service_item & __recalc...
|
||||
"""
|
||||
# GIVEN: A setting to adjust "Max height for non-text slides in slide controller",
|
||||
# an image ServiceItem and a ListPreviewWidget.
|
||||
@ -136,18 +131,17 @@ class TestListPreviewWidget(TestCase):
|
||||
# THEN: timer should have been started
|
||||
self.assertEquals(mocked_resizeRowsToContents.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(mocked_setRowHeight.call_count, 4, 'Should be called twice for each slide')
|
||||
calls = [call(0,200), call(1,200),call(0,400), call(1,400)]
|
||||
calls = [call(0, 200), call(1, 200), call(0, 400), call(1, 400)]
|
||||
mocked_setRowHeight.assert_has_calls(calls)
|
||||
|
||||
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.Settings')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.viewport')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.resizeRowsToContents')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.setRowHeight')
|
||||
def replace_recalculate_layout_test_img_max(self, mocked_setRowHeight, mocked_resizeRowsToContents,
|
||||
mocked_viewport, mocked_Settings):
|
||||
mocked_viewport, mocked_Settings):
|
||||
"""
|
||||
Test if "Max height for non-text slides in slide controller" enabled, image-based slides are resized to the max-height in replace_service_item and __recalculate_layout.
|
||||
Test if "Max height for non-text slides..." enabled, img slides resized in replace_service_item & __recalc...
|
||||
"""
|
||||
|
||||
# GIVEN: A setting to adjust "Max height for non-text slides in slide controller",
|
||||
@ -177,19 +171,18 @@ class TestListPreviewWidget(TestCase):
|
||||
# THEN: timer should have been started
|
||||
self.assertEquals(mocked_resizeRowsToContents.call_count, 0, 'Should not be called')
|
||||
self.assertEquals(mocked_setRowHeight.call_count, 4, 'Should be called twice for each slide')
|
||||
calls = [call(0,100), call(1,100),call(0,100), call(1,100)]
|
||||
calls = [call(0, 100), call(1, 100), call(0, 100), call(1, 100)]
|
||||
mocked_setRowHeight.assert_has_calls(calls)
|
||||
|
||||
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.Settings')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.viewport')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.resizeRowsToContents')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.setRowHeight')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.cellWidget')
|
||||
def row_resized_test_text(self, mocked_cellWidget, mocked_setRowHeight, mocked_resizeRowsToContents,
|
||||
mocked_viewport, mocked_Settings):
|
||||
mocked_viewport, mocked_Settings):
|
||||
"""
|
||||
Test if "Max height for non-text slides in slide controller" enabled, text-based slides not affected in row_resized.
|
||||
Test if "Max height for non-text slides..." enabled, text-based slides not affected in row_resized.
|
||||
"""
|
||||
# GIVEN: A setting to adjust "Max height for non-text slides in slide controller",
|
||||
# a text ServiceItem and a ListPreviewWidget.
|
||||
@ -210,7 +203,7 @@ class TestListPreviewWidget(TestCase):
|
||||
# Mock self.cellWidget().children().setMaximumWidth()
|
||||
mocked_cellWidget_child = MagicMock()
|
||||
mocked_cellWidget_obj = MagicMock()
|
||||
mocked_cellWidget_obj.children.return_value = [None,mocked_cellWidget_child]
|
||||
mocked_cellWidget_obj.children.return_value = [None, mocked_cellWidget_child]
|
||||
mocked_cellWidget.return_value = mocked_cellWidget_obj
|
||||
# init ListPreviewWidget and load service item
|
||||
list_preview_widget = ListPreviewWidget(None, 1)
|
||||
@ -222,16 +215,15 @@ class TestListPreviewWidget(TestCase):
|
||||
# THEN: self.cellWidget(row, 0).children()[1].setMaximumWidth() should not be called
|
||||
self.assertEquals(mocked_cellWidget_child.setMaximumWidth.call_count, 0, 'Should not be called')
|
||||
|
||||
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.Settings')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.viewport')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.resizeRowsToContents')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.setRowHeight')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.cellWidget')
|
||||
def row_resized_test_img(self, mocked_cellWidget, mocked_setRowHeight, mocked_resizeRowsToContents,
|
||||
mocked_viewport, mocked_Settings):
|
||||
mocked_viewport, mocked_Settings):
|
||||
"""
|
||||
Test if "Max height for non-text slides in slide controller" disabled, image-based slides not affected in row_resized.
|
||||
Test if "Max height for non-text slides..." disabled, image-based slides not affected in row_resized.
|
||||
"""
|
||||
# GIVEN: A setting to adjust "Max height for non-text slides in slide controller",
|
||||
# an image ServiceItem and a ListPreviewWidget.
|
||||
@ -252,7 +244,7 @@ class TestListPreviewWidget(TestCase):
|
||||
# Mock self.cellWidget().children().setMaximumWidth()
|
||||
mocked_cellWidget_child = MagicMock()
|
||||
mocked_cellWidget_obj = MagicMock()
|
||||
mocked_cellWidget_obj.children.return_value = [None,mocked_cellWidget_child]
|
||||
mocked_cellWidget_obj.children.return_value = [None, mocked_cellWidget_child]
|
||||
mocked_cellWidget.return_value = mocked_cellWidget_obj
|
||||
# init ListPreviewWidget and load service item
|
||||
list_preview_widget = ListPreviewWidget(None, 1)
|
||||
@ -264,16 +256,15 @@ class TestListPreviewWidget(TestCase):
|
||||
# THEN: self.cellWidget(row, 0).children()[1].setMaximumWidth() should not be called
|
||||
self.assertEquals(mocked_cellWidget_child.setMaximumWidth.call_count, 0, 'Should not be called')
|
||||
|
||||
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.Settings')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.viewport')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.resizeRowsToContents')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.setRowHeight')
|
||||
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.cellWidget')
|
||||
def row_resized_test_img_max(self, mocked_cellWidget, mocked_setRowHeight, mocked_resizeRowsToContents,
|
||||
mocked_viewport, mocked_Settings):
|
||||
mocked_viewport, mocked_Settings):
|
||||
"""
|
||||
Test if "Max height for non-text slides in slide controller" enabled, image-based slides are scaled in row_resized.
|
||||
Test if "Max height for non-text slides..." enabled, image-based slides are scaled in row_resized.
|
||||
"""
|
||||
# GIVEN: A setting to adjust "Max height for non-text slides in slide controller",
|
||||
# an image ServiceItem and a ListPreviewWidget.
|
||||
@ -294,7 +285,7 @@ class TestListPreviewWidget(TestCase):
|
||||
# Mock self.cellWidget().children().setMaximumWidth()
|
||||
mocked_cellWidget_child = MagicMock()
|
||||
mocked_cellWidget_obj = MagicMock()
|
||||
mocked_cellWidget_obj.children.return_value = [None,mocked_cellWidget_child]
|
||||
mocked_cellWidget_obj.children.return_value = [None, mocked_cellWidget_child]
|
||||
mocked_cellWidget.return_value = mocked_cellWidget_obj
|
||||
# init ListPreviewWidget and load service item
|
||||
list_preview_widget = ListPreviewWidget(None, 1)
|
||||
|
Loading…
Reference in New Issue
Block a user