예제 #1
0
    def test_build_html_video(self, MockedSettings, Mocked_build_html):
        # GIVEN: Mocked display
        display = MagicMock()
        mocked_media_controller = MagicMock()
        Registry.create()
        Registry().register('media_controller', mocked_media_controller)
        main_display = MainDisplay(display)
        main_display.frame = MagicMock()
        mocked_settings = MagicMock()
        mocked_settings.value.return_value = False
        MockedSettings.return_value = mocked_settings
        main_display.shake_web_view = MagicMock()
        service_item = MagicMock()
        service_item.theme_data = MagicMock()
        service_item.theme_data.background_type = 'video'
        mocked_plugin = MagicMock()
        display.plugin_manager = PluginManager()
        display.plugin_manager.plugins = [mocked_plugin]
        main_display.web_view = MagicMock()

        # WHEN: build_html is called with a normal service item and a video theme.
        main_display.build_html(service_item)

        # THEN: the following should had not been called
        self.assertEquals(main_display.web_view.setHtml.call_count, 1,
                          'setHTML should be called once')
        self.assertEquals(
            main_display.media_controller.video.call_count, 1,
            'Media Controller video should have been called once')
예제 #2
0
    def hook_settings_tabs_with_active_plugin_and_mocked_form_test(self):
        """
        Test running the hook_settings_tabs() method with an active plugin and a mocked settings form
        """
        # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active
        mocked_plugin = MagicMock()
        mocked_plugin.status = PluginStatus.Active
        plugin_manager = PluginManager()
        plugin_manager.plugins = [mocked_plugin]
        mocked_settings_form = MagicMock()
        # Replace the autoloaded plugin with the version for testing in real code this would error
        mocked_settings_form.plugin_manager = plugin_manager

        # WHEN: We run hook_settings_tabs()
        plugin_manager.hook_settings_tabs()

        # THEN: The create_media_manager_item() method should have been called with the mocked settings form
        self.assertEqual(
            1, mocked_plugin.create_settings_tab.call_count,
            'The create_media_manager_item() method should have been called once.'
        )
        self.assertEqual(
            plugin_manager.plugins,
            mocked_settings_form.plugin_manager.plugins,
            'The plugins on the settings form should be the same as the plugins in the plugin manager'
        )
예제 #3
0
    def test_build_html_video(self, MockedSettings, Mocked_build_html):
        # GIVEN: Mocked display
        display = MagicMock()
        mocked_media_controller = MagicMock()
        Registry.create()
        Registry().register('media_controller', mocked_media_controller)
        main_display = MainDisplay(display)
        main_display.frame = MagicMock()
        mocked_settings = MagicMock()
        mocked_settings.value.return_value = False
        MockedSettings.return_value = mocked_settings
        main_display.shake_web_view = MagicMock()
        service_item = MagicMock()
        service_item.theme_data = MagicMock()
        service_item.theme_data.background_type = 'video'
        service_item.theme_data.theme_name = 'name'
        service_item.theme_data.background_filename = 'background_filename'
        mocked_plugin = MagicMock()
        display.plugin_manager = PluginManager()
        display.plugin_manager.plugins = [mocked_plugin]
        main_display.web_view = MagicMock()

        # WHEN: build_html is called with a normal service item and a video theme.
        main_display.build_html(service_item)

        # THEN: the following should had not been called
        self.assertEquals(main_display.web_view.setHtml.call_count, 1, 'setHTML should be called once')
        self.assertEquals(main_display.media_controller.video.call_count, 1,
                          'Media Controller video should have been called once')
예제 #4
0
    def test_hook_settings_tabs_with_disabled_plugin_and_mocked_form(self):
        """
        Test running the hook_settings_tabs() method with a disabled plugin and a mocked form
        """
        # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Disabled
        mocked_plugin = MagicMock()
        mocked_plugin.status = PluginStatus.Disabled
        plugin_manager = PluginManager()
        plugin_manager.plugins = [mocked_plugin]
        mocked_settings_form = MagicMock()
        # Replace the autoloaded plugin with the version for testing in real code this would error
        mocked_settings_form.plugin_manager = plugin_manager

        # WHEN: We run hook_settings_tabs()
        plugin_manager.hook_settings_tabs()

        # THEN: The create_settings_tab() method should not have been called, but the plugins lists should be the same
        self.assertEqual(
            0, mocked_plugin.create_settings_tab.call_count,
            'The create_media_manager_item() method should not have been called.'
        )
        self.assertEqual(
            mocked_settings_form.plugin_manager.plugins,
            plugin_manager.plugins,
            'The plugins on the settings form should be the same as the plugins in the plugin manager'
        )
예제 #5
0
    def hook_settings_tabs_with_active_plugin_and_mocked_form_test(self):
        """
        Test running the hook_settings_tabs() method with an active plugin and a mocked settings form
        """
        # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active
        mocked_plugin = MagicMock()
        mocked_plugin.status = PluginStatus.Active
        plugin_manager = PluginManager()
        plugin_manager.plugins = [mocked_plugin]
        mocked_settings_form = MagicMock()
        # Replace the autoloaded plugin with the version for testing in real code this would error
        mocked_settings_form.plugin_manager = plugin_manager

        # WHEN: We run hook_settings_tabs()
        plugin_manager.hook_settings_tabs()

        # THEN: The create_media_manager_item() method should have been called with the mocked settings form
        self.assertEqual(1, mocked_plugin.create_settings_tab.call_count,
                         'The create_media_manager_item() method should have been called once.')
        self.assertEqual(plugin_manager.plugins, mocked_settings_form.plugin_manager.plugins,
                         'The plugins on the settings form should be the same as the plugins in the plugin manager')
예제 #6
0
    def test_hook_settings_tabs_with_disabled_plugin_and_mocked_form(self):
        """
        Test running the hook_settings_tabs() method with a disabled plugin and a mocked form
        """
        # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Disabled
        mocked_plugin = MagicMock()
        mocked_plugin.status = PluginStatus.Disabled
        plugin_manager = PluginManager()
        plugin_manager.plugins = [mocked_plugin]
        mocked_settings_form = MagicMock()
        # Replace the autoloaded plugin with the version for testing in real code this would error
        mocked_settings_form.plugin_manager = plugin_manager

        # WHEN: We run hook_settings_tabs()
        plugin_manager.hook_settings_tabs()

        # THEN: The create_settings_tab() method should not have been called, but the plugins lists should be the same
        self.assertEqual(0, mocked_plugin.create_settings_tab.call_count,
                         'The create_media_manager_item() method should not have been called.')
        self.assertEqual(mocked_settings_form.plugin_manager.plugins, plugin_manager.plugins,
                         'The plugins on the settings form should be the same as the plugins in the plugin manager')