Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit b3ae763

Browse files
committed
add tests for updating profile
1 parent f80a893 commit b3ae763

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

testdata/update_profile.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"follow_request_sent": null, "profile_image_url_https": "https://pbs.twimg.com/profile_images/968861535127949312/v7ZnBn4I_normal.jpg", "location": "philly", "created_at": "Sun Sep 11 23:49:28 +0000 2011", "profile_banner_url": "https://pbs.twimg.com/profile_banners/372018022/1475799101", "has_extended_profile": false, "is_translation_enabled": false, "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png", "description": "these people have addresses | #botally", "statuses_count": 4083, "profile_sidebar_fill_color": "000000", "following": null, "profile_location": null, "lang": "en", "default_profile_image": false, "verified": false, "notifications": null, "profile_image_url": "http://pbs.twimg.com/profile_images/968861535127949312/v7ZnBn4I_normal.jpg", "geo_enabled": false, "favourites_count": 20700, "profile_link_color": "EE3355", "utc_offset": -18000, "protected": true, "profile_sidebar_border_color": "000000", "friends_count": 497, "screen_name": "__jcbl__", "profile_background_color": "FFFFFF", "url": "https://t.co/wtg3XyA3vL", "id": 372018022, "entities": {"description": {"urls": []}, "url": {"urls": [{"display_url": "iseverythingstilltheworst.com", "expanded_url": "http://iseverythingstilltheworst.com", "url": "https://t.co/wtg3XyA3vL", "indices": [0, 23]}]}}, "followers_count": 189, "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png", "profile_use_background_image": false, "contributors_enabled": false, "translator_type": "none", "default_profile": false, "profile_background_tile": false, "name": "jeremy", "id_str": "372018022", "listed_count": 6, "profile_text_color": "000000", "is_translator": false, "time_zone": "Eastern Time (US & Canada)"}

tests/test_api_30.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,3 +1753,18 @@ def test_outgoing_friendships(self):
17531753
assert resp
17541754
assert isinstance(resp, list)
17551755
assert resp[0] == 12
1756+
1757+
@responses.activate
1758+
def test_update_profile(self):
1759+
with open('testdata/update_profile.json') as f:
1760+
responses.add(POST, DEFAULT_URL, f.read())
1761+
resp = self.api.UpdateProfile(
1762+
name='jeremy',
1763+
location='philly',
1764+
profileURL='example.com',
1765+
description='test',
1766+
profile_link_color='#e35',
1767+
include_entities=True,
1768+
skip_status=True)
1769+
assert resp
1770+
assert isinstance(resp, twitter.User)

twitter/api.py

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4373,49 +4373,37 @@ def UpdateProfile(self,
43734373
"""Update's the authenticated user's profile data.
43744374
43754375
Args:
4376-
name:
4376+
name (str, optional):
43774377
Full name associated with the profile.
4378-
Maximum of 20 characters. [Optional]
4379-
profileURL:
4378+
profileURL (str, optional):
43804379
URL associated with the profile.
43814380
Will be prepended with "http://" if not present.
4382-
Maximum of 100 characters. [Optional]
4383-
location:
4381+
location (str, optional):
43844382
The city or country describing where the user of the account is located.
43854383
The contents are not normalized or geocoded in any way.
4386-
Maximum of 30 characters. [Optional]
4387-
description:
4384+
description (str, optional):
43884385
A description of the user owning the account.
4389-
Maximum of 160 characters. [Optional]
4390-
profile_link_color:
4386+
profile_link_color (str, optional):
43914387
hex value of profile color theme. formated without '#' or '0x'. Ex: FF00FF
4392-
[Optional]
4393-
include_entities:
4388+
include_entities (bool, optional):
43944389
The entities node will be omitted when set to False.
4395-
[Optional]
4396-
skip_status:
4390+
skip_status (bool, optional):
43974391
When set to either True, t or 1 then statuses will not be included
4398-
in the returned user objects. [Optional]
4392+
in the returned user objects.
43994393
44004394
Returns:
44014395
A twitter.User instance representing the modified user.
44024396
"""
44034397
url = '%s/account/update_profile.json' % (self.base_url)
4404-
data = {}
4405-
if name:
4406-
data['name'] = name
4407-
if profileURL:
4408-
data['url'] = profileURL
4409-
if location:
4410-
data['location'] = location
4411-
if description:
4412-
data['description'] = description
4413-
if profile_link_color:
4414-
data['profile_link_color'] = profile_link_color
4415-
if include_entities:
4416-
data['include_entities'] = include_entities
4417-
if skip_status:
4418-
data['skip_status'] = skip_status
4398+
data = {
4399+
'name': name,
4400+
'url': profileURL,
4401+
'location': location,
4402+
'description': description,
4403+
'profile_link_color': profile_link_color,
4404+
'include_entities': include_entities,
4405+
'skip_status': skip_status,
4406+
}
44194407

44204408
resp = self._RequestUrl(url, 'POST', data=data)
44214409
data = self._ParseAndCheckTwitter(resp.content.decode('utf-8'))

0 commit comments

Comments
 (0)