def testObjectRecovery(self):
        """Test the parsing of the config recovering any webadmin modules mentioned.
        """
        test_config = """
        [director]
        msg_host = "127.0.0.1"
        msg_port = 61613
        msg_username = ''
        msg_password = ''
        msg_channel = 'evasion'
        disable_broker = no
        poll_time = 1

        [broker]
        host="localhost"
        port=61613
        
        [agency]
        #disabled = 'yes'

            [aardvark]
            #disabled = 'yes'
            cat = swipe
            agent = myswipe

            [bat]
            #disabled = 'yes'
            cat = swipe
            agent = myswipe

        [webadmin]
        host="127.0.0.1"
        port=29837

        [checkdir]
        controller = 'director.controllers.commandline'
        command = "ls"
        workingdir = "/tmp"
        
        [somerandomsection]
        # This will be ignored entirely and will not appear in the recovered objects.
        bob = '1234'
        uptime = True

        """
        objs = config.recover_objects(test_config)
        
        # This should only contain 6 as the agents should be part of 
        # the agency.agents member:
        self.assertEquals(len(objs), 5)
        
        # This is the default order in which the objects should be recovered:
        self.assertEquals(objs[0].name, 'director')
        self.assertEquals(objs[0].order, 0)
        self.assertEquals(objs[1].name, 'broker')
        self.assertEquals(objs[1].order, 1)
        self.assertEquals(objs[2].name, 'agency')
        self.assertEquals(objs[2].order, 2)
        self.assertEquals(objs[3].name, 'webadmin')
        self.assertEquals(objs[3].order, 3)
        self.assertEquals(objs[4].name, 'checkdir')
        self.assertEquals(objs[4].order, 4)
        
        # Check the agents are present:
        agents = objs[2].agents
        self.assertEquals(len(agents), 2)
        
        # Check the default ordering of the recovered agents:
        self.assertEquals(agents[0].name, 'aardvark')
        self.assertEquals(agents[0].order, 0)
        self.assertEquals(agents[1].name, 'bat')
        self.assertEquals(agents[1].order, 1)
    def testOrdering(self):
        """Test the ordering of configuration objects.
        """
        test_config = """
        [director]
        # The director is a hardcoded order of 0. The is not much 
        # point ordering before it as the director runs all the 
        # other parts and the order has no effect on it.
        
        [broker]
        order = 4
        
        [agency]
        order = 2

            [aardvark]
            order = 1
            cat = swipe
            agent = myswipe

            [bat]
            order = 0
            cat = swipe
            agent = myswipe

        [webadmin]
        order = 1

        [checkdir]
        order = 3
        controller = 'director.controllers.commandline'
        command = "ls"
        workingdir = "/tmp"
        webadmin = 'bob.webadmin'

        """
        objs = config.recover_objects(test_config)
        
        # This should only contain 5 as the agents should be part of 
        # the agency.agents member:
        self.assertEquals(len(objs), 5)
        
        # This is the default order in which the objects should be recovered:
        self.assertEquals(objs[0].name, 'director')
        self.assertEquals(objs[0].order, 0)
        self.assertEquals(objs[1].name, 'webadmin')
        self.assertEquals(objs[1].order, 1)
        self.assertEquals(objs[2].name, 'agency')
        self.assertEquals(objs[2].order, 2)
        self.assertEquals(objs[3].name, 'checkdir')
        self.assertEquals(objs[3].order, 3)
        self.assertEquals(objs[4].name, 'broker')
        self.assertEquals(objs[4].order, 4)
        
        # Check the agents are present:
        agents = objs[2].agents
        self.assertEquals(len(agents), 2)
        
        # Check the default ordering of the recovered agents:
        self.assertEquals(agents[0].name, 'bat')
        self.assertEquals(agents[0].order, 0)
        self.assertEquals(agents[1].name, 'aardvark')
        self.assertEquals(agents[1].order, 1)