[songusage] No need to trigger the action twice

This commit is contained in:
Raoul Snyman 2016-02-11 23:05:41 +02:00
parent a172183a4e
commit dcd39adfe2
3 changed files with 32 additions and 2 deletions

View File

@ -44,3 +44,4 @@ __pycache__
cover
*.kdev4
coverage
tags

View File

@ -118,7 +118,6 @@ class SongUsagePlugin(Plugin):
self.main_window.status_bar.insertPermanentWidget(1, self.song_usage_active_button)
self.song_usage_active_button.hide()
# Signals and slots
self.song_usage_status.changed.connect(self.toggle_song_usage_state)
self.song_usage_active_button.toggled.connect(self.toggle_song_usage_state)
self.song_usage_menu.menuAction().setVisible(False)

View File

@ -23,12 +23,23 @@
This module contains tests for the Songusage plugin.
"""
from unittest import TestCase
from unittest.mock import MagicMock, patch
from openlp.core import Registry
from openlp.plugins.songusage.lib import upgrade
from openlp.plugins.songusage.lib.db import init_schema
from openlp.plugins.songusage.songusageplugin import SongUsagePlugin
class TestSongUsage(TestCase):
def test_about_text(self):
def setUp(self):
Registry.create()
def about_text_test(self):
"""
Test the about text of the song usage plugin
"""
# GIVEN: The SongUsagePlugin
# WHEN: Retrieving the about text
# THEN: about() should return a string object
@ -36,3 +47,22 @@ class TestSongUsage(TestCase):
# THEN: about() should return a non-empty string
self.assertNotEquals(len(SongUsagePlugin.about()), 0)
self.assertNotEquals(len(SongUsagePlugin.about()), 0)
@patch('openlp.plugins.songusage.songusageplugin.Manager')
def song_usage_init_test(self, MockedManager):
"""
Test the initialisation of the SongUsagePlugin class
"""
# GIVEN: A mocked database manager
mocked_manager = MagicMock()
MockedManager.return_value = mocked_manager
# WHEN: The SongUsagePlugin class is instantiated
song_usage = SongUsagePlugin()
# THEN: It should be initialised correctly
MockedManager.assert_called_with('songusage', init_schema, upgrade_mod=upgrade)
self.assertEqual(mocked_manager, song_usage.manager)
self.assertFalse(song_usage.song_usage_active)