Esempio n. 1
0
    def test_check_if_continue_downloading_invalid_date(self):
        tweet = TweetUpdateHelper().get_mock_tweet_may_26_follower_1()
        min_date = TweetUpdateService.get_formatted_date('123123')

        result = TweetUpdateService.check_if_continue_downloading(
            tweet, min_date)

        assert result is False
Esempio n. 2
0
    def test_do_not_store_new_tweets(self, insert_mock):
        tweet2 = TweetUpdateHelper().get_mock_tweet_may_24_follower_1()
        download_tweets = [tweet2]
        min_date = TweetUpdateHelper().get_mock_min_date_may_25()

        TweetUpdateService.store_new_tweets(download_tweets, min_date)

        assert insert_mock.call_count == 0
Esempio n. 3
0
    def test_update_complete_follower(self, update_mock):
        tweet = TweetUpdateHelper().get_mock_tweet_may_26_follower_1()
        last_date = TweetUpdateHelper().get_mock_min_date_may_24()

        TweetUpdateService.update_complete_follower("dummyFollower", tweet,
                                                    last_date)

        assert update_mock.call_count == 1
Esempio n. 4
0
    def test_store_new_tweets(self, origin_mock, cooccurrence_mock,
                              insert_mock):
        tweet1 = TweetUpdateHelper().get_mock_tweet_may_26_follower_1()
        tweet2 = TweetUpdateHelper().get_mock_tweet_may_24_follower_1()
        download_tweets = [tweet1, tweet2]
        min_date = TweetUpdateHelper().get_mock_min_date_may_24()

        TweetUpdateService.store_new_tweets(download_tweets, min_date)

        assert insert_mock.call_count == 2
        assert origin_mock.call_count == 2
        assert cooccurrence_mock.call_count == 2
Esempio n. 5
0
    def test_check_if_continue_downloading(self):
        tweet = TweetUpdateHelper().get_mock_tweet_may_26_follower_1()
        min_date = TweetUpdateHelper().get_mock_min_date_may_25()

        result = TweetUpdateService.check_if_continue_downloading(
            tweet, min_date)

        assert result is True
Esempio n. 6
0
    def test_do_download_tweets_requests_with_no_results(
            self, download_tweets_mock, twitter_mock):
        follower = TweetUpdateHelper().get_mock_follower_1()
        is_first_request = True
        max_id = None

        result = TweetUpdateService().do_download_tweets_request(
            twitter_mock, follower, "timestamp", is_first_request, max_id)
        assert download_tweets_mock.call_count == 1
        assert len(result) == 1
Esempio n. 7
0
    def test_download_tweets_and_validate_with_results(self,
                                                       download_tweets_mock,
                                                       twitter_mock):
        follower = TweetUpdateHelper().get_mock_follower_1()
        min_tweet_date = TweetUpdateHelper().get_mock_min_date_may_25()
        is_first_request = True
        max_id = None

        result = TweetUpdateService().download_tweets_and_validate(
            twitter_mock, follower, min_tweet_date, is_first_request, max_id)
        assert len(result) == 1
        assert download_tweets_mock.call_count == 1
Esempio n. 8
0
 def initialize_context(cls):
     """ Create instances of all environment services in a Spring-like fashion."""
     cls.LOGGER.info('Instantiating context services and components.')
     ConfigurationManager()
     ConcurrencyUtils()
     Scheduler()
     CandidateDAO()
     RawFollowerDAO()
     CandidatesFollowersDAO()
     CredentialService()
     CandidateService()
     FollowerUpdateService()
     TweetUpdateService()
     FollowersQueueService()
Esempio n. 9
0
 def initialize_with_credential(cls, credential):
     TweetUpdateService().download_tweets_with_credential(credential)
Esempio n. 10
0
 def get_mock_min_date_may_24():
     return TweetUpdateService.get_formatted_date(
         'Fri May 24 00:00:00 +0000 2019')
Esempio n. 11
0
 def get_mock_min_date_may_25():
     return TweetUpdateService.get_formatted_date(
         'Sat May 25 02:43:14 +0000 2019')
Esempio n. 12
0
    def test_get_formatted_date_invalid_date(self):
        date = TweetUpdateService.get_formatted_date('123123')

        assert date is None
Esempio n. 13
0
    def test_update_follower_as_private(self, tag_mock):
        TweetUpdateService.update_follower_as_private("dummyFollower")

        assert tag_mock.call_count == 1
Esempio n. 14
0
    def test_update_follower_with_no_tweets_not_private_user(
            self, get_mock, update_mock):
        TweetUpdateService.update_follower_with_no_tweets("dummyFollower")

        assert get_mock.call_count == 1
        assert update_mock.call_count == 1