diff --git a/tsstats/tests/res/test.log.identmap_wrong_identifier b/tsstats/tests/res/test.log.identmap_wrong_identifier new file mode 100644 index 0000000..3ad89fb --- /dev/null +++ b/tsstats/tests/res/test.log.identmap_wrong_identifier @@ -0,0 +1,7 @@ +2017-03-28 01:00:00.000000|INFO |VirtualServer| 1| listening on 0.0.0.0:9987 +2017-03-28 03:00:00.000000|INFO |VirtualServerBase| 2| client connected 'Client1'(id:2) from 1.2.3.4:1234 +2017-03-28 04:00:00.000000|INFO |VirtualServerBase| 2| client disconnected 'Client1'(id:2) reason 'reasonmsg=ByeBye!' +2017-03-28 01:00:00.000000|INFO |VirtualServerBase| 2| client connected 'Client1'(id:1) from 1.2.3.4:1234 +2017-03-28 02:00:00.000000|INFO |VirtualServerBase| 2| client disconnected 'Client1'(id:1) reason 'reasonmsg=ByeBye!' +2017-03-28 05:00:00.000000|INFO |VirtualServerBase| 2| client connected 'Client1'(id:3) from 1.2.3.4:1234 +2017-03-28 06:00:00.000000|INFO |VirtualServerBase| 2| client disconnected 'Client1'(id:3) reason 'reasonmsg=ByeBye!' diff --git a/tsstats/tests/test_ident_map.py b/tsstats/tests/test_ident_map.py index e1cb26d..4aa63c6 100644 --- a/tsstats/tests/test_ident_map.py +++ b/tsstats/tests/test_ident_map.py @@ -1,6 +1,7 @@ import pytest from tsstats.client import Client, Clients +from tsstats.log import _parse_details from tsstats.utils import transform_pretty_identmap @@ -51,3 +52,17 @@ def test_transform_pretty_identmap(test_input, expected): transformed_identmap = transform_pretty_identmap(test_input) for alternate, primary in expected: assert transformed_identmap[alternate] == primary + + +def test_ident_map_wrong_identifier(): + clients = _parse_details( + 'tsstats/tests/res/test.log.identmap_wrong_identifier', ident_map={ + '2': '1', + '3': '1' + } + ) + client = clients.get('1') + # assert client exists + assert client + # assert correct identifier + assert client.identifier == '1'