@@ -35,8 +35,9 @@ def json_dict():
35
35
36
36
@pytest .fixture (scope = 'function' )
37
37
def user (bot ):
38
- return User (TestUser .id , TestUser .first_name , TestUser .is_bot , last_name = TestUser .last_name ,
39
- username = TestUser .username , language_code = TestUser .language_code , bot = bot )
38
+ return User (id = TestUser .id , first_name = TestUser .first_name , is_bot = TestUser .is_bot ,
39
+ last_name = TestUser .last_name , username = TestUser .username ,
40
+ language_code = TestUser .language_code , bot = bot )
40
41
41
42
42
43
class TestUser (object ):
@@ -164,6 +165,22 @@ def test(*args, **kwargs):
164
165
monkeypatch .setattr ('telegram.Bot.send_voice' , test )
165
166
assert user .send_voice ('test_voice' )
166
167
168
+ def test_mention_html (self , user ):
169
+ expected = u'<a href="tg://user?id={}">{}</a>'
170
+
171
+ assert user .mention_html () == expected .format (user .id , user .full_name )
172
+ assert user .mention_html ('the<b>name\u2022 ' ) == expected .format (user .id ,
173
+ 'the<b>name\u2022 ' )
174
+ assert user .mention_html (user .username ) == expected .format (user .id , user .username )
175
+
176
+ def test_mention_markdown (self , user ):
177
+ expected = u'[{}](tg://user?id={})'
178
+
179
+ assert user .mention_markdown () == expected .format (user .full_name , user .id )
180
+ assert user .mention_markdown ('the_name*\u2022 ' ) == expected .format ('the\_name\*\u2022 ' ,
181
+ user .id )
182
+ assert user .mention_markdown (user .username ) == expected .format (user .username , user .id )
183
+
167
184
def test_equality (self ):
168
185
a = User (self .id , self .first_name , self .is_bot , self .last_name )
169
186
b = User (self .id , self .first_name , self .is_bot , self .last_name )
0 commit comments