def testMoveSlots(self): c = SlottedContainer() c.id = "container" c.slotNames = ['head','hand'] thing = Item(id='thing') thing.fitsInSlots = ['hand','head'] c.add(thing,'hand') self.assertEquals(c.slots['hand'](),thing) self.assertEquals(thing.location(),c) self.assertEquals(thing.locationSlot,'hand') c.add(thing,'head') self.assertEquals(c.slots['head'](),thing) self.assertEquals(thing.location(),c) self.assertEquals(thing.locationSlot,'head')
def testSlotted(self): c = SlottedContainer() c.id = "container" c.slotNames = ['hand'] thing = Item(id='thing') thing.fitsInSlots = ['hand'] c.add(thing,'hand') self.assertEquals(c.slots['hand'](),thing) self.assertEquals(thing.location(),c) self.assertEquals(thing.locationSlot,'hand') c.remove(thing) self.assertFalse(thing.location) self.assertFalse(thing.locationSlot) self.assertRaises(GameException,c.add,thing,'head')