def testParseSimple(self): f = self._buildPlanet('') config = PlanetConfigParser(f) config.parse() self.failIf(config.flows) self.failIf(config.path) self.failIf(config.atmosphere.components)
def testParseAtmosphereWithComponent(self): f = self._buildAtmosphere( '<component name="cname" type="http-server" worker="worker"/>') config = PlanetConfigParser(f) config.parse() components = config.atmosphere.components self.failUnless(components) self.failUnless('cname' in components) component = components.pop('cname') self.failUnless(component) self.failUnless(isinstance(component, ConfigEntryComponent)) self.assertEquals(component.worker, 'worker') self.assertEquals(component.type, 'http-server') self.assertEquals(component.config['avatarId'], '/atmosphere/cname') self.failIf(flatten(component.config['plugs'].values()))
def testParseAtmosphereInvalid(self): f = self._buildAtmosphere( '<component name="cname" type="http-server" worker="worker">' ' <clock-master>true</clock-master>' '</component>') config = PlanetConfigParser(f) self.assertRaises(ConfigError, config.parse)
def testParseFlowInvalid(self): # missing name f = self._buildPlanet('<flow/>') config = PlanetConfigParser(f) self.assertRaises(ConfigError, config.parse) # invalid name for name in ['atmosphere', 'manager']: f = self._buildFlow('', name=name) config = PlanetConfigParser(f) self.assertRaises(ConfigError, config.parse) # multiple clock master f = self._buildFlow( '<component name="one" type="http-server" worker="worker">' ' <clock-master>true</clock-master>' '</component>' '<component name="two" type="http-server" worker="worker">' ' <clock-master>true</clock-master>' '</component>') config = PlanetConfigParser(f) self.assertRaises(ConfigError, config.parse)
def testParseFlow(self): f = self._buildFlow( '<component name="audio" type="audiotest-producer" ' 'worker="worker">' ' <clock-master>true</clock-master>' '</component>' '<component name="video" type="videotest-producer" ' 'worker="worker">' '</component>') config = PlanetConfigParser(f) config.parse() self.failUnless(config.flows) self.assertEquals(len(config.flows), 1) components = config.flows[0].components self.failUnless(components) self.failUnless('video' in components) component = components.pop('audio') self.assertEquals(component.type, 'audiotest-producer') self.assertEquals(component.config['clock-master'], '/flow/audio') component = components.pop('video') self.assertEquals(component.type, 'videotest-producer') self.assertEquals(component.config['clock-master'], '/flow/audio') self.failIf(components)
def testParseAtmosphereEmpty(self): f = self._buildAtmosphere('') config = PlanetConfigParser(f) config.parse() self.failIf(config.atmosphere.components)
def testParseInvalid(self): f = StringIO("<xxx/>") config = PlanetConfigParser(f) self.assertRaises(ConfigError, config.parse)