def create_user(): sleep(0.02) now = datetime.now() defaults = { 'id': random.randint(0, 999), 'name': 'Alejandro', 'screen_name': 'dialelo', 'description': None, 'url': 'http://dialelo.com', 'created_at': now, 'friends_count': 3, 'followers_count': 42, 'favorites_count': 0, 'status': random_status(), } defaults.update(**kwargs) return User(**defaults)
def _to_user(user, **kwargs): """ Convert a `tweepy.User` to a `turses.models.User`. """ defaults = { 'id': user.id, 'name': user.name, 'screen_name': user.screen_name, 'description': user.description, 'url': user.url, 'created_at': user.created_at, 'friends_count': user.friends_count, 'followers_count': user.followers_count, 'favorites_count': user.favourites_count, } if hasattr(user, 'status'): status = _to_status(user.status, user=user.screen_name) defaults['status'] = status defaults.update(**kwargs) return User(**defaults)