Example #1
0
def test_connection_error():
    mock_client = MagicMock()
    mock_client.return_value.id.side_effect = ConnectionError('boo!')

    with patch('ipwb.util.ipfs_client', mock_client):
        with pytest.raises(Exception, match='Daemon is not running at'):
            check_daemon_is_alive()
Example #2
0
def test_os_error():
    mock_client = MagicMock()
    mock_client.return_value.id.side_effect = OSError('foo!')

    with patch('ipwb.util.ipfs_client', mock_client):
        with pytest.raises(Exception, match='IPFS is likely not installed'):
            check_daemon_is_alive()
Example #3
0
def test_unknown_error():
    mock_client = MagicMock()
    mock_client.return_value.id.side_effect = Exception('foo!')
    expected_error = 'Unknown error in retrieving IPFS daemon status.'

    with patch('ipwb.util.ipfs_client', mock_client):
        with pytest.raises(Exception, match=expected_error):
            check_daemon_is_alive()
Example #4
0
def checkArgs_index(args):
    util.check_daemon_is_alive()

    encKey = None
    compression_level = None
    if args.e:
        encKey = ''
    if args.c:
        compression_level = 6  # Magic 6, TA-DA!

    indexer.index_file_at(args.warc_path, encKey, compression_level,
                          args.compressFirst, outfile=args.outfile,
                          debug=args.debug)
Example #5
0
def test_is_alive():
    mock_client = MagicMock()

    with patch('ipwb.util.ipfs_client', mock_client):
        assert check_daemon_is_alive() is True