Пример #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))