def test_default_call_options(self, twitter_api): get_tweets('walter') twitter_api.assert_called() twitter_api.return_value.user_timeline.assert_called_with(screen_name='walter', include_rts=True, exclude_replies=True, count=100)
def test_override_default_call_options(self, twitter_api): get_tweets('dude') twitter_api.assert_called() twitter_api.return_value.user_timeline.assert_called_with(screen_name='dude', abide=True, include_rts=False, exclude_replies=True, count=100)
def update_tweets(): for account in settings.TWITTER_ACCOUNTS: tweets = get_tweets(account) if tweets: account_cache, created = TwitterCache.objects.get_or_create( account=account, defaults={'tweets': tweets}) if not created: account_cache.tweets = tweets account_cache.save()
def handle_safe(self, *args, **options): if not settings.TWITTER_APP_KEYS['consumer_key']: # twitter auth not configured return for account in settings.TWITTER_ACCOUNTS: tweets = get_tweets(account) if tweets: account_cache, created = TwitterCache.objects.get_or_create( account=account, defaults={'tweets': tweets}) if not created: account_cache.tweets = tweets account_cache.save()
def test_returns_none_if_api_not_configured(self, twitter_api): twitter_api.return_value = None self.assertIsNone(get_tweets('dude'))