add test for tsstats.log._bundle_logs
This commit is contained in:
parent
105f464b9a
commit
976d40e2b9
|
@ -1,17 +1,17 @@
|
|||
from datetime import timedelta
|
||||
from datetime import datetime, timedelta
|
||||
from time import sleep
|
||||
|
||||
import pytest
|
||||
|
||||
from tsstats.exceptions import InvalidLog
|
||||
from tsstats.log import parse_log, parse_logs
|
||||
from tsstats.log import TimedLog, _bundle_logs, _parse_details
|
||||
|
||||
testlog_path = 'tsstats/tests/res/test.log'
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def clients():
|
||||
return parse_log(testlog_path, online_dc=False)
|
||||
return _parse_details(testlog_path, online_dc=False)
|
||||
|
||||
|
||||
def test_log_client_count(clients):
|
||||
|
@ -39,6 +39,32 @@ def test_log_pbans(clients):
|
|||
assert clients['2'].pbans == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize("logs,bundled", [
|
||||
(
|
||||
['l1.log', 'l2.log'],
|
||||
{'': [TimedLog('l1.log', None), TimedLog('l2.log', None)]}
|
||||
),
|
||||
(
|
||||
[
|
||||
'ts3server_2016-06-06__14_22_09.527229_1.log',
|
||||
'ts3server_2017-07-07__15_23_10.638340_1.log'
|
||||
],
|
||||
{
|
||||
'1': [
|
||||
TimedLog('ts3server_2016-06-06__14_22_09.527229_1.log',
|
||||
datetime(year=2016, month=6, day=6, hour=14,
|
||||
minute=22, second=9, microsecond=527229)),
|
||||
TimedLog('ts3server_2017-07-07__15_23_10.638340_1.log',
|
||||
datetime(year=2017, month=7, day=7, hour=15,
|
||||
minute=23, second=10, microsecond=638340))
|
||||
]
|
||||
}
|
||||
)
|
||||
])
|
||||
def test_log_bundle(logs, bundled):
|
||||
assert _bundle_logs(logs) == bundled
|
||||
|
||||
|
||||
def test_log_invalid():
|
||||
with pytest.raises(InvalidLog):
|
||||
parse_log('tsstats/tests/res/test.log.broken')
|
||||
|
|
Loading…
Reference in New Issue