def test_same_send(self): ''' Tests that identical tweets are properly handled ''' tweet1 = Tweet("text 1", "something.something", "corn") tweet2 = Tweet("text 1", "something.something", "corn") tweets = [tweet1, tweet2] poem = Poem(tweets, "corn", "couplet") sendPoem(self.twitter, poem) self.assertEqual(poem.hashtag, tweet1.hashtag)
def test_newline_send(self): ''' Tests that newlines are appropriately handled ''' tweet1 = Tweet("text 1\n", "something.something", "corn") tweet2 = Tweet("text 2\n", "somethingelse.something", "corn") tweets = [tweet1, tweet2] poem = Poem(tweets, "corn", "couplet") sendPoem(self.twitter, poem) self.assertEqual(poem.hashtag, tweet1.hashtag)
def test_empty_send(self): ''' Tests that empty strings are properly handled ''' tweet1 = Tweet("", "something.something", "corn") tweet2 = Tweet("", "somethingelse.something", "corn") tweets = [tweet1, tweet2] poem = Poem(tweets, "corn", "couplet") sendPoem(self.twitter, poem) self.assertEqual(poem.hashtag, tweet1.hashtag)
def test_basic_send(self): ''' Tests a basic tweet is sent ''' tweet1 = Tweet("text 1", "something.something", "corn") tweet2 = Tweet("text 2", "somethingelse.something", "corn") tweets = [tweet1, tweet2] poem = Poem(tweets, "corn", "couplet") sendPoem(self.twitter, poem) self.assertEqual(poem.hashtag, tweet1.hashtag)
def sendtweet(): """request to submit a generated poem to twitter""" print "sending tweet" print request.form["id"] twitter = connect() poem = Poem.query.filter_by(id=request.form["id"]).first() if poem is None: abort(404) sendPoem(twitter, poem) print "send success" return redirect(url_for("poem", id=str(poem.id)))
def test_zero_send(self): ''' Tests on an empty list of tweets ''' tweets = [] poem = Poem(tweets, "corn", "couplet") sendPoem(self.twitter, poem)