def test_put_tweets_when_exist_same_tweet(self): data = [mock.Status(41, 40, u'same_tweet', u'text1'), mock.Status(41, 40, u'same_tweet', u'text1')] bot = OmiaiBot() bot._put_tweets(data) query = StatusModel.all() users = query.filter('id', 41L).fetch(2) eq_(len(users), 1)
def test_put_tweets_when_exist_same_user(self): data = [mock.Status(21, 20, u'same_user', u'text1'), mock.Status(22, 20, u'same_user', u'text2')] bot = OmiaiBot() bot._put_tweets(data) query = UserModel.all() users = query.filter('screen_name', u'same_user').fetch(2) eq_(len(users), 1)
def test_put_tweets_when_data_is_simple(self): data = [mock.Status(1, 1, u'user_name', u'text')] bot = OmiaiBot() bot._put_tweets(data) query = StatusModel.all() tweet = query.filter('id >', 0L).filter('id <', 10L).get() eq_(tweet.id, 1L) eq_(tweet.text, u'text') eq_(tweet.author.screen_name, u'user_name') eq_(tweet.updated, False)
def test_put_tweets_when_data_is_multiple(self): data = [mock.Status(11, 11, u'user1', u'text1'), mock.Status(12, 12, u'user2', u'text2')] bot = OmiaiBot() bot._put_tweets(data) query = StatusModel.all() tweets = query.filter('id >', 10L).filter('id <', 20L).fetch(2) eq_(tweets[0].id, 11L) eq_(tweets[0].text, u'text1') eq_(tweets[0].author.screen_name, u'user1') eq_(tweets[0].updated, False) eq_(tweets[1].id, 12L) eq_(tweets[1].text, u'text2') eq_(tweets[1].author.screen_name, u'user2') eq_(tweets[1].updated, False)