summaryrefslogtreecommitdiff
path: root/test/test_user.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-05-28 18:32:31 +0200
committermathieui <mathieui@mathieui.net>2020-05-28 18:32:31 +0200
commitf670e3ce3b8d69a9fde71301e156f936aaee6fd8 (patch)
tree45002211b05e2b56943e7af4a97eb2d7f4b1d0d4 /test/test_user.py
parent1595741e7aaaeda282283530e7ab8cd72cdc4078 (diff)
parent0aa34147f774fc1a6bc454b9b4e9028024e7a932 (diff)
downloadpoezio-f670e3ce3b8d69a9fde71301e156f936aaee6fd8.tar.gz
poezio-f670e3ce3b8d69a9fde71301e156f936aaee6fd8.tar.bz2
poezio-f670e3ce3b8d69a9fde71301e156f936aaee6fd8.tar.xz
poezio-f670e3ce3b8d69a9fde71301e156f936aaee6fd8.zip
Merge branch 'tests-user' into 'master'
Minimal tests for User class See merge request poezio/poezio!134
Diffstat (limited to 'test/test_user.py')
-rw-r--r--test/test_user.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/test_user.py b/test/test_user.py
new file mode 100644
index 00000000..a462f45b
--- /dev/null
+++ b/test/test_user.py
@@ -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)