From 09ef24667d17d2f71453d437aa9f53af7066c09b Mon Sep 17 00:00:00 2001 From: Thor77 Date: Fri, 28 Aug 2015 13:47:03 +0200 Subject: [PATCH] add broken-log and iter-clients-test --- tests/res/test.log.broken | 2 ++ tests/test_general.py | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 tests/res/test.log.broken diff --git a/tests/res/test.log.broken b/tests/res/test.log.broken new file mode 100644 index 0000000..35ea44f --- /dev/null +++ b/tests/res/test.log.broken @@ -0,0 +1,2 @@ +2015-05-18 16:00:14.951191|INFO |VirtualServerBase| 3| client disconnected 'Client1'(id:1) reason 'reasonmsg=ByeBye!' +2015-05-18 15:55:23.456679|INFO |VirtualServerBase| 3| client connected 'Client1'(id:1) from 1.2.3.4:1234 diff --git a/tests/test_general.py b/tests/test_general.py index b53e88e..1b2aca0 100644 --- a/tests/test_general.py +++ b/tests/test_general.py @@ -59,3 +59,14 @@ def test_debug_log(): clients = parse_logs('tests/res/test.log', file_log=True) open('debug.txt') remove('debug.txt') + + +@raises(exceptions.InvalidLog) +def test_parse_broken(): + clients = parse_logs('tests/res/test.log.broken') + + +def test_iter_clients(): + clients_length = len(clients.clients_by_id) + len(clients.clients_by_uid) + clients_iter = [client for client in clients] + assert len(clients_iter) == clients_length