Add testcase for wrong identifier with identmap
If a client connects with a secondary identifier first, this one is used as the identifier for the Client-object instead of the primary one.
This commit is contained in:
parent
6e662e2555
commit
683f9b984a
|
@ -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!'
|
|
@ -1,6 +1,7 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tsstats.client import Client, Clients
|
from tsstats.client import Client, Clients
|
||||||
|
from tsstats.log import _parse_details
|
||||||
from tsstats.utils import transform_pretty_identmap
|
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)
|
transformed_identmap = transform_pretty_identmap(test_input)
|
||||||
for alternate, primary in expected:
|
for alternate, primary in expected:
|
||||||
assert transformed_identmap[alternate] == primary
|
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'
|
||||||
|
|
Loading…
Reference in New Issue