~trb143/openlp/trans31032017

« back to all changes in this revision

Viewing changes to tests/interfaces/openlp_core_ui/test_shortcutlistform.py

  • Committer: Raoul Snyman
  • Date: 2017-03-30 01:47:59 UTC
  • mfrom: (2680.1.2 custom-shortcut-2.4)
  • Revision ID: raoul@snyman.info-20170330014759-af3l00nvkqngyvcy
Disable the shortcut controls when an action has not been selected

Add this to your merge proposal:
--------------------------------
lp:~raoul-snyman/openlp/custom-shortcuts-2.4 (revision 2681)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1952/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1863/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1804/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/1530/
[SUCCESS] https://ci.openlp.io/job...

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
        del self.form
53
53
        del self.main_window
54
54
 
 
55
    def test_set_controls_enabled(self):
 
56
        """
 
57
        Test that the _set_controls_enabled() method works correctly
 
58
        """
 
59
        # GIVEN: A shortcut form, and a value to set the controls
 
60
        is_enabled = True
 
61
 
 
62
        # WHEN: _set_controls_enabled() is called
 
63
        self.form._set_controls_enabled(is_enabled)
 
64
 
 
65
        # THEN: The controls should be enabled
 
66
        assert self.form.default_radio_button.isEnabled() is True
 
67
        assert self.form.custom_radio_button.isEnabled() is True
 
68
        assert self.form.primary_push_button.isEnabled() is True
 
69
        assert self.form.alternate_push_button.isEnabled() is True
 
70
        assert self.form.clear_primary_button.isEnabled() is True
 
71
        assert self.form.clear_alternate_button.isEnabled() is True
 
72
 
55
73
    def adjust_button_test(self):
56
74
        """
57
75
        Test the _adjust_button() method
71
89
            mocked_check_method.assert_called_once_with(True)
72
90
            self.assertEqual(button.isEnabled(), enabled, 'The button should be disabled.')
73
91
 
 
92
    @patch('openlp.core.ui.shortcutlistform.QtWidgets.QDialog.exec')
 
93
    def test_exec(self, mocked_exec):
 
94
        """
 
95
        Test the exec method
 
96
        """
 
97
        # GIVEN: A form and a mocked out base exec method
 
98
        mocked_exec.return_value = True
 
99
 
 
100
        # WHEN: exec is called
 
101
        result = self.form.exec()
 
102
 
 
103
        # THEN: The result should be True and the controls should be disabled
 
104
        assert self.form.default_radio_button.isEnabled() is False
 
105
        assert self.form.custom_radio_button.isEnabled() is False
 
106
        assert self.form.primary_push_button.isEnabled() is False
 
107
        assert self.form.alternate_push_button.isEnabled() is False
 
108
        assert self.form.clear_primary_button.isEnabled() is False
 
109
        assert self.form.clear_alternate_button.isEnabled() is False
 
110
        mocked_exec.assert_called_once_with(self.form)
 
111
        assert result is True
 
112
 
74
113
    def space_key_press_event_test(self):
75
114
        """
76
115
        Test the keyPressEvent when the spacebar was pressed