Example #1
0
class TestThemeManager(TestCase):
    """
    Test the functions in the ThemeManager Class
    """
    def setUp(self):
        with patch('openlp.core.ui.ThemeForm._setup'):
            self.instance = ThemeForm(None)

    def test_on_image_path_edit_path_changed(self):
        """
        Test the `image_path_edit.pathChanged` handler
        """
        # GIVEN: An instance of Theme Form
        with patch.object(self.instance, 'set_background_page_values'
                          ) as mocked_set_background_page_values:
            self.instance.theme = MagicMock()

            # WHEN: `on_image_path_edit_path_changed` is clicked
            self.instance.on_image_path_edit_path_changed(
                Path('/', 'new', 'pat.h'))

            # THEN: The theme background file should be set and `set_background_page_values` should have been called
            assert self.instance.theme.background_filename == Path(
                '/', 'new', 'pat.h')
            mocked_set_background_page_values.assert_called_once_with()