def test_equality(self): "Two rooms should be considered equal if they have the same name, description, objects, and exits" name, desc, exits = self.room.name, self.room.description, self.room.exits objs = [Dresser(), Lamp(), Bed()] other_room = Room(name, objs, desc, exits) # equal self.assertTrue(self.room == other_room) other_room.objects.pop() # not equal self.assertFalse(self.room == other_room)
def setUp(self): self.dresser = Dresser() self.bed = Bed() self.lamp = Lamp() self.chair = Chair() self.room = Room(name="Room", objects=[self.dresser, self.bed, self.lamp], description="A room.", exits={}) self.southern_room = Room(name='', objects=[], description='', exits={'north': self.room}) self.room.exits['south'] = self.southern_room
def test_action_with_adj_when_two_objects_have_same_name(self): """When two objects have the same name but a distinguishing adjective is provided, should perform the action on the correct object""" brass_lamp = Lamp() brass_lamp.description = "A brass lamp with a tarnished base." brass_lamp.on_description = "The light turns on." brass_lamp.off_description = "The light turns off." self.room.objects.append(brass_lamp) # adjective is in object.name action = "light brass lamp" self.assertEquals(parse(action, self.room, self.inv), brass_lamp.on_description) self.assertTrue(brass_lamp.is_lit) # adjective is in object.description action = "snuff tarnished lamp" parse(action, self.room, self.inv) self.assertFalse(brass_lamp.is_lit)
def setUp(self): self.dresser = Dresser() self.bed = Bed() self.lamp = Lamp() self.unreachable_lamp = UnreachableLamp() self.chair = Chair()