~suutari-olli/openlp/click-slide-to-go-live-from-blank

« back to all changes in this revision

Viewing changes to tests/functional/openlp_core_common/test_versionchecker.py

  • Committer: Simon Hanna
  • Date: 2016-05-17 08:48:19 UTC
  • mfrom: (2625.1.36 openlp)
  • mto: (2625.1.37 openlp)
  • mto: This revision was merged to the branch mainline in revision 2649.
  • Revision ID: simon.hanna@serve-me.info-20160517084819-lgup78nzyzjympuu
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
 
3
 
 
4
###############################################################################
 
5
# OpenLP - Open Source Lyrics Projection                                      #
 
6
# --------------------------------------------------------------------------- #
 
7
# Copyright (c) 2008-2016 OpenLP Developers                                   #
 
8
# --------------------------------------------------------------------------- #
 
9
# This program is free software; you can redistribute it and/or modify it     #
 
10
# under the terms of the GNU General Public License as published by the Free  #
 
11
# Software Foundation; version 2 of the License.                              #
 
12
#                                                                             #
 
13
# This program is distributed in the hope that it will be useful, but WITHOUT #
 
14
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
 
15
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    #
 
16
# more details.                                                               #
 
17
#                                                                             #
 
18
# You should have received a copy of the GNU General Public License along     #
 
19
# with this program; if not, write to the Free Software Foundation, Inc., 59  #
 
20
# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
 
21
###############################################################################
 
22
"""
 
23
Package to test the openlp.core.common.versionchecker package.
 
24
"""
 
25
from unittest import TestCase
 
26
 
 
27
from openlp.core.common.settings import Settings
 
28
from openlp.core.common.versionchecker import VersionThread
 
29
from tests.functional import MagicMock, patch
 
30
from tests.helpers.testmixin import TestMixin
 
31
 
 
32
 
 
33
class TestVersionchecker(TestMixin, TestCase):
 
34
 
 
35
    def setUp(self):
 
36
        """
 
37
        Create an instance and a few example actions.
 
38
        """
 
39
        self.build_settings()
 
40
 
 
41
    def tearDown(self):
 
42
        """
 
43
        Clean up
 
44
        """
 
45
        self.destroy_settings()
 
46
 
 
47
    def version_thread_triggered_test(self):
 
48
        """
 
49
        Test the version thread call does not trigger UI
 
50
        :return:
 
51
        """
 
52
        # GIVEN: a equal version setup and the data is not today.
 
53
        mocked_main_window = MagicMock()
 
54
        Settings().setValue('core/last version test', '1950-04-01')
 
55
        # WHEN: We check to see if the version is different .
 
56
        with patch('PyQt5.QtCore.QThread'),\
 
57
                patch('openlp.core.common.versionchecker.get_application_version') as mocked_get_application_version:
 
58
            mocked_get_application_version.return_value = {'version': '1.0.0', 'build': '', 'full': '2.0.4'}
 
59
            version_thread = VersionThread(mocked_main_window)
 
60
            version_thread.run()
 
61
        # THEN: If the version has changed the main window is notified
 
62
        self.assertTrue(mocked_main_window.openlp_version_check.emit.called,
 
63
                        'The main windows should have been notified')