def test_parse_file(logger_queue_name, logger_queue, log_sample, tmpdir): log, entries = log_sample with tmpdir.join('log.txt').open('w') as f: f.write(log) main(['--log-queue', logger_queue_name, str(tmpdir.join('log.txt'))]) for log_msg, entry in entries: assert logger_queue.recv_msg() == (log_msg, entry)
def test_parse_compressed(logger_queue_name, logger_queue, log_sample, tmpdir): log, entries = log_sample with tmpdir.join('log.gz').open('wb') as f: f.write(gzip.compress(log.encode('ascii'))) main(['--log-queue', logger_queue_name, str(tmpdir.join('log.gz'))]) for log_msg, entry in entries: assert logger_queue.recv_msg() == (log_msg, entry)
def test_parse_file(logger_queue_name, logger_queue, log_sample, tmpdir): log, downloads = log_sample with tmpdir.join('log.txt').open('w') as f: f.write(log) main(['--log-queue', logger_queue_name, str(tmpdir.join('log.txt'))]) for download in downloads: assert logger_queue.recv_msg() == ('LOG', download)
def test_parse_stdin(logger_queue_name, logger_queue, log_sample): log, entries = log_sample with mock.patch('sys.stdin', io.StringIO(log)): main(['--log-queue', logger_queue_name]) for log_msg, entry in entries: assert logger_queue.recv_msg() == (log_msg, entry)
def test_version(capsys): with pytest.raises(SystemExit): main(['--version']) out, err = capsys.readouterr() assert out.strip() == __version__
def test_help(capsys): with pytest.raises(SystemExit): main(['--help']) out, err = capsys.readouterr() assert out.startswith('usage:') assert '--drop' in out
def test_parse_stdin(logger_queue_name, logger_queue, log_sample): log, downloads = log_sample with mock.patch('sys.stdin', io.StringIO(log)): main(['--log-queue', logger_queue_name]) for download in downloads: assert logger_queue.recv_msg() == ('LOG', download)