Exemple #1
0
 def test_exits(self):
     hall = Location("hall")
     attic = Location("attic")
     exit1 = Exit("ladder1", attic, "The first ladder leads to the attic.")
     exit2 = Exit("up", attic, "Second ladder to attic.")
     exit3 = Exit("ladder3", attic, "Third ladder to attic.")
     exit4 = Exit("window", attic, "A window.",
                  "A window, maybe if you open it you can get out?")
     hall.add_exits([exit1, exit2, exit3, exit4])
     self.assertTrue(hall.exits["up"] is exit2)
     self.assertTrue(hall.exits["ladder3"] is exit3)
     self.assertTrue(hall.exits["window"] is exit4)
     self.assertEqual([
         '[hall]',
         'The first ladder leads to the attic. Third ladder to attic. Second ladder to attic. A window.'
     ], strip_text_styles(hall.look()))
     self.assertEqual("Third ladder to attic.", exit3.description)
     self.assertEqual("A window, maybe if you open it you can get out?",
                      exit4.description)
     with self.assertRaises(ActionRefused):
         exit1.activate(None)
     with self.assertRaises(ActionRefused):
         exit1.deactivate(None)
     with self.assertRaises(ActionRefused):
         exit1.close(None, None)
     with self.assertRaises(ActionRefused):
         exit1.open(None, None)
     with self.assertRaises(ActionRefused):
         exit1.lock(None, None)
     with self.assertRaises(ActionRefused):
         exit1.unlock(None, None)
     with self.assertRaises(ActionRefused):
         exit1.manipulate("frobnitz", None)
     with self.assertRaises(ActionRefused):
         exit1.read(None)
 def test_exits(self):
     hall = Location("hall")
     attic = Location("attic")
     exit1 = Exit("ladder1", attic, "The first ladder leads to the attic.")
     exit2 = Exit("up", attic, "Second ladder to attic.")
     exit3 = Exit("ladder3", attic, "Third ladder to attic.")
     exit4 = Exit("window", attic, "A window.", "A window, maybe if you open it you can get out?")
     hall.add_exits([exit1, exit2, exit3, exit4])
     self.assertTrue(hall.exits["up"] is exit2)
     self.assertTrue(hall.exits["ladder3"] is exit3)
     self.assertTrue(hall.exits["window"] is exit4)
     self.assertEqual(['[hall]', 'The first ladder leads to the attic. Third ladder to attic. Second ladder to attic. A window.'], strip_text_styles(hall.look()))
     self.assertEqual("Third ladder to attic.", exit3.description)
     self.assertEqual("A window, maybe if you open it you can get out?", exit4.description)
     with self.assertRaises(ActionRefused):
         exit1.activate(None)
     with self.assertRaises(ActionRefused):
         exit1.deactivate(None)
     with self.assertRaises(ActionRefused):
         exit1.close(None, None)
     with self.assertRaises(ActionRefused):
         exit1.open(None, None)
     with self.assertRaises(ActionRefused):
         exit1.lock(None, None)
     with self.assertRaises(ActionRefused):
         exit1.unlock(None, None)
     with self.assertRaises(ActionRefused):
         exit1.manipulate("frobnitz", None)
     with self.assertRaises(ActionRefused):
         exit1.read(None)