From fde3a921f990207ab2aa9d3bf7cac9f8ff91d0de Mon Sep 17 00:00:00 2001 From: Thor77 Date: Fri, 10 Jun 2016 16:45:41 +0200 Subject: [PATCH] refactor tsstats.tests.test_template.test_onlinetime * check client-count in template * take clients as base instead for comparisons * dynamically check all included client-objects TODO ==== * move nick_data-dict-generation into function or fixture * split tsstats.client.Clients into id and uuid-clients to easily compare client- and template-data --- tsstats/tests/test_template.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tsstats/tests/test_template.py b/tsstats/tests/test_template.py index ab6999d..a521182 100644 --- a/tsstats/tests/test_template.py +++ b/tsstats/tests/test_template.py @@ -43,5 +43,19 @@ def test_debug(output): def test_onlinetime(soup): - assert seconds_to_text(clients['1'].onlinetime) == \ - soup.find('span', class_='badge').text + # move this into a (parameterized) fixture or function + items = soup.find('ul', id='onlinetime').find_all('li') + nick_data = {} + for item in items: + nick, data = item.find_all('span') + nick_data[nick.text] = data.text + # seperate between uuid and id-clients or merge them some way + # => assert len(items) == len(clients.id) + assert len(items) == 2 + for client in clients: + if client.nick in nick_data and client.onlinetime > 0: + # remove this clause after splitting cients + # (uuid-clients will never have a online-time, because + # they're only used for bans and kicks) + assert nick_data[client.nick] == \ + seconds_to_text(client.onlinetime)