コード例 #1
0
 def test_OpenPortal(self):
     self.assertSimple(
         OpenPortal('foo', 'ore', 'joe'), {
             'action': 'openportal',
             'subject': 'foo',
             'ore': 'ore',
             'portal_user': '******'
         })
コード例 #2
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
    def usedPortal(self):
        self.world = World(MagicMock())
        self.place = self.world.create('place')
        self.ore = self.world.create('ore')
        self.bot = self.world.create('bot')
        self.lander = self.world.create('lander')

        Move(self.ore['id'], self.place['id']).execute(self.world)
        OpenPortal(self.bot['id'], self.ore['id'],
                   self.lander['id']).execute(self.world)
        UsePortal(self.lander['id'], self.ore['id']).execute(self.world)
コード例 #3
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
    def test_open(self):
        """
        You can open a portal on from some ore.
        """
        world = World(MagicMock())
        ore = world.create('ore')
        bot = world.create('bot')
        OpenPortal(bot['id'], ore['id'], 'user').execute(world)

        self.assertEqual(
            ore['portal_user'], 'user', "Should set the portal "
            "user to the id of the user that can use the portal")
        self.assertEqual(ore['kind'], 'portal')
コード例 #4
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
    def test_openerDies(self):
        """
        If the opener dies before the portal is used, the portal reverts to
        ore.
        """
        world = World(MagicMock())
        ore = world.create('ore')
        bot = world.create('bot')
        OpenPortal(bot['id'], ore['id'], 'user').execute(world)

        # it is death to move to the void
        Move(bot['id'], None).execute(world)

        self.assertEqual(ore['kind'], 'ore')
        self.assertNotIn('portal_user', ore)
コード例 #5
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
    def test_portal_user_noMatch(self):
        """
        It is NotAllowed to use a portal with a portal_user different than the
        thing trying to use the portal.
        """
        world = World(MagicMock())
        place = world.create('place')
        ore = world.create('ore')
        bot = world.create('bot')
        lander = world.create('lander')
        imposter = world.create('imposter')

        Move(ore['id'], place['id']).execute(world)
        OpenPortal(bot['id'], ore['id'], lander['id']).execute(world)
        self.assertRaises(NotAllowed,
                          UsePortal(imposter['id'], ore['id']).execute, world)
コード例 #6
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
 def test_subject(self):
     self.assertEqual(OpenPortal('foo', 'bar', 'baz').subject(), 'foo')
コード例 #7
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
 def test_emitters(self):
     self.assertEqual(
         OpenPortal('me', 'ore', 'user').emitters(), ['me', 'user'])
コード例 #8
0
ファイル: test_action.py プロジェクト: iffy/xatrobots
 def test_IAction(self):
     verifyObject(IAction, OpenPortal('me', 'ore', 'user'))
コード例 #9
0
 def test_OpenPortal(self):
     self.assertSimple(OpenPortal('foo', 'ore', 'joe'),
                       'foo used ore to open a portal for joe')