Add testcase for tsstats.utils.filter_threshold
This commit is contained in:
parent
5637a11b2b
commit
d522ce648a
|
@ -7,10 +7,10 @@ from bs4 import BeautifulSoup
|
||||||
|
|
||||||
from tsstats.log import _parse_details
|
from tsstats.log import _parse_details
|
||||||
from tsstats.template import render_template
|
from tsstats.template import render_template
|
||||||
from tsstats.utils import seconds_to_text
|
from tsstats.utils import filter_threshold, seconds_to_text, sort_clients
|
||||||
|
|
||||||
output_path = 'tsstats/tests/res/output.html'
|
output_path = 'tsstats/tests/res/output.html'
|
||||||
clients = _parse_details('tsstats/tests/res/test.log')
|
clients = _parse_details('tsstats/tests/res/test.log', online_dc=False)
|
||||||
|
|
||||||
logger = logging.getLogger('tsstats')
|
logger = logging.getLogger('tsstats')
|
||||||
|
|
||||||
|
@ -60,3 +60,11 @@ def test_onlinetime(soup):
|
||||||
# they're only used for bans and kicks)
|
# they're only used for bans and kicks)
|
||||||
assert nick_data[client.nick] == \
|
assert nick_data[client.nick] == \
|
||||||
seconds_to_text(int(client.onlinetime.total_seconds()))
|
seconds_to_text(int(client.onlinetime.total_seconds()))
|
||||||
|
|
||||||
|
|
||||||
|
def test_filter_threshold():
|
||||||
|
sorted_clients = sort_clients(
|
||||||
|
clients, lambda c: c.onlinetime.total_seconds())
|
||||||
|
assert len(filter_threshold(sorted_clients, -1)) == len(sorted_clients)
|
||||||
|
assert len(filter_threshold(sorted_clients, 20)) == 1
|
||||||
|
assert len(filter_threshold(sorted_clients, 500)) == 0
|
||||||
|
|
Loading…
Reference in New Issue