Skip to content

Commit 97d26de

Browse files
committed
Fixed Test
1 parent 33df3a8 commit 97d26de

File tree

8 files changed

+61
-9
lines changed

8 files changed

+61
-9
lines changed

telegram/bot.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ def send_venue(self,
10201020
title=None,
10211021
address=None,
10221022
foursquare_id=None,
1023+
foursquare_type=None,
10231024
disable_notification=False,
10241025
reply_to_message_id=None,
10251026
reply_markup=None,
@@ -1030,7 +1031,8 @@ def send_venue(self,
10301031
10311032
Note:
10321033
you can either supply :obj:`venue`, or :obj:`latitude`, :obj:`longitude`,
1033-
:obj:`title` and :obj:`address` and optionally :obj:`foursquare_id`.
1034+
:obj:`title` and :obj:`address` and optionally :obj:`foursquare_id` and optionally
1035+
:obj:`foursquare_type`.
10341036
10351037
Args:
10361038
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
@@ -1040,6 +1042,9 @@ def send_venue(self,
10401042
title (:obj:`str`, optional): Name of the venue.
10411043
address (:obj:`str`, optional): Address of the venue.
10421044
foursquare_id (:obj:`str`, optional): Foursquare identifier of the venue.
1045+
foursquare_type (:obj:`str`, optional): Foursquare type of the venue, if known.
1046+
(For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or
1047+
“food/icecream”.)
10431048
venue (:class:`telegram.Venue`, optional): The venue to send.
10441049
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
10451050
receive a notification with no sound.
@@ -1072,6 +1077,7 @@ def send_venue(self,
10721077
address = venue.address
10731078
title = venue.title
10741079
foursquare_id = venue.foursquare_id
1080+
foursquare_type = venue.foursquare_type
10751081

10761082
data = {
10771083
'chat_id': chat_id,
@@ -1083,6 +1089,8 @@ def send_venue(self,
10831089

10841090
if foursquare_id:
10851091
data['foursquare_id'] = foursquare_id
1092+
if foursquare_type:
1093+
data['foursquare_type'] = foursquare_type
10861094

10871095
return url, data
10881096

@@ -1104,7 +1112,7 @@ def send_contact(self,
11041112
11051113
Note:
11061114
You can either supply :obj:`contact` or :obj:`phone_number` and :obj:`first_name`
1107-
with optionally :obj:`last_name`.
1115+
with optionally :obj:`last_name` and optionally :obj:`vcard`.
11081116
11091117
Args:
11101118
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username

telegram/files/venue.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,29 @@ class Venue(TelegramObject):
2929
title (:obj:`str`): Name of the venue.
3030
address (:obj:`str`): Address of the venue.
3131
foursquare_id (:obj:`str`): Optional. Foursquare identifier of the venue.
32+
foursquare_type (:obj:`str`): Optional. Foursquare type of the venue. (For example,
33+
“arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
3234
3335
Args:
3436
location (:class:`telegram.Location`): Venue location.
3537
title (:obj:`str`): Name of the venue.
3638
address (:obj:`str`): Address of the venue.
3739
foursquare_id (:obj:`str`, optional): Foursquare identifier of the venue.
40+
foursquare_type (:obj:`str`, optional): Foursquare type of the venue. (For example,
41+
“arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
3842
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
3943
4044
"""
4145

42-
def __init__(self, location, title, address, foursquare_id=None, **kwargs):
46+
def __init__(self, location, title, address, foursquare_id=None, foursquare_type=None,
47+
**kwargs):
4348
# Required
4449
self.location = location
4550
self.title = title
4651
self.address = address
4752
# Optionals
4853
self.foursquare_id = foursquare_id
54+
self.foursquare_type = foursquare_type
4955

5056
self._id_attrs = (self.location, self.title)
5157

telegram/inline/inlinequeryresultvenue.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class InlineQueryResultVenue(InlineQueryResult):
3535
title (:obj:`str`): Title of the venue.
3636
address (:obj:`str`): Address of the venue.
3737
foursquare_id (:obj:`str`): Optional. Foursquare identifier of the venue if known.
38+
foursquare_type (:obj:`str`): Optional. Foursquare type of the venue, if known.
39+
(For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or
40+
“food/icecream”.)
3841
reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached
3942
to the message.
4043
input_message_content (:class:`telegram.InputMessageContent`): Optional. Content of the
@@ -50,6 +53,9 @@ class InlineQueryResultVenue(InlineQueryResult):
5053
title (:obj:`str`): Title of the venue.
5154
address (:obj:`str`): Address of the venue.
5255
foursquare_id (:obj:`str`, optional): Foursquare identifier of the venue if known.
56+
foursquare_type (:obj:`str`, optional): Foursquare type of the venue, if known.
57+
(For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or
58+
“food/icecream”.)
5359
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached
5460
to the message.
5561
input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the
@@ -68,6 +74,7 @@ def __init__(self,
6874
title,
6975
address,
7076
foursquare_id=None,
77+
foursquare_type=None,
7178
reply_markup=None,
7279
input_message_content=None,
7380
thumb_url=None,
@@ -85,6 +92,8 @@ def __init__(self,
8592
# Optional
8693
if foursquare_id:
8794
self.foursquare_id = foursquare_id
95+
if foursquare_type:
96+
self.foursquare_type = foursquare_type
8897
if reply_markup:
8998
self.reply_markup = reply_markup
9099
if input_message_content:

telegram/inline/inputvenuemessagecontent.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,30 @@ class InputVenueMessageContent(InputMessageContent):
3030
title (:obj:`str`): Name of the venue.
3131
address (:obj:`str`): Address of the venue.
3232
foursquare_id (:obj:`str`): Optional. Foursquare identifier of the venue, if known.
33+
foursquare_type (:obj:`str`): Optional. Foursquare type of the venue, if known.
34+
(For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or
35+
“food/icecream”.)
3336
3437
Args:
3538
latitude (:obj:`float`): Latitude of the location in degrees.
3639
longitude (:obj:`float`): Longitude of the location in degrees.
3740
title (:obj:`str`): Name of the venue.
3841
address (:obj:`str`): Address of the venue.
3942
foursquare_id (:obj:`str`, optional): Foursquare identifier of the venue, if known.
43+
foursquare_type (:obj:`str`, optional): Foursquare type of the venue, if known.
44+
(For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or
45+
“food/icecream”.)
4046
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
4147
4248
"""
4349

44-
def __init__(self, latitude, longitude, title, address, foursquare_id=None, **kwargs):
50+
def __init__(self, latitude, longitude, title, address, foursquare_id=None,
51+
foursquare_type=None, **kwargs):
4552
# Required
4653
self.latitude = latitude
4754
self.longitude = longitude
4855
self.title = title
4956
self.address = address
5057
# Optionals
5158
self.foursquare_id = foursquare_id
59+
self.foursquare_type = foursquare_type

tests/test_bot.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,19 @@ def test_send_venue(self, bot, chat_id):
114114
latitude = -23.691288
115115
title = 'title'
116116
address = 'address'
117+
foursquare_id = 'foursquare id'
118+
foursquare_type = 'foursquare type'
117119
message = bot.send_venue(chat_id=chat_id, title=title, address=address, latitude=latitude,
118-
longitude=longitude)
120+
longitude=longitude, foursquare_id=foursquare_id,
121+
foursquare_type=foursquare_type)
119122

120123
assert message.venue
121124
assert message.venue.title == title
122125
assert message.venue.address == address
123126
assert message.venue.location.latitude == latitude
124127
assert message.venue.location.longitude == longitude
128+
assert message.venue.foursquare_id == foursquare_id
129+
assert message.venue.foursquare_type == foursquare_type
125130

126131
@flaky(3, 1)
127132
@pytest.mark.timeout(10)

tests/test_inlinequeryresultvenue.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def inline_query_result_venue():
3232
TestInlineQueryResultVenue.title,
3333
TestInlineQueryResultVenue.address,
3434
foursquare_id=TestInlineQueryResultVenue.foursquare_id,
35+
foursquare_type=TestInlineQueryResultVenue.foursquare_type,
3536
thumb_url=TestInlineQueryResultVenue.thumb_url,
3637
thumb_width=TestInlineQueryResultVenue.thumb_width,
3738
thumb_height=TestInlineQueryResultVenue.thumb_height,
@@ -47,6 +48,7 @@ class TestInlineQueryResultVenue(object):
4748
title = 'title'
4849
address = 'address'
4950
foursquare_id = 'foursquare id'
51+
foursquare_type = 'foursquare type'
5052
thumb_url = 'thumb url'
5153
thumb_width = 10
5254
thumb_height = 15
@@ -61,6 +63,7 @@ def test_expected_values(self, inline_query_result_venue):
6163
assert inline_query_result_venue.title == self.title
6264
assert inline_query_result_venue.address == self.address
6365
assert inline_query_result_venue.foursquare_id == self.foursquare_id
66+
assert inline_query_result_venue.foursquare_type == self.foursquare_type
6467
assert inline_query_result_venue.thumb_url == self.thumb_url
6568
assert inline_query_result_venue.thumb_width == self.thumb_width
6669
assert inline_query_result_venue.thumb_height == self.thumb_height
@@ -80,6 +83,8 @@ def test_to_dict(self, inline_query_result_venue):
8083
assert inline_query_result_venue_dict['address'] == inline_query_result_venue.address
8184
assert (inline_query_result_venue_dict['foursquare_id'] ==
8285
inline_query_result_venue.foursquare_id)
86+
assert (inline_query_result_venue_dict['foursquare_type'] ==
87+
inline_query_result_venue.foursquare_type)
8388
assert inline_query_result_venue_dict['thumb_url'] == inline_query_result_venue.thumb_url
8489
assert (inline_query_result_venue_dict['thumb_width'] ==
8590
inline_query_result_venue.thumb_width)

tests/test_inputvenuemessagecontent.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def input_venue_message_content():
2828
TestInputVenueMessageContent.longitude,
2929
TestInputVenueMessageContent.title,
3030
TestInputVenueMessageContent.address,
31-
foursquare_id=TestInputVenueMessageContent.foursquare_id)
31+
foursquare_id=TestInputVenueMessageContent.foursquare_id,
32+
foursquare_type=TestInputVenueMessageContent.foursquare_type)
3233

3334

3435
class TestInputVenueMessageContent(object):
@@ -37,13 +38,15 @@ class TestInputVenueMessageContent(object):
3738
title = 'title'
3839
address = 'address'
3940
foursquare_id = 'foursquare id'
41+
foursquare_type = 'foursquare type'
4042

4143
def test_expected_values(self, input_venue_message_content):
4244
assert input_venue_message_content.longitude == self.longitude
4345
assert input_venue_message_content.latitude == self.latitude
4446
assert input_venue_message_content.title == self.title
4547
assert input_venue_message_content.address == self.address
4648
assert input_venue_message_content.foursquare_id == self.foursquare_id
49+
assert input_venue_message_content.foursquare_type == self.foursquare_type
4750

4851
def test_to_dict(self, input_venue_message_content):
4952
input_venue_message_content_dict = input_venue_message_content.to_dict()
@@ -57,3 +60,5 @@ def test_to_dict(self, input_venue_message_content):
5760
assert input_venue_message_content_dict['address'] == input_venue_message_content.address
5861
assert (input_venue_message_content_dict['foursquare_id'] ==
5962
input_venue_message_content.foursquare_id)
63+
assert (input_venue_message_content_dict['foursquare_type'] ==
64+
input_venue_message_content.foursquare_type)

tests/test_venue.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,41 @@ def venue():
2727
return Venue(TestVenue.location,
2828
TestVenue.title,
2929
TestVenue.address,
30-
foursquare_id=TestVenue.foursquare_id)
30+
foursquare_id=TestVenue.foursquare_id,
31+
foursquare_type=TestVenue.foursquare_type)
3132

3233

3334
class TestVenue(object):
3435
location = Location(longitude=-46.788279, latitude=-23.691288)
3536
title = 'title'
3637
address = 'address'
3738
foursquare_id = 'foursquare id'
39+
foursquare_type = 'foursquare type'
3840

3941
def test_de_json(self, bot):
4042
json_dict = {
4143
'location': TestVenue.location.to_dict(),
4244
'title': TestVenue.title,
4345
'address': TestVenue.address,
44-
'foursquare_id': TestVenue.foursquare_id
46+
'foursquare_id': TestVenue.foursquare_id,
47+
'foursquare_type': TestVenue.foursquare_type
4548
}
4649
venue = Venue.de_json(json_dict, bot)
4750

4851
assert venue.location == self.location
4952
assert venue.title == self.title
5053
assert venue.address == self.address
5154
assert venue.foursquare_id == self.foursquare_id
55+
assert venue.foursquare_type == self.foursquare_type
5256

5357
def test_send_with_venue(self, monkeypatch, bot, chat_id, venue):
5458
def test(_, url, data, **kwargs):
5559
return (data['longitude'] == self.location.longitude
5660
and data['latitude'] == self.location.latitude
5761
and data['title'] == self.title
5862
and data['address'] == self.address
59-
and data['foursquare_id'] == self.foursquare_id)
63+
and data['foursquare_id'] == self.foursquare_id
64+
and data['foursquare_type'] == self.foursquare_type)
6065

6166
monkeypatch.setattr('telegram.utils.request.Request.post', test)
6267
message = bot.send_venue(chat_id, venue=venue)
@@ -74,6 +79,7 @@ def test_to_dict(self, venue):
7479
assert venue_dict['title'] == venue.title
7580
assert venue_dict['address'] == venue.address
7681
assert venue_dict['foursquare_id'] == venue.foursquare_id
82+
assert venue_dict['fousquare_type'] == venue.foursquare_type
7783

7884
def test_equality(self):
7985
a = Venue(Location(0, 0), self.title, self.address)

0 commit comments

Comments
 (0)