Minimal tests for User class
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
1595741e7a
commit
0aa34147f7
1 changed files with 45 additions and 0 deletions
45
test/test_user.py
Normal file
45
test/test_user.py
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
"""
|
||||||
|
Tests for the User class
|
||||||
|
"""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from datetime import datetime
|
||||||
|
from slixmpp import JID
|
||||||
|
from poezio.user import User
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def user1():
|
||||||
|
return User(
|
||||||
|
'nick1',
|
||||||
|
'member',
|
||||||
|
'xa',
|
||||||
|
'My Status!',
|
||||||
|
'moderator',
|
||||||
|
JID('foo@muc/nick1'),
|
||||||
|
False,
|
||||||
|
'red',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_new_user(user1):
|
||||||
|
assert user1.last_talked == datetime(1, 1, 1)
|
||||||
|
assert user1.jid == JID('foo@muc/nick1')
|
||||||
|
assert user1.chatstate is None
|
||||||
|
assert user1.affiliation == 'member'
|
||||||
|
assert user1.show == 'xa'
|
||||||
|
assert user1.status == 'My Status!'
|
||||||
|
assert user1.role == 'moderator'
|
||||||
|
assert user1.nick == 'nick1'
|
||||||
|
assert user1.color == (196, -1)
|
||||||
|
assert str(user1) == '>nick1<'
|
||||||
|
|
||||||
|
|
||||||
|
def test_change_nick(user1):
|
||||||
|
user1.change_nick('nick2')
|
||||||
|
assert user1.nick == 'nick2'
|
||||||
|
|
||||||
|
|
||||||
|
def test_change_color(user1):
|
||||||
|
user1.change_color('blue', deterministic=False)
|
||||||
|
assert user1.color == (21, -1)
|
Loading…
Reference in a new issue