Example #1
0
def test_logs_error_msg_when_platform_not_supported(mocker):
    mocker.patch('passpie.clipboard.platform.system', return_value='unknown')
    mock_logger = mocker.patch('passpie.clipboard.logger')

    clipboard.copy('text')
    assert mock_logger.error.called
    msg = "platform 'unknown' copy to clipboard not supported"
    mock_logger.error.assert_called_once_with(msg)
Example #2
0
def test_logs_error_msg_when_platform_not_supported(mocker):
    mocker.patch('passpie.clipboard.platform.system', return_value='unknown')
    mock_logger = mocker.patch('passpie.clipboard.logging')

    clipboard.copy('text')
    assert mock_logger.error.called
    msg = "platform 'unknown' copy to clipboard not supported"
    mock_logger.error.assert_called_once_with(msg)
Example #3
0
def test_copy_calls_copy_cygwin_when_on_cygwin_system(mocker):
    mocker.patch('passpie.clipboard.platform.system', return_value='cygwin system')
    mock_copy_cygwin = mocker.patch('passpie.clipboard._copy_cygwin')
    text = 's3cr3t'

    clipboard.copy(text)

    assert mock_copy_cygwin.called
    mock_copy_cygwin.assert_called_once_with(text)
Example #4
0
def test_copy_calls_copy_cygwin_when_on_cygwin_system(mocker):
    mocker.patch('passpie.clipboard.platform.system', return_value='cygwin system')
    mock_copy_cygwin = mocker.patch('passpie.clipboard._copy_cygwin')
    text = 's3cr3t'

    clipboard.copy(text)

    assert mock_copy_cygwin.called
    mock_copy_cygwin.assert_called_once_with(text, 0)
Example #5
0
def test_copy_calls_copy_windows_when_on_windows_system(mocker):
    mocker.patch('passpie.clipboard.Popen')
    mocker.patch('passpie.clipboard.platform.system', return_value='Windows')
    mock_copy_osx = mocker.patch('passpie.clipboard._copy_osx')
    mock_copy_linux = mocker.patch('passpie.clipboard._copy_linux')
    mock_copy_windows = mocker.patch('passpie.clipboard._copy_windows')

    clipboard.copy('text')

    assert mock_copy_windows.called is True
    assert mock_copy_osx.called is False
    assert mock_copy_linux.called is False
    mock_copy_windows.assert_called_once_with('text')
Example #6
0
def test_copy_calls_copy_windows_when_on_windows_system(mocker):
    mocker.patch('passpie.clipboard.process.call')
    mocker.patch('passpie.clipboard.platform.system', return_value='Windows')
    mock_copy_osx = mocker.patch('passpie.clipboard._copy_osx')
    mock_copy_linux = mocker.patch('passpie.clipboard._copy_linux')
    mock_copy_windows = mocker.patch('passpie.clipboard._copy_windows')

    clipboard.copy('text')

    assert mock_copy_windows.called is True
    assert mock_copy_osx.called is False
    assert mock_copy_linux.called is False
    mock_copy_windows.assert_called_once_with('text', 0)