def test_SvgToggleButton_enable(mocker): """ Ensure enable. """ stb = SvgToggleButton(on='mock_on', off='mock_off') stb.enable() assert stb.isEnabled() is True
def test_SvgToggleButton_disable(mocker): """ Ensure disable. """ stb = SvgToggleButton(on='mock_on', off='mock_off') stb.disable() assert stb.isEnabled() is False
def test_SvgToggleButton_set_icon(mocker): """ Ensure set_icon loads and sets the icon. """ setIcon_fn = mocker.patch('securedrop_client.gui.SvgToggleButton.setIcon') icon = mocker.MagicMock() load_toggle_icon_fn = mocker.patch('securedrop_client.gui.load_toggle_icon', return_value=icon) stb = SvgToggleButton(on='mock_on', off='mock_off') stb.set_icon(on='mock_on', off='mock_off') load_toggle_icon_fn.assert_called_with(on='mock_on', off='mock_off') setIcon_fn.assert_called_with(icon) assert stb.icon == icon
def test_SvgToggleButton_init(mocker): """ Ensure SvgToggleButton is checkable, which allows it to be a toggle button and that the expected methods are called correctly to set the icon and size. """ svg_size = QSize(1, 1) icon = mocker.MagicMock() load_toggle_icon_fn = mocker.patch('securedrop_client.gui.load_toggle_icon', return_value=icon) setIcon_fn = mocker.patch('securedrop_client.gui.SvgToggleButton.setIcon') setIconSize_fn = mocker.patch('securedrop_client.gui.SvgToggleButton.setIconSize') stb = SvgToggleButton(on='mock_on', off='mock_off', svg_size=svg_size) assert stb.isCheckable() is True load_toggle_icon_fn.assert_called_once_with(on='mock_on', off='mock_off') setIcon_fn.assert_called_once_with(icon) setIconSize_fn.assert_called_once_with(svg_size)
def test_SvgToggleButton_toggle(mocker): """ Make sure we're not calling this a toggle button for no reason. """ stb = SvgToggleButton(on='mock_on', off='mock_off') stb.toggle() assert stb.isChecked() is True stb.toggle() assert stb.isChecked() is False stb.toggle() assert stb.isChecked() is True