示例#1
0
 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
示例#2
0
 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
示例#3
0
 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
示例#4
0
    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")
示例#5
0
    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")
示例#6
0
 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
示例#7
0
 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
示例#8
0
 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
示例#9
0
    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")
示例#10
0
 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
示例#11
0
 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")
示例#12
0
    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')
示例#13
0
 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")
示例#14
0
 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")
示例#15
0
    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")
示例#16
0
 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
示例#17
0
    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")
示例#18
0
    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")
示例#19
0
    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
示例#20
0
    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')
示例#21
0
    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))
示例#22
0
 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) )
示例#23
0
 def testCloseFailClosed(self):
     invoke(self.obj, IOpenablel, 'close') # No cmdObject
     try: invoke(self.obj, IOpenable, 'close', self.cmd, False)
     except pub.errors.StateError: pass
示例#24
0
 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))
示例#25
0
 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) )
示例#26
0
 def testCanContain(self):
     """check that the container can contain the direct object"""
     self.assert_(invoke(self.obj, IContainer, 'canContain', self.cmd) )
示例#27
0
 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) )
示例#28
0
 def testReceiveDone(self):
     self.assert_(invoke(self.obj, ISentience, 'receive', self.cmd, False))
示例#29
0
 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) )
示例#30
0
 def testCloseDone(self):
     invoke(self.obj, IOpenable, 'open')
     self.assert_(invoke(self.obj, IOpenable, 'close', self.cmd, False))
示例#31
0
 def testCloseFailClosed(self):
     invoke(self.obj, IOpenablel, 'close')  # No cmdObject
     try:
         invoke(self.obj, IOpenable, 'close', self.cmd, False)
     except pub.errors.StateError:
         pass
示例#32
0
 def testOpenFailOpen(self):
     invoke(self.obj, IOpenable, 'open')  # No cmdObject
     try:
         invoke(self.obj, IOpenable, 'open', self.cmd, False)
     except pub.errors.StateError:
         pass
示例#33
0
 def testOpenDone(self):
     invoke(self.obj, IOpenable, 'close')  # No cmdObject
     self.assert_(invoke(self.obj, IOpenable, 'open', self.cmd, False))
示例#34
0
 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))
示例#35
0
 def testContainNoCheck(self):
     """move direct object into container"""
     self.assert_(invoke(self.obj, IContainer, 'containNoCheck', self.cmd))
示例#36
0
 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))
示例#37
0
    def testWearL(self):
        """check that an object can be worn."""

        self.assert_(invoke(self.obj, IWearL, 'wear', self.cmd, False) )
示例#38
0
 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
示例#39
0
 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))
示例#40
0
 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) )
示例#41
0
 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
示例#42
0
 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
示例#43
0
    def testAskDone(self):
        """check that we can ask about things in the topics"""

        self.assert_(invoke(self.obj, IAskL, 'ask', self.cmd, False))
示例#44
0
 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))
示例#45
0
 def testContainNoCheck(self):
     """move direct object into container"""
     self.assert_(invoke(self.obj, IContainer, 'containNoCheck', self.cmd) 
     )
示例#46
0
 def testOpenFailOpen(self):
     invoke(self.obj, IOpenable, 'open') # No cmdObject
     try: invoke(self.obj, IOpenable, 'open', self.cmd, False)
     except pub.errors.StateError: pass
示例#47
0
 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
示例#48
0
 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))
示例#49
0
    def testAskDone(self):
        """check that we can ask about things in the topics"""

        self.assert_(invoke(self.obj, IAskL, 'ask', self.cmd, False))
示例#50
0
    def testWearL(self):
        """check that an object can be worn."""

        self.assert_(invoke(self.obj, IWearL, 'wear', self.cmd, False))
示例#51
0
 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) )
示例#52
0
 def testReceiveDone(self):
     """test that you can receive an object."""
     
     self.assert_(invoke(self.obj, IReceiveL, 'receive', self.cmd, False) )
示例#53
0
 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
示例#54
0
    def testRemoveDone(self):
        """tests that an object can be removed"""

        self.assert_(invoke(self.obj, IRemoveL, 'remove', self.cmd, False) )
示例#55
0
 def testOpenDone(self):
     invoke(self.obj, IOpenable, 'close') # No cmdObject
     self.assert_(invoke(self.obj, IOpenable, 'open', self.cmd, False) )
示例#56
0
    def testTurnL(self):
        """check that an object can be turned."""

        self.assert_(invoke(self.obj, ITurnL, 'turn', self.cmd, False) )
示例#57
0
 def testCloseDone(self):
     invoke(self.obj, IOpenable, 'open')
     self.assert_(invoke(self.obj, IOpenable, 'close', self.cmd, False) )
示例#58
0
    def testUnlockLDone(self):
        """check that an object can be unlocked."""

        self.assert_(invoke(self.obj, IUnlockL, 'unlock', self.cmd, False) )
示例#59
0
 def testReceiveDone(self):
     self.assert_(invoke(self.obj, ISentience, 'receive', self.cmd, False) )
示例#60
0
 def testCanContain(self):
     """check that the container can contain the direct object"""
     self.assert_(invoke(self.obj, IContainer, 'canContain', self.cmd))