Exemplo n.º 1
0
 def test_tell(self):
     rat = MsgTraceNPC("rat", "n", "rodent")
     self.assertTrue(rat._init_called, "init() must be called from __init__")
     julie = MsgTraceNPC("julie", "f", "human")
     hall = Location("hall")
     hall.livings = [rat, julie]
     hall.tell("roommsg")
     self.assertEqual(["roommsg"], rat.messages)
     self.assertEqual(["roommsg"], julie.messages)
     rat.clearmessages()
     julie.clearmessages()
     hall.tell("roommsg", rat, [julie], "juliemsg")
     self.assertEqual([], rat.messages)
     self.assertEqual(["juliemsg"], julie.messages)
Exemplo n.º 2
0
 def test_tell(self):
     rat = MsgTraceNPC("rat", "n", "rodent")
     self.assertTrue(rat._init_called,
                     "init() must be called from __init__")
     julie = MsgTraceNPC("julie", "f", "human")
     hall = Location("hall")
     hall.livings = [rat, julie]
     hall.tell("roommsg")
     self.assertEqual(["roommsg"], rat.messages)
     self.assertEqual(["roommsg"], julie.messages)
     rat.clearmessages()
     julie.clearmessages()
     hall.tell("roommsg", rat, [julie], "juliemsg")
     self.assertEqual([], rat.messages)
     self.assertEqual(["juliemsg"], julie.messages)
Exemplo n.º 3
0
 def test_wiretap(self):
     attic = Location("Attic", "A dark attic.")
     player = Player("fritz", "m")
     io = ConsoleIo(None)
     io.supports_smartquotes = False
     pc = PlayerConnection(player, io)
     player.set_screen_sizes(0, 100)
     julie = NPC("julie", "f")
     julie.move(attic)
     player.move(attic)
     julie.tell("message for julie")
     attic.tell("message for room")
     self.assertEqual(["message for room\n"], player.test_get_output_paragraphs())
     with self.assertRaises(ActionRefused):
         player.create_wiretap(julie)
     player.privileges = {"wizard"}
     player.create_wiretap(julie)
     player.create_wiretap(attic)
     julie.tell("message for julie")
     attic.tell("message for room")
     pubsub.sync()
     output = pc.get_output()
     self.assertTrue("[wiretapped from 'Attic': message for room]" in output)
     self.assertTrue("[wiretapped from 'julie': message for julie]" in output)
     self.assertTrue("[wiretapped from 'julie': message for room]" in output)
     self.assertTrue("message for room " in output)
     # test removing the wiretaps
     player.clear_wiretaps()
     import gc
     gc.collect()
     julie.tell("message for julie")
     attic.tell("message for room")
     self.assertEqual(["message for room\n"], player.test_get_output_paragraphs())
Exemplo n.º 4
0
 def test_wiretap(self):
     attic = Location("Attic", "A dark attic.")
     player = Player("fritz", "m")
     io = ConsoleIo(None)
     io.supports_smartquotes = False
     pc = PlayerConnection(player, io)
     player.set_screen_sizes(0, 100)
     julie = NPC("julie", "f")
     julie.move(attic)
     player.move(attic)
     julie.tell("message for julie")
     attic.tell("message for room")
     self.assertEqual(["message for room\n"],
                      player.test_get_output_paragraphs())
     with self.assertRaises(ActionRefused):
         player.create_wiretap(julie)
     player.privileges = {"wizard"}
     player.create_wiretap(julie)
     player.create_wiretap(attic)
     julie.tell("message for julie")
     attic.tell("message for room")
     pubsub.sync()
     output = pc.get_output()
     self.assertTrue(
         "[wiretapped from 'Attic': message for room]" in output)
     self.assertTrue(
         "[wiretapped from 'julie': message for julie]" in output)
     self.assertTrue(
         "[wiretapped from 'julie': message for room]" in output)
     self.assertTrue("message for room " in output)
     # test removing the wiretaps
     player.clear_wiretaps()
     import gc
     gc.collect()
     julie.tell("message for julie")
     attic.tell("message for room")
     self.assertEqual(["message for room\n"],
                      player.test_get_output_paragraphs())