Ejemplo n.º 1
0
    def __init__(self):

        # Set up application-based Twitter auth
        self.app_auth = tweepy.OAuthHandler(
            os.environ['TWITTER_API_KEY'], os.environ['TWITTER_API_SECRET'])
        self.app_auth.set_access_token(os.environ['TWITTER_ACCESS_TOKEN'], os.environ[
                                   'TWITTER_ACCESS_TOKEN_SECRET'])

        # Keep reference to twitter app api
        self.app_api = tweepy.API(self.app_auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True,
                              retry_count=3, retry_delay=5, retry_errors=set([403, 500, 503]))


        # Set up user-based Twitter auth
        self.client_auth = tweepy.OAuthHandler(
            os.environ['TWITTER_API_KEY'], os.environ['TWITTER_API_SECRET'])
        self.client_auth.set_access_token(os.environ['TWITTER_CLIENT_ACCESS_TOKEN'], os.environ[
            'TWITTER_CLIENT_ACCESS_TOKEN_SECRET'])

        # Keep reference to twitter app api
        self.client_api = tweepy.API(self.client_auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True,
                              retry_count=3, retry_delay=5, retry_errors=set([403, 500, 503]))

        # Create reply argument_builder
        self.reply_argument_builder = ReplyArgumentBuilder(self.app_api)

        # Create new aggregator
        self.aggregator = TrafficViolationsAggregator()

        # Log how many times we've called the apis
        self.direct_messages_iteration = 0
        self.events_iteration = 0
        self.statuses_iteration = 0
Ejemplo n.º 2
0
    def setUp(self):
        recipient_mock = MagicMock(name='recipient_mock')
        recipient_mock.screen_name = self.HMDNY_TWITTER_HANDLE

        sender_mock = MagicMock(name='sender_mock')
        sender_mock.screen_name = self.OTHER_TWITTER_HANDLE

        api = MagicMock(name='api_mock')
        api.get_user.side_effect = [recipient_mock, sender_mock]
        self.reply_argument_builder = ReplyArgumentBuilder(api)
Ejemplo n.º 3
0
    def __init__(self):

        self._app_api = None
        self._client_api = None

        # Create reply argument_builder
        self.reply_argument_builder = ReplyArgumentBuilder(self._get_twitter_application_api())

        # Create new aggregator
        self.aggregator = TrafficViolationsAggregator()

        # Log how many times we've called the apis
        self.direct_messages_iteration = 0
        self.events_iteration = 0
        self.statuses_iteration = 0

        # Initialize cached values to None
        self._follower_ids: Optional[List[int]] = None
        self._follower_ids_last_fetched: Optional[datetime] = None
Ejemplo n.º 4
0
    def __init__(self):

        self._app_api = None
        self._client_api = None

        # Create reply argument_builder
        self.reply_argument_builder = ReplyArgumentBuilder(self._get_twitter_application_api())

        # Create new aggregator
        self.aggregator = TrafficViolationsAggregator()

        # Need to find if unanswered statuses have been deleted
        self.tweet_detection_service = TweetDetectionService()

        # Log how many times we've called the apis
        self._direct_messages_iteration = 0
        self._events_iteration = 0
        self._statuses_iteration = 0

        self._lookup_threads = []

        # Initialize cached values to None
        self._follower_ids: Optional[list[int]] = None
        self._follower_ids_last_fetched: Optional[datetime] = None