Esempio n. 1
0
def test_valid_get_tweets():
    valid_test_tweets = "tests/client/test_tweets.txt"
    valid_test_client = TwitterAPIClient(valid_test_tweets)
    assert isgeneratorfunction(valid_test_client.get_tweets)

    tweet_generator = valid_test_client.get_tweets()
    tweet = tweet_generator.next()
    assert type(tweet) == type({})
Esempio n. 2
0
def test_invalid_get_tweets():
    invalid_test_tweets = "tests/client/invalid_tweets.txt"
    invalid_test_client = TwitterAPIClient(invalid_test_tweets)

    tweet_generator = invalid_test_client.get_tweets()

    with pytest.raises(SystemExit):
        tweet_generator.next()
Esempio n. 3
0
File: ft1.py Progetto: nguyent/IDS
def main():
    args = parse_args()
    client = TwitterAPIClient(args.input)
    tweet_generator = client.get_tweets()

    output_file = open(args.output, "w")
    for tweet in tweet_generator:
        cleaned_tweet = TweetParser.clean_tweet(tweet)
        output_file.write("%s (timestamp: %s)\n" % (cleaned_tweet, tweet["created_at"]))

    output_file.write("\n%d tweets contained unicode.\n" % TweetParser.unicode_count)
    output_file.close()
Esempio n. 4
0
File: ft2.py Progetto: nguyent/IDS
def main():
    args = parse_args()
    client = TwitterAPIClient(args.input)
    tweet_generator = client.get_tweets()
    graph = TwitterHashtagGraph()

    output_file = open(args.output,'w')

    for tweet in tweet_generator:
        graph.add_tweet(tweet)
        output_file.write("%s\n" % graph.average)

    output_file.close()