2525@pytest .fixture (scope = 'class' )
2626def contact ():
2727 return Contact (TestContact .phone_number , TestContact .first_name , TestContact .last_name ,
28- TestContact .user_id )
28+ TestContact .user_id , TestContact . vcard )
2929
3030
3131class TestContact (object ):
3232 phone_number = '+11234567890'
3333 first_name = 'Leandro'
3434 last_name = 'Toledo'
3535 user_id = 23
36+ vcard = 'vCard'
3637
3738 def test_de_json_required (self , bot ):
3839 json_dict = {'phone_number' : self .phone_number , 'first_name' : self .first_name }
@@ -43,20 +44,23 @@ def test_de_json_required(self, bot):
4344
4445 def test_de_json_all (self , bot ):
4546 json_dict = {'phone_number' : self .phone_number , 'first_name' : self .first_name ,
46- 'last_name' : self .last_name , 'user_id' : self .user_id }
47+ 'last_name' : self .last_name , 'user_id' : self .user_id ,
48+ 'vcard' : self .vcard }
4749 contact = Contact .de_json (json_dict , bot )
4850
4951 assert contact .phone_number == self .phone_number
5052 assert contact .first_name == self .first_name
5153 assert contact .last_name == self .last_name
5254 assert contact .user_id == self .user_id
55+ assert contact .vcard == self .vcard
5356
5457 def test_send_with_contact (self , monkeypatch , bot , chat_id , contact ):
5558 def test (_ , url , data , ** kwargs ):
5659 phone = data ['phone_number' ] == contact .phone_number
5760 first = data ['first_name' ] == contact .first_name
5861 last = data ['last_name' ] == contact .last_name
59- return phone and first and last
62+ vcard = data ['vcard' ] == contact .vcard
63+ return phone and first and last and vcard
6064
6165 monkeypatch .setattr ('telegram.utils.request.Request.post' , test )
6266 message = bot .send_contact (contact = contact , chat_id = chat_id )
@@ -74,6 +78,7 @@ def test_to_dict(self, contact):
7478 assert contact_dict ['first_name' ] == contact .first_name
7579 assert contact_dict ['last_name' ] == contact .last_name
7680 assert contact_dict ['user_id' ] == contact .user_id
81+ assert contact_dict ['vcard' ] == contact .vcard
7782
7883 def test_equality (self ):
7984 a = Contact (self .phone_number , self .first_name )
0 commit comments