def testPutFailWrongSize(self): """check that you can't put too big an object in""" self.cmd.dirobj = actor1 try: invoke(self.obj, IContainer, 'put', self.cmd, False) except pub.errors.SizeError: pass
def testUnlockFailNotLocked(self): """check that you can't unlock what is not locked""" invoke(self.obj, ILockable, 'unlock') try: invoke(self.obj, ILockable, 'unlock', self.cmd, False) except pub.errors.StateError: pass
def testGetFailSize(self): """check that you can't pick up too big items""" self.obj.moveTo(self.room) self.obj.size = 150 #Test it try: invoke(self.obj, ICarriable, 'get', self.cmd) except pub.SizeError: pass
def testLockFailLocked(self): """checks that a locked object returns an error if locked.""" self.com.isLocked = True try: invoke(self.obj, ILockL, 'lock', self.cmd, False) except pub.errors.StateError: pass else: self.fail("Expected a StateError")
def testAskFailNoAboutObj(self): """check that not having an aboutobj raises an error""" self.cmd.aboutobj = '' try: invoke(self.obj, IAskL, 'ask', self.cmd, False) except pub.errors.ObjError: pass else: self.fail("Expected an ObjError")
def testPutFailOnSelf(self): """check that you can't put an object into itself.""" self.cmd.dirobj = self.obj try: invoke(self.obj, IContainer, 'put', self.cmd, False) except pub.errors.TargetError: pass
def testDropFailNotHave(self): """check that you need to have the object in your inventory""" self.obj.moveTo(self.room) #Test it try: invoke(self.obj, ICarriable, 'drop', self.cmd) except pub.InventoryError: pass
def testUnlockFailNoKey(self): """check that not having the key returns an error""" invoke(self.obj, ILockable, 'lock') self.key.moveTo(self.room) try: invoke(self.obj, ILockable, 'unlock', self.cmd, False) except pub.errors.InventoryError: pass
def testUnlockFailNotLocked(self): """check that unlocking a not locked object will result in an error""" self.obj.isLocked = False try: invoke(self.obj, IUnlockL, 'unlock', self.cmd, False) except pub.errors.StateError: pass else: self.fail("Expected a StateError")
def testGetFailSize(self): """check that you can't pick up too big items""" self.obj.moveTo(self.room) self.obj.size = 150 #Test it try: invoke(self.obj, ICarriable, 'get', self.cmd) except pub.SizeError: pass
def testGiveFailNoToObj(self): """check that having no toObj raises an error""" self.cmd.toObj = '' try: invoke(self.obj, IGiveL, 'give', self.cmd, False) except pub.errors.ObjError: pass else: self.fail("Expected an ObjError")
def testGoFailNoDest(self): """checks that you get an error when the exit doesn't have a room reference""" self.obj.dest = None try: invoke(self.obj, IGo, 'go', self.cmd, False) except pub.errors.DestinationError: pass else: self.fail('Expected a DestinationError')
def testCloseFailOpen(self): """check that the test fails if the object is closed""" self.com.isOpen = False try: invoke(self.obj, ICloseL, 'close', self.cmd, False) except pub.errors.StateError: pass else: self.fail("Expected a StateError")
def testDropFailNoInventory(self): """check that you can't drop what you don't have""" self.obj.moveTo(self.actor.getRoom()) try: invoke(self.obj, IDropL, 'drop', self.cmd, False) except pub.errors.InventoryError: pass else: self.fail("Expected an InventoryError")
def testLockFailLocked(self): """checks that a locked object returns an error if locked.""" self.com.isLocked = True try: invoke(self.obj, ILockL, 'lock', self.cmd, False) except pub.errors.StateError: pass else: self.fail("Expected a StateError")
def testGiveFailNotHave(self): """check that you need to have the object before giving it away""" self.obj.moveTo(self.room) self.actor2 = pub.objs.Actor() self.actor2.moveTo(self.room) self.cmd.dirobj = self.actor2 #Test it try: invoke(self.obj, ICarriable, 'give', self.cmd) except pub.InventoryError: pass
def testAskFailNoAboutObj(self): """check that not having an aboutobj raises an error""" self.cmd.aboutobj = '' try: invoke(self.obj, IAskL, 'ask', self.cmd, False) except pub.errors.ObjError: pass else: self.fail("Expected an ObjError")
def testUnlockFailNotLocked(self): """check that unlocking a not locked object will result in an error""" self.obj.isLocked = False try: invoke(self.obj, IUnlockL, 'unlock', self.cmd, False) except pub.errors.StateError: pass else: self.fail("Expected a StateError")
def testGiveFailNotHave(self): """check that you need to have the object before giving it away""" self.obj.moveTo(self.room) self.actor2 = pub.objs.Actor() self.actor2.moveTo(self.room) self.cmd.dirobj = self.actor2 #Test it try: invoke(self.obj, ICarriable, 'give', self.cmd) except pub.InventoryError: pass
def testGoFailNoDest(self): """checks that you get an error when the exit doesn't have a room reference""" self.obj.dest = None try: invoke(self.obj, IGo, 'go', self.cmd, False) except pub.errors.DestinationError: pass else: self.fail('Expected a DestinationError')
def testGiveDone(self): """check that you can give away a normal object""" self.obj.moveTo(self.actor) self.actor2 = pub.objs.Actor() self.actor2.moveTo(self.room) self.cmd.dirobj = self.actor2 #Test it self.assert_(invoke(self.obj, ICarriable, 'give', self.cmd))
def testGiveDone(self): """check that you can give away a normal object""" self.obj.moveTo(self.actor) self.actor2 = pub.objs.Actor() self.actor2.moveTo(self.room) self.cmd.dirobj = self.actor2 #Test it self.assert_(invoke(self.obj, ICarriable, 'give', self.cmd) )
def testCloseFailClosed(self): invoke(self.obj, IOpenablel, 'close') # No cmdObject try: invoke(self.obj, IOpenable, 'close', self.cmd, False) except pub.errors.StateError: pass
def testDropDone(self): """check that you can put the object into your own container.""" self.obj.moveTo(self.actor) #Test it self.assert_(invoke(self.obj, ICarriable, 'drop', self.cmd))
def testPutDone(self): """check that you can put an object somewhere.""" self.cmd.dirobj = self.normObj self.assert_(invoke(self.obj, IContainer, 'put', self.cmd) )
def testCanContain(self): """check that the container can contain the direct object""" self.assert_(invoke(self.obj, IContainer, 'canContain', self.cmd) )
def testDropDone(self): """check that you can put the object into your own container.""" self.obj.moveTo(self.actor) #Test it self.assert_(invoke(self.obj, ICarriable, 'drop', self.cmd) )
def testReceiveDone(self): self.assert_(invoke(self.obj, ISentience, 'receive', self.cmd, False))
def testGetDone(self): """check that you are able to pick up an object.""" self.obj.moveTo(self.room) #Test it self.assert_(invoke(self.obj, ICarriable, 'get', self.cmd) )
def testCloseDone(self): invoke(self.obj, IOpenable, 'open') self.assert_(invoke(self.obj, IOpenable, 'close', self.cmd, False))
def testCloseFailClosed(self): invoke(self.obj, IOpenablel, 'close') # No cmdObject try: invoke(self.obj, IOpenable, 'close', self.cmd, False) except pub.errors.StateError: pass
def testOpenFailOpen(self): invoke(self.obj, IOpenable, 'open') # No cmdObject try: invoke(self.obj, IOpenable, 'open', self.cmd, False) except pub.errors.StateError: pass
def testOpenDone(self): invoke(self.obj, IOpenable, 'close') # No cmdObject self.assert_(invoke(self.obj, IOpenable, 'open', self.cmd, False))
def testGetDone(self): """check that you are able to pick up an object.""" self.obj.moveTo(self.room) #Test it self.assert_(invoke(self.obj, ICarriable, 'get', self.cmd))
def testContainNoCheck(self): """move direct object into container""" self.assert_(invoke(self.obj, IContainer, 'containNoCheck', self.cmd))
def testCloseDone(self): """check that the component can be closed, given that it is open""" self.assert_(invoke(self.obj, ICloseL, 'close', self.cmd, False))
def testWearL(self): """check that an object can be worn.""" self.assert_(invoke(self.obj, IWearL, 'wear', self.cmd, False) )
def testPutFailWrongSize(self): """check that you can't put too big an object in""" self.cmd.dirobj = actor1 try: invoke(self.obj, IContainer, 'put', self.cmd, False) except pub.errors.SizeError: pass
def testPutDone(self): """check that you can put an object somewhere.""" self.cmd.dirobj = self.normObj self.assert_(invoke(self.obj, IContainer, 'put', self.cmd))
def testLockDone(self): """check that you can lock the obj""" invoke(self.obj, ILockable, 'unlock') self.assert_(invoke(self.obj, ILockable, 'lock', self.cmd, False) )
def testDropFailNotHave(self): """check that you need to have the object in your inventory""" self.obj.moveTo(self.room) #Test it try: invoke(self.obj, ICarriable, 'drop', self.cmd) except pub.InventoryError: pass
def testUnlockFailNoKey(self): """check that not having the key returns an error""" invoke(self.obj, ILockable, 'lock') self.key.moveTo(self.room) try: invoke(self.obj, ILockable, 'unlock', self.cmd, False) except pub.errors.InventoryError: pass
def testAskDone(self): """check that we can ask about things in the topics""" self.assert_(invoke(self.obj, IAskL, 'ask', self.cmd, False))
def testLockDone(self): """check that you can lock the obj""" invoke(self.obj, ILockable, 'unlock') self.assert_(invoke(self.obj, ILockable, 'lock', self.cmd, False))
def testContainNoCheck(self): """move direct object into container""" self.assert_(invoke(self.obj, IContainer, 'containNoCheck', self.cmd) )
def testOpenFailOpen(self): invoke(self.obj, IOpenable, 'open') # No cmdObject try: invoke(self.obj, IOpenable, 'open', self.cmd, False) except pub.errors.StateError: pass
def testPutFailOnSelf(self): """check that you can't put an object into itself.""" self.cmd.dirobj = self.obj try: invoke(self.obj, IContainer, 'put', self.cmd, False) except pub.errors.TargetError: pass
def testUnlockDone(self): """check that the object can be unlocked""" invoke(self.obj, ILockable, 'lock') self.assert_(invoke(self.obj, ILockable, 'unlock', self.cmd, False))
def testAskDone(self): """check that we can ask about things in the topics""" self.assert_(invoke(self.obj, IAskL, 'ask', self.cmd, False))
def testWearL(self): """check that an object can be worn.""" self.assert_(invoke(self.obj, IWearL, 'wear', self.cmd, False))
def testUnlockDone(self): """check that the object can be unlocked""" invoke(self.obj, ILockable, 'lock') self.assert_(invoke(self.obj, ILockable, 'unlock', self.cmd, False) )
def testReceiveDone(self): """test that you can receive an object.""" self.assert_(invoke(self.obj, IReceiveL, 'receive', self.cmd, False) )
def testUnlockFailNotLocked(self): """check that you can't unlock what is not locked""" invoke(self.obj, ILockable, 'unlock') try: invoke(self.obj, ILockable, 'unlock', self.cmd, False) except pub.errors.StateError: pass
def testRemoveDone(self): """tests that an object can be removed""" self.assert_(invoke(self.obj, IRemoveL, 'remove', self.cmd, False) )
def testOpenDone(self): invoke(self.obj, IOpenable, 'close') # No cmdObject self.assert_(invoke(self.obj, IOpenable, 'open', self.cmd, False) )
def testTurnL(self): """check that an object can be turned.""" self.assert_(invoke(self.obj, ITurnL, 'turn', self.cmd, False) )
def testCloseDone(self): invoke(self.obj, IOpenable, 'open') self.assert_(invoke(self.obj, IOpenable, 'close', self.cmd, False) )
def testUnlockLDone(self): """check that an object can be unlocked.""" self.assert_(invoke(self.obj, IUnlockL, 'unlock', self.cmd, False) )
def testReceiveDone(self): self.assert_(invoke(self.obj, ISentience, 'receive', self.cmd, False) )
def testCanContain(self): """check that the container can contain the direct object""" self.assert_(invoke(self.obj, IContainer, 'canContain', self.cmd))