openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #29810
Re: [Merge] lp:~knightrider0xd/openlp/non-text-item-height-default into lp:openlp
Review: Needs Fixing
Sorry, just spotted this. Your tests are incorrectly named, and won't be picked up by the test runner (especially when we move to nose2).
Diff comments:
>
> === modified file 'tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py'
> --- tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py 2016-05-06 01:46:49 +0000
> +++ tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py 2016-06-01 04:37:07 +0000
> @@ -227,6 +227,44 @@
>
> @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents')
> @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight')
> + def replace_recalculate_layout_test_img_auto(self, mocked_setRowHeight, mocked_resizeRowsToContents):
This test won't be run. You need to name it "test_..." in order for the test runner to pick it up.
> + """
> + Test if "Max height for non-text slides..." auto, img slides resized 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.
> +
> + # Mock Settings().value('advanced/slide max height')
> + self.mocked_Settings_obj.value.return_value = -4
> + # Mock self.viewport().width()
> + self.mocked_viewport_obj.width.return_value = 200
> + self.mocked_viewport_obj.height.return_value = 600
> + # Mock image service item
> + service_item = MagicMock()
> + service_item.is_text.return_value = False
> + service_item.is_capable.return_value = False
> + service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': None},
> + {'title': None, 'path': None, 'image': None}]
> + # init ListPreviewWidget and load service item
> + list_preview_widget = ListPreviewWidget(None, 1)
> + list_preview_widget.replace_service_item(service_item, 200, 0)
> + # Change viewport width before forcing a resize
> + self.mocked_viewport_obj.width.return_value = 400
> +
> + # WHEN: __recalculate_layout() is called (via screen_size_changed)
> + list_preview_widget.screen_size_changed(1)
> + self.mocked_viewport_obj.height.return_value = 200
> + list_preview_widget.screen_size_changed(1)
> +
> + # THEN: resizeRowsToContents() should not be called, while setRowHeight() should be called
> + # twice for each slide.
> + self.assertEquals(mocked_resizeRowsToContents.call_count, 0, 'Should not be called')
> + self.assertEquals(mocked_setRowHeight.call_count, 6, 'Should be called 3 times for each slide')
> + calls = [call(0, 100), call(1, 100), call(0, 150), call(1, 150), call(0, 100), call(1, 100)]
> + mocked_setRowHeight.assert_has_calls(calls)
> +
> + @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents')
> + @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight')
> @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.cellWidget')
> def row_resized_test_text(self, mocked_cellWidget, mocked_setRowHeight, mocked_resizeRowsToContents):
This test has the same problem as above. Please just fix it too.
> """
> @@ -331,6 +369,41 @@
> # THEN: self.cellWidget(row, 0).children()[1].setMaximumWidth() should be called
> mocked_cellWidget_child.setMaximumWidth.assert_called_once_with(150)
>
> + @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents')
> + @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight')
> + @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.cellWidget')
> + def row_resized_test_setting_changed(self, mocked_cellWidget, mocked_setRowHeight, mocked_resizeRowsToContents):
See the comments above.
> + """
> + Test if "Max height for non-text slides..." enabled while item live, program doesn't crash on row_resized.
> + """
> + # GIVEN: A setting to adjust "Max height for non-text slides in slide controller",
> + # an image ServiceItem and a ListPreviewWidget.
> +
> + # Mock Settings().value('advanced/slide max height')
> + self.mocked_Settings_obj.value.return_value = 0
> + # Mock self.viewport().width()
> + self.mocked_viewport_obj.width.return_value = 200
> + # Mock image service item
> + service_item = MagicMock()
> + service_item.is_text.return_value = False
> + service_item.is_capable.return_value = False
> + service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': None},
> + {'title': None, 'path': None, 'image': None}]
> + # Mock self.cellWidget().children()
> + mocked_cellWidget_obj = MagicMock()
> + mocked_cellWidget_obj.children.return_value = None
> + mocked_cellWidget.return_value = mocked_cellWidget_obj
> + # init ListPreviewWidget and load service item
> + list_preview_widget = ListPreviewWidget(None, 1)
> + list_preview_widget.replace_service_item(service_item, 200, 0)
> + self.mocked_Settings_obj.value.return_value = 100
> +
> + # WHEN: row_resized() is called
> + list_preview_widget.row_resized(0, 100, 150)
> +
> + # THEN: self.cellWidget(row, 0).children()[1].setMaximumWidth() should fail
> + self.assertRaises(Exception)
> +
> @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.selectRow')
> @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.scrollToItem')
> @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.item')
--
https://code.launchpad.net/~knightrider0xd/openlp/non-text-item-height-default/+merge/296161
Your team OpenLP Core is subscribed to branch lp:openlp.
References