Use parse_logs instead of _parse_details

This commit is contained in:
Thor77 2017-09-10 00:04:11 +02:00
parent cbc76b5541
commit b1b80f657a
1 changed files with 7 additions and 12 deletions

View File

@ -1,7 +1,7 @@
import pendulum import pendulum
import pytest import pytest
from tsstats.log import TimedLog, _bundle_logs, _parse_details, parse_logs from tsstats.log import TimedLog, _bundle_logs, parse_logs
from tsstats.template import render_servers from tsstats.template import render_servers
testlog_path = 'tsstats/tests/res/test.log' testlog_path = 'tsstats/tests/res/test.log'
@ -9,7 +9,7 @@ testlog_path = 'tsstats/tests/res/test.log'
@pytest.fixture @pytest.fixture
def clients(): def clients():
return _parse_details(testlog_path, online_dc=False) return list(parse_logs(testlog_path, online_dc=False))[0].clients
def test_log_client_count(clients): def test_log_client_count(clients):
@ -77,22 +77,17 @@ def test_log_client_online():
current_time = pendulum.now() current_time = pendulum.now()
pendulum.set_test_now(current_time) pendulum.set_test_now(current_time)
clients = _parse_details(testlog_path) clients = list(parse_logs(testlog_path))[0].clients
old_onlinetime = int(clients['1'].onlinetime.total_seconds()) old_onlinetime = int(clients['1'].onlinetime.total_seconds())
pendulum.set_test_now(current_time.add(seconds=2)) # add 2s to .now() pendulum.set_test_now(current_time.add(seconds=2)) # add 2s to .now()
clients = _parse_details(testlog_path) clients = list(parse_logs(testlog_path))[0].clients
assert int(clients['1'].onlinetime.total_seconds()) == old_onlinetime + 2 assert int(clients['1'].onlinetime.total_seconds()) == old_onlinetime + 2
def test_parse_logs():
assert len(_parse_details(testlog_path)) ==\
len(parse_logs(testlog_path)[0].clients)
def test_parse_groups(): def test_parse_groups():
clients = _parse_details('tsstats/tests/res/test.log.groups') server = list(parse_logs('tsstats/tests/res/test.log.groups'))
assert len(clients) == 0 assert len(server) == 0
def test_parse_utf8(output): def test_parse_utf8(output):
@ -101,6 +96,6 @@ def test_parse_utf8(output):
def test_server_stop(): def test_server_stop():
clients = _parse_details('tsstats/tests/res/test.log.stopped') clients = list(parse_logs('tsstats/tests/res/test.log.stopped'))[0].clients
assert clients['1'].onlinetime.seconds / 60 == 20 # minutes assert clients['1'].onlinetime.seconds / 60 == 20 # minutes
assert clients['2'].onlinetime.seconds / 60 == 10 # minutes assert clients['2'].onlinetime.seconds / 60 == 10 # minutes