class TestSpecialTopic(IFPTestCase): def setUp(self): super().setUp() self.actor = Actor(self.game, "shepherd") self.actor.moveTo(self.start_room) self.verb_keyword = "ask" self.subject_phrase = "how come" suggestion = " ".join([self.verb_keyword, self.subject_phrase]) self.text = "He shakes his head sadly." topic = SpecialTopic(self.game, suggestion, self.text) self.actor.addSpecialTopic(topic) self.game.turnMain("hi") def test_take_conversation_suggestion_with_verb_keyword(self): self.game.turnMain(self.verb_keyword) self.assertIn(self.text, self.app.print_stack) def test_take_conversation_suggestion_without_verb_keyword(self): self.game.turnMain(self.subject_phrase) self.assertIn(self.text, self.app.print_stack)
def test_accept_suggestion(self): girl = Actor(self.game, "girl") TOPIC_SUGGESTION = "ask what her name is" TOPIC_TEXT = '"It\'s Karen," says the girl.' topic = SpecialTopic(self.game, TOPIC_SUGGESTION, TOPIC_TEXT) girl.addSpecialTopic(topic) self.start_room.addThing(girl) self.game.turnMain("talk to girl") self.assertTrue(self.game.parser.command.specialTopics) self.game.turnMain(TOPIC_SUGGESTION) msg = self.app.print_stack.pop(-2) self.assertEqual( msg, TOPIC_TEXT, "Expected topic text to print after accepting suggestion" )