From c86af0bed308efd8f8099233dbd5e41ef4616fd1 Mon Sep 17 00:00:00 2001 From: Thor77 Date: Mon, 22 May 2017 18:40:25 +0200 Subject: [PATCH] Replace datetime/timedelta with pendulum in tests --- tsstats/tests/test_log.py | 28 ++++++++++++++++++---------- tsstats/tests/test_template.py | 6 +++--- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/tsstats/tests/test_log.py b/tsstats/tests/test_log.py index b8beb72..785aee8 100644 --- a/tsstats/tests/test_log.py +++ b/tsstats/tests/test_log.py @@ -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 + ) + ) ] } ) diff --git a/tsstats/tests/test_template.py b/tsstats/tests/test_template.py index f7422d3..8e99b79 100644 --- a/tsstats/tests/test_template.py +++ b/tsstats/tests/test_template.py @@ -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