X Tutup
Skip to content

Commit 5e51254

Browse files
committed
Adding all the others inlinequeryresult tests python-telegram-bot#188.
1 parent f86e6f9 commit 5e51254

6 files changed

+576
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
InlineQueryResultCachedDocument"""
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 InlineQueryResultCachedDocumentTest(BaseTest, unittest.TestCase):
37+
"""This object represents Tests for Telegram
38+
InlineQueryResultCachedDocument."""
39+
40+
def setUp(self):
41+
self.id = 'id'
42+
self.type = 'document'
43+
self.document_file_id = 'document file id'
44+
self.title = 'title'
45+
self.caption = 'caption'
46+
self.description = 'description'
47+
self.input_message_content = telegram.InputTextMessageContent(
48+
'input_message_content')
49+
self.reply_markup = telegram.InlineKeyboardMarkup([[
50+
telegram.InlineKeyboardButton('reply_markup')]])
51+
self.json_dict = {
52+
'id': self.id,
53+
'type': self.type,
54+
'document_file_id': self.document_file_id,
55+
'title': self.title,
56+
'caption': self.caption,
57+
'description': self.description,
58+
'input_message_content': self.input_message_content.to_dict(),
59+
'reply_markup': self.reply_markup.to_dict(),
60+
}
61+
62+
63+
def test_document_de_json(self):
64+
document = telegram.InlineQueryResultCachedDocument.de_json(
65+
self.json_dict)
66+
67+
self.assertEqual(document.id, self.id)
68+
self.assertEqual(document.type, self.type)
69+
self.assertEqual(document.document_file_id, self.document_file_id)
70+
self.assertEqual(document.title, self.title)
71+
self.assertEqual(document.caption, self.caption)
72+
self.assertEqual(document.description, self.description)
73+
self.assertDictEqual(document.input_message_content.to_dict(),
74+
self.input_message_content.to_dict())
75+
self.assertDictEqual(document.reply_markup.to_dict(),
76+
self.reply_markup.to_dict())
77+
78+
def test_document_to_json(self):
79+
document = telegram.InlineQueryResultCachedDocument.de_json(
80+
self.json_dict)
81+
82+
self.assertTrue(self.is_json(document.to_json()))
83+
84+
def test_document_to_dict(self):
85+
document = \
86+
telegram.InlineQueryResultCachedDocument.de_json(
87+
self.json_dict).to_dict()
88+
89+
self.assertTrue(self.is_dict(document))
90+
self.assertDictEqual(self.json_dict, document)
91+
92+
93+
if __name__ == '__main__':
94+
unittest.main()
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+
InlineQueryResultCachedSticker"""
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 InlineQueryResultCachedStickerTest(BaseTest, unittest.TestCase):
37+
"""This object represents Tests for Telegram
38+
InlineQueryResultCachedSticker."""
39+
40+
def setUp(self):
41+
self.id = 'id'
42+
self.type = 'sticker'
43+
self.sticker_file_id = 'sticker file id'
44+
self.input_message_content = telegram.InputTextMessageContent(
45+
'input_message_content')
46+
self.reply_markup = telegram.InlineKeyboardMarkup([[
47+
telegram.InlineKeyboardButton('reply_markup')]])
48+
49+
self.json_dict = {
50+
'type': self.type,
51+
'id': self.id,
52+
'sticker_file_id': self.sticker_file_id,
53+
'input_message_content': self.input_message_content.to_dict(),
54+
'reply_markup': self.reply_markup.to_dict(),
55+
}
56+
57+
def test_sticker_de_json(self):
58+
sticker = telegram.InlineQueryResultCachedSticker.de_json(
59+
self.json_dict)
60+
61+
self.assertEqual(sticker.type, self.type)
62+
self.assertEqual(sticker.id, self.id)
63+
self.assertEqual(sticker.sticker_file_id, self.sticker_file_id)
64+
self.assertDictEqual(sticker.input_message_content.to_dict(),
65+
self.input_message_content.to_dict())
66+
self.assertDictEqual(sticker.reply_markup.to_dict(),
67+
self.reply_markup.to_dict())
68+
69+
def test_sticker_to_json(self):
70+
sticker = telegram.InlineQueryResultCachedSticker.de_json(
71+
self.json_dict)
72+
73+
self.assertTrue(self.is_json(sticker.to_json()))
74+
75+
def test_sticker_to_dict(self):
76+
sticker = \
77+
telegram.InlineQueryResultCachedSticker.de_json(
78+
self.json_dict).to_dict()
79+
80+
self.assertTrue(self.is_dict(sticker))
81+
self.assertDictEqual(self.json_dict, sticker)
82+
83+
84+
if __name__ == '__main__':
85+
unittest.main()
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
InlineQueryResultContact"""
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 InlineQueryResultContactTest(BaseTest, unittest.TestCase):
37+
"""This object represents Tests for Telegram InlineQueryResultContact."""
38+
39+
def setUp(self):
40+
self.id = 'id'
41+
self.type = 'contact'
42+
self.phone_number = 'phone_number'
43+
self.first_name = 'first_name'
44+
self.last_name = 'last_name'
45+
self.thumb_url = 'thumb url'
46+
self.thumb_width = 10
47+
self.thumb_height = 15
48+
self.input_message_content = telegram.InputTextMessageContent(
49+
'input_message_content')
50+
self.reply_markup = telegram.InlineKeyboardMarkup([[
51+
telegram.InlineKeyboardButton('reply_markup')]])
52+
self.json_dict = {
53+
'id': self.id,
54+
'type': self.type,
55+
'phone_number': self.phone_number,
56+
'first_name': self.first_name,
57+
'last_name': self.last_name,
58+
'thumb_url': self.thumb_url,
59+
'thumb_width': self.thumb_width,
60+
'thumb_height': self.thumb_height,
61+
'input_message_content': self.input_message_content.to_dict(),
62+
'reply_markup': self.reply_markup.to_dict(),
63+
}
64+
65+
def test_contact_de_json(self):
66+
contact = telegram.InlineQueryResultContact.de_json(self.json_dict)
67+
68+
self.assertEqual(contact.id, self.id)
69+
self.assertEqual(contact.type, self.type)
70+
self.assertEqual(contact.phone_number, self.phone_number)
71+
self.assertEqual(contact.first_name, self.first_name)
72+
self.assertEqual(contact.last_name, self.last_name)
73+
self.assertEqual(contact.thumb_url, self.thumb_url)
74+
self.assertEqual(contact.thumb_width, self.thumb_width)
75+
self.assertEqual(contact.thumb_height, self.thumb_height)
76+
self.assertDictEqual(contact.input_message_content.to_dict(),
77+
self.input_message_content.to_dict())
78+
self.assertDictEqual(contact.reply_markup.to_dict(),
79+
self.reply_markup.to_dict())
80+
81+
def test_contact_to_json(self):
82+
contact = telegram.InlineQueryResultContact.de_json(self.json_dict)
83+
84+
self.assertTrue(self.is_json(contact.to_json()))
85+
86+
def test_contact_to_dict(self):
87+
contact = \
88+
telegram.InlineQueryResultContact.de_json(
89+
self.json_dict).to_dict()
90+
91+
self.assertTrue(self.is_dict(contact))
92+
self.assertDictEqual(self.json_dict, contact)
93+
94+
95+
if __name__ == '__main__':
96+
unittest.main()
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
InlineQueryResultDocument"""
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 InlineQueryResultDocumentTest(BaseTest, unittest.TestCase):
37+
"""This object represents Tests for Telegram InlineQueryResultDocument."""
38+
39+
def setUp(self):
40+
self.id = 'id'
41+
self.type = 'document'
42+
self.document_url = 'document url'
43+
self.title = 'title'
44+
self.caption = 'caption'
45+
self.mime_type = 'mime type'
46+
self.description = 'description'
47+
self.thumb_url = 'thumb url'
48+
self.thumb_width = 10
49+
self.thumb_height = 15
50+
self.input_message_content = telegram.InputTextMessageContent(
51+
'input_message_content')
52+
self.reply_markup = telegram.InlineKeyboardMarkup([[
53+
telegram.InlineKeyboardButton('reply_markup')]])
54+
self.json_dict = {
55+
'id': self.id,
56+
'type': self.type,
57+
'document_url': self.document_url,
58+
'title': self.title,
59+
'caption': self.caption,
60+
'mime_type': self.mime_type,
61+
'description': self.description,
62+
'thumb_url': self.thumb_url,
63+
'thumb_width': self.thumb_width,
64+
'thumb_height': self.thumb_height,
65+
'input_message_content': self.input_message_content.to_dict(),
66+
'reply_markup': self.reply_markup.to_dict(),
67+
}
68+
69+
70+
def test_document_de_json(self):
71+
document = telegram.InlineQueryResultDocument.de_json(self.json_dict)
72+
73+
self.assertEqual(document.id, self.id)
74+
self.assertEqual(document.type, self.type)
75+
self.assertEqual(document.document_url, self.document_url)
76+
self.assertEqual(document.title, self.title)
77+
self.assertEqual(document.caption, self.caption)
78+
self.assertEqual(document.mime_type, self.mime_type)
79+
self.assertEqual(document.description, self.description)
80+
self.assertEqual(document.thumb_url, self.thumb_url)
81+
self.assertEqual(document.thumb_width, self.thumb_width)
82+
self.assertEqual(document.thumb_height, self.thumb_height)
83+
self.assertDictEqual(document.input_message_content.to_dict(),
84+
self.input_message_content.to_dict())
85+
self.assertDictEqual(document.reply_markup.to_dict(),
86+
self.reply_markup.to_dict())
87+
88+
def test_document_to_json(self):
89+
document = telegram.InlineQueryResultDocument.de_json(self.json_dict)
90+
91+
self.assertTrue(self.is_json(document.to_json()))
92+
93+
def test_document_to_dict(self):
94+
document = \
95+
telegram.InlineQueryResultDocument.de_json(
96+
self.json_dict).to_dict()
97+
98+
self.assertTrue(self.is_dict(document))
99+
self.assertDictEqual(self.json_dict, document)
100+
101+
102+
if __name__ == '__main__':
103+
unittest.main()

0 commit comments

Comments
 (0)
X Tutup