def test_check_values(): log_list = logtolist.logtolist(logfilename) first_log_dict = log_list[0] assert first_log_dict['ip_address'] == '67.218.116.165' assert first_log_dict['timestamp'] == '30/Jan/2010:00:03:18 +0200' assert first_log_dict['request'] == 'GET /robots.txt HTTP/1.0'
def test_re_read_bad_line(mini_mini_file): log_list = logtolist(StringIO('abc def ghi\n')) assert len(log_list) == 1 first_log_dict = log_list[0] assert first_log_dict['ip_address'] == 'No IP address found' assert first_log_dict['timestamp'] == 'No timestamp found' assert first_log_dict['request'] == 'No request found'
def test_read_logs(): log_list = logtolist.logtolist(logfilename) assert len(log_list) == 206
def test_check_keys(): log_list = logtolist.logtolist(logfilename) assert set(log_list[0].keys()) == {'ip_address', 'timestamp', 'request'}
def all_are_dicts(): log_list = logtolist.logtolist(logfilename) assert all([type(x) is dict for x in log_list])
def got_a_list(): log_list = logtolist.logtolist(logfilename) assert type(log_list) is list
def test_re_all_are_dicts(mini_mini_file): log_list = logtolist(mini_mini_file) assert all([type(x) is dict for x in log_list])
def test_re_got_a_list(mini_mini_file): log_list = logtolist(mini_mini_file) assert type(log_list) is list
def test_re_read_logs(mini_mini_file): log_list = logtolist(mini_mini_file) assert len(log_list) == 10
def test_re_read_empty_line(mini_mini_file): log_list = logtolist(StringIO('\n')) assert len(log_list) == 0
def test_check_keys(mini_mini_file): log_list = logtolist(mini_mini_file) assert set(log_list[0].keys()) == {'ip_address', 'timestamp', 'request'}
def test_read_empty_file(): log_list = logtolist(StringIO('')) assert len(log_list) == 0 assert log_list == []