Replace datetime/timedelta with pendulum in tests

This commit is contained in:
Thor77 2017-05-22 18:40:25 +02:00
parent a781382a39
commit c86af0bed3
2 changed files with 21 additions and 13 deletions

View File

@ -1,5 +1,3 @@
from datetime import datetime, timedelta
import pendulum
import pytest
@ -20,8 +18,10 @@ def test_log_client_count(clients):
def test_log_onlinetime(clients):
assert clients['1'].onlinetime == timedelta(0, 402, 149208)
assert clients['2'].onlinetime == timedelta(0, 19, 759644)
assert clients['1'].onlinetime == pendulum.Interval(
seconds=402, microseconds=149208)
assert clients['2'].onlinetime == pendulum.Interval(
seconds=19, microseconds=759644)
def test_log_kicks(clients):
@ -52,12 +52,20 @@ def test_log_pbans(clients):
],
{
'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))
TimedLog(
'ts3server_2016-06-06__14_22_09.527229_1.log',
pendulum.create(
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',
pendulum.create(
year=2017, month=7, day=7, hour=15, minute=23,
second=10, microsecond=638340
)
)
]
}
)

View File

@ -1,9 +1,9 @@
import logging
from datetime import timedelta
import pendulum
import pytest
from bs4 import BeautifulSoup
from bs4 import BeautifulSoup
from tsstats.log import Server, _parse_details
from tsstats.template import render_servers
from tsstats.utils import filter_threshold, seconds_to_text, sort_clients
@ -44,7 +44,7 @@ def test_onlinetime(soup):
onlinetime = onlinetime.text
# find corresponding client-object
client = list(filter(
lambda c: c.nick == nick and c.onlinetime > timedelta(0),
lambda c: c.nick == nick and c.onlinetime > pendulum.Interval(),
clients
))
# assert existence