Exemple #1
0
def test_SourceWidget_update_unstarred():
    """
    Ensure the widget displays the expected details from the source.
    """
    mock_source = mock.MagicMock()
    mock_source.journalist_designation = 'foo bar baz'
    mock_source.is_starred = False
    sw = SourceWidget(None, mock_source)
    sw.name = mock.MagicMock()
    with mock.patch('securedrop_client.gui.widgets.load_svg') as mock_load:
        sw.update()
        mock_load.assert_called_once_with('star_off.svg')
    sw.name.setText.assert_called_once_with('<strong>foo bar baz</strong>')
Exemple #2
0
def test_SourceWidget_update_attachment_icon():
    """
    Attachment icon identicates document count
    """
    source = factory.Source(document_count=1)
    sw = SourceWidget(None, source)

    sw.update()
    assert not sw.attached.isHidden()

    source.document_count = 0

    sw.update()
    assert sw.attached.isHidden()
Exemple #3
0
def test_SourceWidget_html_init(mocker):
    """
    The source widget is initialised with the given source name, with
    HTML escaped properly.
    """
    mock_source = mocker.MagicMock()
    mock_source.journalist_designation = 'foo <b>bar</b> baz'

    sw = SourceWidget(None, mock_source)
    sw.name = mocker.MagicMock()
    sw.summary_layout = mocker.MagicMock()

    mocker.patch('securedrop_client.gui.widgets.load_svg')
    sw.update()

    sw.name.setText.assert_called_once_with(
        '<strong>foo &lt;b&gt;bar&lt;/b&gt; baz</strong>')