add tests for Clients-getter
This commit is contained in:
parent
d9f46e1b33
commit
3729ecf9c0
|
@ -1,22 +1,26 @@
|
||||||
from tsstats.client import Clients
|
import pytest
|
||||||
|
|
||||||
|
from tsstats.client import Client, Clients
|
||||||
|
|
||||||
clients = Clients()
|
clients = Clients()
|
||||||
clients += 1
|
cl1 = Client('1')
|
||||||
clients += 2
|
cl2 = Client('2')
|
||||||
clients += 'UID1'
|
clients += cl1
|
||||||
clients += 'UID2'
|
clients += cl2
|
||||||
|
uidcl1 = Client('UID1')
|
||||||
|
uidcl2 = Client('UID2')
|
||||||
|
clients += uidcl1
|
||||||
|
clients += uidcl2
|
||||||
|
|
||||||
|
|
||||||
def test_client_get():
|
def test_client_get():
|
||||||
'''
|
assert clients['1'] == cl1
|
||||||
Currently not testable because of tsstats.client.Clients add-behaviour
|
assert clients['2'] == cl2
|
||||||
'''
|
assert clients['UID1'] == uidcl1
|
||||||
pass
|
assert clients['UID2'] == uidcl2
|
||||||
|
with pytest.raises(KeyError):
|
||||||
|
clients['3']
|
||||||
def test_client_seperation():
|
clients['UID3']
|
||||||
assert len(clients.clients_by_id) == 2
|
|
||||||
assert len(clients.clients_by_uid) == 2
|
|
||||||
|
|
||||||
|
|
||||||
def test_client_repr():
|
def test_client_repr():
|
||||||
|
@ -27,6 +31,8 @@ def test_client_repr():
|
||||||
|
|
||||||
|
|
||||||
def test_clients_iter():
|
def test_clients_iter():
|
||||||
clients_length = len(clients.clients_by_id) + len(clients.clients_by_uid)
|
client_list = list(iter(clients))
|
||||||
clients_iter = [client for client in clients]
|
assert cl1 in client_list
|
||||||
assert len(clients_iter) == clients_length
|
assert cl2 in client_list
|
||||||
|
assert uidcl1 in client_list
|
||||||
|
assert uidcl2 in client_list
|
||||||
|
|
Loading…
Reference in New Issue