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

Commit fd10c45

Browse files
authored
Merge pull request #510 from bear/bugfix/issue497
move UserStatus.connections to private class attr
2 parents 1c480df + ca387fe commit fd10c45

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

tests/test_models.py

+4
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,7 @@ def test_user_status(self):
190190
self.fail(e)
191191
self.assertTrue(user_status.AsJsonString())
192192
self.assertTrue(user_status.AsDict())
193+
194+
self.assertTrue(user_status.connections['blocking'])
195+
self.assertTrue(user_status.connections['muting'])
196+
self.assertFalse(user_status.connections['followed_by'])

twitter/models.py

+16-7
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,12 @@ class UserStatus(TwitterModel):
282282
""" A class representing the UserStatus structure. This is an abbreviated
283283
form of the twitter.User object. """
284284

285-
connections = {'following': False,
286-
'followed_by': False,
287-
'following_received': False,
288-
'following_requested': False,
289-
'blocking': False,
290-
'muting': False}
285+
_connections = {'following': False,
286+
'followed_by': False,
287+
'following_received': False,
288+
'following_requested': False,
289+
'blocking': False,
290+
'muting': False}
291291

292292
def __init__(self, **kwargs):
293293
self.param_defaults = {
@@ -307,10 +307,19 @@ def __init__(self, **kwargs):
307307
setattr(self, param, kwargs.get(param, default))
308308

309309
if 'connections' in kwargs:
310-
for param in self.connections:
310+
for param in self._connections:
311311
if param in kwargs['connections']:
312312
setattr(self, param, True)
313313

314+
@property
315+
def connections(self):
316+
return {'following': self.following,
317+
'followed_by': self.followed_by,
318+
'following_received': self.following_received,
319+
'following_requested': self.following_requested,
320+
'blocking': self.blocking,
321+
'muting': self.muting}
322+
314323
def __repr__(self):
315324
connections = [param for param in self.connections if getattr(self, param)]
316325
return "UserStatus(ID={uid}, ScreenName={sn}, Connections=[{conn}])".format(

0 commit comments

Comments
 (0)