|
| 1 | +#!/usr/bin/env python |
| 2 | +# |
| 3 | +# A library that provides a Python interface to the Telegram Bot API |
| 4 | +# Copyright (C) 2015-2017 |
| 5 | +# Leandro Toledo de Souza <devs@python-telegram-bot.org> |
| 6 | +# |
| 7 | +# This program is free software: you can redistribute it and/or modify |
| 8 | +# it under the terms of the GNU Lesser Public License as published by |
| 9 | +# the Free Software Foundation, either version 3 of the License, or |
| 10 | +# (at your option) any later version. |
| 11 | +# |
| 12 | +# This program is distributed in the hope that it will be useful, |
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | +# GNU Lesser Public License for more details. |
| 16 | +# |
| 17 | +# You should have received a copy of the GNU Lesser Public License |
| 18 | +# along with this program. If not, see [http://www.gnu.org/licenses/]. |
| 19 | +from telegram import PhotoSize, UserProfilePhotos |
| 20 | + |
| 21 | + |
| 22 | +class TestUserProfilePhotos(object): |
| 23 | + total_count = 2 |
| 24 | + photos = [ |
| 25 | + [ |
| 26 | + PhotoSize('file_id1', 512, 512), |
| 27 | + PhotoSize('file_id2', 512, 512) |
| 28 | + ], |
| 29 | + [ |
| 30 | + PhotoSize('file_id3', 512, 512), |
| 31 | + PhotoSize('file_id4', 512, 512) |
| 32 | + ] |
| 33 | + ] |
| 34 | + |
| 35 | + def test_de_json(self, bot): |
| 36 | + json_dict = { |
| 37 | + 'total_count': 2, |
| 38 | + 'photos': [[y.to_dict() for y in x] for x in self.photos] |
| 39 | + } |
| 40 | + user_profile_photos = UserProfilePhotos.de_json(json_dict, bot) |
| 41 | + assert user_profile_photos.total_count == self.total_count |
| 42 | + assert user_profile_photos.photos == self.photos |
| 43 | + |
| 44 | + def test_to_dict(self): |
| 45 | + user_profile_photos = UserProfilePhotos(self.total_count, self.photos) |
| 46 | + user_profile_photos_dict = user_profile_photos.to_dict() |
| 47 | + assert user_profile_photos_dict['total_count'] == user_profile_photos.total_count |
| 48 | + for ix, x in enumerate(user_profile_photos_dict['photos']): |
| 49 | + for iy, y in enumerate(x): |
| 50 | + assert y == user_profile_photos.photos[ix][iy].to_dict() |
0 commit comments