Esempio n. 1
0
    def change_color_test(self):
        """
        Test that change_color sets the new color and the stylesheet
        """
        self.change_color_patcher.stop()

        # GIVEN: An instance of the ColorButton object, and a mocked out setStyleSheet
        with patch('openlp.core.lib.colorbutton.ColorButton.setStyleSheet') as mocked_set_style_sheet:
            widget = ColorButton()

            # WHEN: Changing the color
            widget.change_color('#000000')

            # THEN: The _color attribute should be set to #000000 and setStyleSheet should have been called twice
            self.assertEqual(widget._color, '#000000', '_color should have been set to #000000')
            mocked_set_style_sheet.assert_has_calls(
                [call('background-color: #ffffff'), call('background-color: #000000')])

        self.mocked_change_color = self.change_color_patcher.start()
Esempio n. 2
0
    def change_color_test(self):
        """
        Test that change_color sets the new color and the stylesheet
        """
        self.change_color_patcher.stop()

        # GIVEN: An instance of the ColorButton object, and a mocked out setStyleSheet
        with patch('openlp.core.lib.colorbutton.ColorButton.setStyleSheet'
                   ) as mocked_set_style_sheet:
            widget = ColorButton()

            # WHEN: Changing the color
            widget.change_color('#000000')

            # THEN: The _color attribute should be set to #000000 and setStyleSheet should have been called twice
            self.assertEqual(widget._color, '#000000',
                             '_color should have been set to #000000')
            mocked_set_style_sheet.assert_has_calls([
                call('background-color: #ffffff'),
                call('background-color: #000000')
            ])

        self.mocked_change_color = self.change_color_patcher.start()