2525
2626@pytest .fixture (scope = 'class' )
2727def chat (bot ):
28- return Chat (TestChat .id , TestChat .title , TestChat .type ,
28+ return Chat (TestChat .id , TestChat .title , TestChat .type , username = TestChat . username ,
2929 all_members_are_administrators = TestChat .all_members_are_administrators ,
3030 bot = bot , sticker_set_name = TestChat .sticker_set_name ,
3131 can_set_sticker_set = TestChat .can_set_sticker_set )
@@ -35,6 +35,7 @@ class TestChat(object):
3535 id = - 28767330
3636 title = 'ToledosPalaceBot - Group'
3737 type = 'group'
38+ username = 'username'
3839 all_members_are_administrators = False
3940 sticker_set_name = 'stickers'
4041 can_set_sticker_set = False
@@ -44,6 +45,7 @@ def test_de_json(self, bot):
4445 'id' : self .id ,
4546 'title' : self .title ,
4647 'type' : self .type ,
48+ 'username' : self .username ,
4749 'all_members_are_administrators' : self .all_members_are_administrators ,
4850 'sticker_set_name' : self .sticker_set_name ,
4951 'can_set_sticker_set' : self .can_set_sticker_set
@@ -53,6 +55,7 @@ def test_de_json(self, bot):
5355 assert chat .id == self .id
5456 assert chat .title == self .title
5557 assert chat .type == self .type
58+ assert chat .username == self .username
5659 assert chat .all_members_are_administrators == self .all_members_are_administrators
5760 assert chat .sticker_set_name == self .sticker_set_name
5861 assert chat .can_set_sticker_set == self .can_set_sticker_set
@@ -64,8 +67,14 @@ def test_to_dict(self, chat):
6467 assert chat_dict ['id' ] == chat .id
6568 assert chat_dict ['title' ] == chat .title
6669 assert chat_dict ['type' ] == chat .type
70+ assert chat_dict ['username' ] == chat .username
6771 assert chat_dict ['all_members_are_administrators' ] == chat .all_members_are_administrators
6872
73+ def test_link (self , chat ):
74+ assert chat .link == 'https://t.me/{}' .format (chat .username )
75+ chat .username = None
76+ assert chat .link is None
77+
6978 def test_send_action (self , monkeypatch , chat ):
7079 def test (* args , ** kwargs ):
7180 id = args [1 ] == chat .id
0 commit comments