X Tutup
Skip to content

Commit 4c0737d

Browse files
committed
Moving InlineQuery* classes to its own test files
1 parent 5dd95f1 commit 4c0737d

File tree

6 files changed

+441
-346
lines changed

6 files changed

+441
-346
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env python
2+
#
3+
# A library that provides a Python interface to the Telegram Bot API
4+
# Copyright (C) 2015-2016
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 General 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 General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see [http://www.gnu.org/licenses/].
19+
20+
"""This module contains a object that represents Tests for Telegram
21+
InlineQueryResultArticle"""
22+
23+
import sys
24+
25+
if sys.version_info[0:2] == (2, 6):
26+
import unittest2 as unittest
27+
else:
28+
import unittest
29+
30+
sys.path.append('.')
31+
32+
import telegram
33+
from tests.base import BaseTest
34+
35+
36+
class InlineQueryResultArticleTest(BaseTest, unittest.TestCase):
37+
"""This object represents Tests for Telegram InlineQueryResultArticle."""
38+
39+
def setUp(self):
40+
self.id = 'id'
41+
self.type = 'article'
42+
self.title = 'title'
43+
self.url = 'url'
44+
self.hide_url = True
45+
self.description = 'description'
46+
self.thumb_url = 'thumb url'
47+
self.thumb_height = 10
48+
self.thumb_width = 15
49+
50+
self.json_dict = {
51+
'type': self.type,
52+
'id': self.id,
53+
'title': self.title,
54+
'url': self.url,
55+
'hide_url': self.hide_url,
56+
'description': self.description,
57+
'thumb_url': self.thumb_url,
58+
'thumb_height': self.thumb_height,
59+
'thumb_width': self.thumb_width
60+
}
61+
62+
def test_article_de_json(self):
63+
article = telegram.InlineQueryResultArticle.de_json(self.json_dict)
64+
65+
self.assertEqual(article.type, self.type)
66+
self.assertEqual(article.id, self.id)
67+
self.assertEqual(article.title, self.title)
68+
self.assertEqual(article.url, self.url)
69+
self.assertEqual(article.hide_url, self.hide_url)
70+
self.assertEqual(article.description, self.description)
71+
self.assertEqual(article.thumb_url, self.thumb_url)
72+
self.assertEqual(article.thumb_height, self.thumb_height)
73+
self.assertEqual(article.thumb_width, self.thumb_width)
74+
75+
def test_article_to_json(self):
76+
article = telegram.InlineQueryResultArticle.de_json(self.json_dict)
77+
78+
self.assertTrue(self.is_json(article.to_json()))
79+
80+
def test_article_to_dict(self):
81+
article = \
82+
telegram.InlineQueryResultArticle.de_json(self.json_dict).to_dict()
83+
84+
self.assertTrue(self.is_dict(article))
85+
self.assertDictEqual(self.json_dict, article)
86+
87+
88+
if __name__ == '__main__':
89+
unittest.main()

tests/test_inlinequeryresultgif.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env python
2+
#
3+
# A library that provides a Python interface to the Telegram Bot API
4+
# Copyright (C) 2015-2016
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 General 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 General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see [http://www.gnu.org/licenses/].
19+
20+
"""This module contains a object that represents Tests for Telegram
21+
InlineQueryResultGif"""
22+
23+
import sys
24+
25+
if sys.version_info[0:2] == (2, 6):
26+
import unittest2 as unittest
27+
else:
28+
import unittest
29+
30+
sys.path.append('.')
31+
32+
import telegram
33+
from tests.base import BaseTest
34+
35+
36+
class InlineQueryResultGifTest(BaseTest, unittest.TestCase):
37+
"""This object represents Tests for Telegram InlineQueryResultGif."""
38+
39+
def setUp(self):
40+
self.id = 'id'
41+
self.type = 'gif'
42+
self.gif_url = 'gif url'
43+
self.gif_width = 10
44+
self.gif_height = 15
45+
self.thumb_url = 'thumb url'
46+
self.title = 'title'
47+
self.caption = 'caption'
48+
49+
self.json_dict = {
50+
'type': self.type,
51+
'id': self.id,
52+
'gif_url': self.gif_url,
53+
'gif_width': self.gif_width,
54+
'gif_height': self.gif_height,
55+
'thumb_url': self.thumb_url,
56+
'title': self.title,
57+
'caption': self.caption,
58+
}
59+
60+
def test_gif_de_json(self):
61+
gif = telegram.InlineQueryResultGif.de_json(self.json_dict)
62+
63+
self.assertEqual(gif.type, self.type)
64+
self.assertEqual(gif.id, self.id)
65+
self.assertEqual(gif.gif_url, self.gif_url)
66+
self.assertEqual(gif.gif_width, self.gif_width)
67+
self.assertEqual(gif.gif_height, self.gif_height)
68+
self.assertEqual(gif.thumb_url, self.thumb_url)
69+
self.assertEqual(gif.title, self.title)
70+
self.assertEqual(gif.caption, self.caption)
71+
72+
def test_gif_to_json(self):
73+
gif = telegram.InlineQueryResultGif.de_json(self.json_dict)
74+
75+
self.assertTrue(self.is_json(gif.to_json()))
76+
77+
def test_gif_to_dict(self):
78+
gif = telegram.InlineQueryResultGif.de_json(self.json_dict).to_dict()
79+
80+
self.assertTrue(self.is_dict(gif))
81+
self.assertDictEqual(self.json_dict, gif)
82+
83+
84+
if __name__ == '__main__':
85+
unittest.main()
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env python
2+
#
3+
# A library that provides a Python interface to the Telegram Bot API
4+
# Copyright (C) 2015-2016
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 General 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 General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see [http://www.gnu.org/licenses/].
19+
20+
"""This module contains a object that represents Tests for Telegram
21+
InlineQueryResultMpeg4Gif"""
22+
23+
import sys
24+
25+
if sys.version_info[0:2] == (2, 6):
26+
import unittest2 as unittest
27+
else:
28+
import unittest
29+
30+
sys.path.append('.')
31+
32+
import telegram
33+
from tests.base import BaseTest
34+
35+
36+
class InlineQueryResultMpeg4GifTest(BaseTest, unittest.TestCase):
37+
"""This object represents Tests for Telegram InlineQueryResultMpeg4Gif."""
38+
39+
def setUp(self):
40+
self.id = 'id'
41+
self.type = 'mpeg4_gif'
42+
self.mpeg4_url = 'mpeg4 url'
43+
self.mpeg4_width = 10
44+
self.mpeg4_height = 15
45+
self.thumb_url = 'thumb url'
46+
self.title = 'title'
47+
self.caption = 'caption'
48+
49+
self.json_dict = {
50+
'type': self.type,
51+
'id': self.id,
52+
'mpeg4_url': self.mpeg4_url,
53+
'mpeg4_width': self.mpeg4_width,
54+
'mpeg4_height': self.mpeg4_height,
55+
'thumb_url': self.thumb_url,
56+
'title': self.title,
57+
'caption': self.caption,
58+
}
59+
60+
def test_mpeg4_de_json(self):
61+
mpeg4 = telegram.InlineQueryResultMpeg4Gif.de_json(self.json_dict)
62+
63+
self.assertEqual(mpeg4.type, self.type)
64+
self.assertEqual(mpeg4.id, self.id)
65+
self.assertEqual(mpeg4.mpeg4_url, self.mpeg4_url)
66+
self.assertEqual(mpeg4.mpeg4_width, self.mpeg4_width)
67+
self.assertEqual(mpeg4.mpeg4_height, self.mpeg4_height)
68+
self.assertEqual(mpeg4.thumb_url, self.thumb_url)
69+
self.assertEqual(mpeg4.title, self.title)
70+
self.assertEqual(mpeg4.caption, self.caption)
71+
72+
def test_mpeg4_to_json(self):
73+
mpeg4 = telegram.InlineQueryResultMpeg4Gif.de_json(self.json_dict)
74+
75+
self.assertTrue(self.is_json(mpeg4.to_json()))
76+
77+
def test_mpeg4_to_dict(self):
78+
mpeg4 = \
79+
telegram.InlineQueryResultMpeg4Gif.de_json(self.json_dict).to_dict()
80+
81+
self.assertTrue(self.is_dict(mpeg4))
82+
self.assertDictEqual(self.json_dict, mpeg4)
83+
84+
85+
if __name__ == '__main__':
86+
unittest.main()
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env python
2+
#
3+
# A library that provides a Python interface to the Telegram Bot API
4+
# Copyright (C) 2015-2016
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 General 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 General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see [http://www.gnu.org/licenses/].
19+
20+
"""This module contains a object that represents Tests for Telegram
21+
InlineQueryResultPhoto"""
22+
23+
import sys
24+
25+
if sys.version_info[0:2] == (2, 6):
26+
import unittest2 as unittest
27+
else:
28+
import unittest
29+
30+
sys.path.append('.')
31+
32+
import telegram
33+
from tests.base import BaseTest
34+
35+
36+
class InlineQueryResultPhotoTest(BaseTest, unittest.TestCase):
37+
"""This object represents Tests for Telegram InlineQueryResultPhoto."""
38+
39+
def setUp(self):
40+
self.id = 'id'
41+
self.type = 'photo'
42+
self.photo_url = 'photo url'
43+
self.photo_width = 10
44+
self.photo_height = 15
45+
self.thumb_url = 'thumb url'
46+
self.title = 'title'
47+
self.caption = 'caption'
48+
49+
self.json_dict = {
50+
'type': self.type,
51+
'id': self.id,
52+
'photo_url': self.photo_url,
53+
'photo_width': self.photo_width,
54+
'photo_height': self.photo_height,
55+
'thumb_url': self.thumb_url,
56+
'title': self.title,
57+
'caption': self.caption,
58+
}
59+
60+
def test_photo_de_json(self):
61+
photo = telegram.InlineQueryResultPhoto.de_json(self.json_dict)
62+
63+
self.assertEqual(photo.type, self.type)
64+
self.assertEqual(photo.id, self.id)
65+
self.assertEqual(photo.photo_url, self.photo_url)
66+
self.assertEqual(photo.photo_width, self.photo_width)
67+
self.assertEqual(photo.photo_height, self.photo_height)
68+
self.assertEqual(photo.thumb_url, self.thumb_url)
69+
self.assertEqual(photo.title, self.title)
70+
self.assertEqual(photo.caption, self.caption)
71+
72+
def test_photo_to_json(self):
73+
photo = telegram.InlineQueryResultPhoto.de_json(self.json_dict)
74+
75+
self.assertTrue(self.is_json(photo.to_json()))
76+
77+
def test_photo_to_dict(self):
78+
photo = \
79+
telegram.InlineQueryResultPhoto.de_json(self.json_dict).to_dict()
80+
81+
self.assertTrue(self.is_dict(photo))
82+
self.assertDictEqual(self.json_dict, photo)
83+
84+
85+
if __name__ == '__main__':
86+
unittest.main()

0 commit comments

Comments
 (0)
X Tutup