def test_equality(self): a = ChatPhoto( self.chatphoto_small_file_id, self.chatphoto_big_file_id, self.chatphoto_small_file_unique_id, self.chatphoto_big_file_unique_id, ) b = ChatPhoto( self.chatphoto_small_file_id, self.chatphoto_big_file_id, self.chatphoto_small_file_unique_id, self.chatphoto_big_file_unique_id, ) c = ChatPhoto( '', '', self.chatphoto_small_file_unique_id, self.chatphoto_big_file_unique_id ) d = ChatPhoto('', '', 0, 0) e = Voice(self.chatphoto_small_file_id, self.chatphoto_small_file_unique_id, 0) assert a == b assert hash(a) == hash(b) assert a is not b assert a != c assert hash(a) != hash(c) assert a != d assert hash(a) != hash(d) assert a != e assert hash(a) != hash(e)
def de_json(cls, data, bot): if not data: return None data['photo'] = ChatPhoto.de_json(data.get('photo'), bot) return cls(bot=bot, **data)
def de_json(cls, data, bot): if not data: return None data['photo'] = ChatPhoto.de_json(data.get('photo'), bot) return cls(bot=bot, **data)
def de_json(cls, data, bot): if not data: return None data['photo'] = ChatPhoto.de_json(data.get('photo'), bot) from telegram import Message data['pinned_message'] = Message.de_json(data.get('pinned_message'), bot) return cls(bot=bot, **data)
def de_json(cls, data, bot): if not data: return None data['photo'] = ChatPhoto.de_json(data.get('photo'), bot) from telegram import Message data['pinned_message'] = Message.de_json(data.get('pinned_message'), bot) return cls(bot=bot, **data)
def test_de_json(self, bot, chat_photo): json_dict = { 'small_file_id': self.chatphoto_small_file_id, 'big_file_id': self.chatphoto_big_file_id, 'small_file_unique_id': self.chatphoto_small_file_unique_id, 'big_file_unique_id': self.chatphoto_big_file_unique_id, } chat_photo = ChatPhoto.de_json(json_dict, bot) assert chat_photo.small_file_id == self.chatphoto_small_file_id assert chat_photo.big_file_id == self.chatphoto_big_file_id assert chat_photo.small_file_unique_id == self.chatphoto_small_file_unique_id assert chat_photo.big_file_unique_id == self.chatphoto_big_file_unique_id
def de_json(cls, data: JSONDict, bot: 'Bot') -> Optional['Chat']: data = cls.parse_data(data) if not data: return None data['photo'] = ChatPhoto.de_json(data.get('photo'), bot) from telegram import Message data['pinned_message'] = Message.de_json(data.get('pinned_message'), bot) data['permissions'] = ChatPermissions.de_json(data.get('permissions'), bot) return cls(bot=bot, **data)
def de_json(cls, data, bot): if not data: return None data['photo'] = ChatPhoto.de_json(data.get('photo'), bot) from telegram import Message pinned_message = data.get('pinned_message') if pinned_message: pinned_message['default_quote'] = data.get('default_quote') data['pinned_message'] = Message.de_json(pinned_message, bot) data['permissions'] = ChatPermissions.de_json(data.get('permissions'), bot) return cls(bot=bot, **data)
def de_json(data, bot): """ Args: data (dict): bot (telegram.Bot): Returns: telegram.Chat: """ if not data: return None data['photo'] = ChatPhoto.de_json(data.get('photo'), bot) return Chat(bot=bot, **data)