Ejemplo n.º 1
0
 def test_get_password(self):
     """Password gleaned correctly from config file"""
     
     c = Configurator()
     c.fromString(configdata)
     self.assertEqual(len(c), 2)
     self.assertEqual(c.getPassword(), 'password123')
Ejemplo n.º 2
0
    def test_case_insensitivity(self):
        """Authentication section name should be case insensitive"""
        
        c = Configurator()
        c.fromString(configdata2)

        self.assertEqual(len(c), 2)
        self.assertEqual(c.getPassword(), 'password123')
Ejemplo n.º 3
0
    def test_password(self):
        """Aggregator should have random password"""

        assert type(self.aggregator.getPassword()) == type("")

        # ensure a second instance has differing password ...
        conf = Configurator()
        conf.fromString('')
        other = Aggregator(conf)
        assert other.getPassword() != self.aggregator.getPassword()
Ejemplo n.º 4
0
    def setUpClass(self):
        """Start a DeviceServer in a child process to test against"""

        self.deviceserverprocess = SubProcessProtocol()
        self.deviceserverprocess.waitOnStartUp( ['server.py', 'deviceserver.conf', '-n'], \
                                                path=os.path.join(agdevicecontrol.path,'bin') )

        if self.deviceserverprocess.running is False:
            raise unittest.SkipTest, "DeviceServer didn't start correctly, skipping tests"

        #wait for slow single CPU buildbots to catch up
        import time
        time.sleep(1)

        # use the config above
        conf = Configurator()
        conf.fromString(configdata)

        # can be set by timeout
        self.failure = False


        # safety timeout
        self.timeout = reactor.callLater(10, self.failed, "Aggregator failed to connect to all deviceservers ... failing")
        
        self.aggregator = Aggregator(conf)
        self.done = False
        while not self.done:
            print "Waiting for aggregator to connect to deviceservers"
            reactor.iterate(0.1)
            if self.aggregator.connected:
                self.succeeded()

        if self.failure:
            raise unittest.SkipTest, "Aggregator didn't connect to all deviceservers ... skipping tests"



        # FIXME: we really should handle missing and newly appearing deviceservers.

        # safety timeout
        self.timeout = reactor.callLater(10, self.failed, "Aggregator failed to map all deviceservers ... failing")

        self.aggregator.notifyOnMapped(self.succeeded)

        self.done = False
        while not self.done:
            print "Waiting for aggregator to map deviceservers"
            reactor.iterate(0.1)


        if self.failure:
            raise unittest.SkipTest, "Aggregator didn't start correctly, skipping tests"
Ejemplo n.º 5
0
    def setUp(self):
        """I'm called at the very beginning of each test"""

        c = Configurator()
        c.fromString(configdata)
        self.ds = DeviceServer(c)

        self.finished = False
        self.failed = None
        self.pending_deferreds = []

        # safety timeout
        self.timeout = reactor.callLater(10, self.timedOut)
Ejemplo n.º 6
0
 def test_load_from_string(self):
     """Create a config file from string data"""
     c = Configurator()
     c.fromString(configdata)
     self.assertIn('dev1', c)