def testAnswerAQuestion(self): question = Question.from_mention({ "id" : 12345, "user" : { "screen_name": "testusername"}, "text": "@username restaurants collingwood" }) client = Mock() oracle = Mock({"answer": "cheesy cheese"}) twitterbot = TwitterBot(client, oracle, None) twitterbot.answer(question) client.mockCheckCall(0, "reply", 12345, "testusername", "cheesy cheese") oracle.mockCheckCall(0, "answer", "restaurants collingwood")
def test_should_shorten_answers(self): question = Question.from_mention({ "id" : 12345, "user" : { "screen_name": "testusername"}, "text": "@username restaurants collingwood" }) client = Mock() oracle = Mock({"answer": "http://longurl.com/blah/cheesy/cheese"}) urlshortener = Mock({"shorten": "http://shorturl.com/edam", "__nonzero__": 1}) twitterbot = TwitterBot(client, oracle, urlshortener) twitterbot.answer(question) oracle.mockCheckCall(0, "answer", "restaurants collingwood") urlshortener.mockCheckCall(0, "__nonzero__") urlshortener.mockCheckCall(1, "shorten", "http://longurl.com/blah/cheesy/cheese") client.mockCheckCall(0, "reply", 12345, "testusername", "http://shorturl.com/edam")