def test_parse_tweet_from_url(self):
	''' Tests that tweet from hashtag can be parsed to correct text '''
	tweets = get_fewer_tweets_from_hashtag(connect(), "#musicthatdontmatch")
	parsed_tweets = parse_all(tweets)
	tweet = parsed_tweets[0]
	text = get_tweet_from_url(connect(), tweet['url'])
	self.assertEqual(parse(text)['line'], tweet['line'])
示例#2
0
def load_more_tweets(hashtag, tries=10, count=100):
    ''' Loads a maximum of count * tries number of new recent tweets with the given hashtag into the database '''
    
    twitter = connect()
    tweets = get_tweets_from_hashtag(twitter, hashtag, tries=tries, count=count)
    parsed_tweets = parse_all(tweets, hashtag)
    inserter = Tweet.__table__.insert().prefix_with('IGNORE')
    engine.execute(inserter, parsed_tweets)
    db.session.commit()
示例#3
0
def load_more_tweets(hashtag, tries=10, count=100):
    ''' Loads a maximum of count * tries number of new recent tweets with the given hashtag into the database '''

    twitter = connect()
    tweets = get_tweets_from_hashtag(twitter,
                                     hashtag,
                                     tries=tries,
                                     count=count)
    parsed_tweets = parse_all(tweets, hashtag)
    inserter = Tweet.__table__.insert().prefix_with('IGNORE')
    engine.execute(inserter, parsed_tweets)
    db.session.commit()
示例#4
0
 def test_parse_all(self):
     ''' Tests that multiple lines are properly handled '''
     lines = ['dog', 'url1']
     output = parse_all(lines)
     print output
     self.assertEqual(output, [{'line':'dog', 'phone': 'AO1G', 'syllables':1, 'url':'url1', 'last_word':'dog'}])