def testComponentWithPlug(self): c = Component() c.name = 'name' c.componentType = 'streamer' c.worker = 'worker' plug = Plug() plug.plugType = 'plug-type' plug.properties.foo = 'bar' c.plugs.append(plug) writer = ConfigurationWriter('flow', [c], []) testsuite.diffStrings( ('<planet>\n' ' <flow name="flow">\n' ' <component name="name"\n' ' type="streamer"\n' ' project="flumotion"\n' ' worker="worker"\n' ' version="%(version)s">\n' ' \n' ' <plugs>\n' ' <plug type="plug-type">\n' ' \n' ' <property name="foo">bar</property>\n' ' </plug>\n' ' </plugs>\n' ' </component>\n' ' </flow>\n' '</planet>\n' % dict(version=configure.version)), writer.getXML())
def testComponentWithPlug(self): c = Component() c.name = 'name' c.componentType = 'streamer' c.worker = 'worker' plug = Plug() plug.plugType = 'plug-type' plug.properties.foo = 'bar' c.plugs.append(plug) writer = ConfigurationWriter('flow', [c], []) testsuite.diffStrings( XMLWriter.encoding + \ ('<planet>\n' ' <flow name="flow">\n' ' <component name="name"\n' ' type="streamer"\n' ' project="flumotion"\n' ' worker="worker"\n' ' version="%(version)s">\n' ' \n' ' <plugs>\n' ' <plug type="plug-type">\n' ' \n' ' <property name="foo">bar</property>\n' ' </plug>\n' ' </plugs>\n' ' </component>\n' ' </flow>\n' '</planet>\n' % dict(version=configure.version)), writer.getXML())
def testComponentWithFeeders(self): c1 = Component() c1.name = 'name' c1.componentType = 'first' c1.worker = 'worker' c2 = Component() c2.name = 'name' c2.componentType = 'second' c2.worker = 'worker' c2.link(c1) writer = ConfigurationWriter('flow', [c1, c2], []) testsuite.diffStrings( ('<planet>\n' ' <flow name="flow">\n' ' <component name="name"\n' ' type="first"\n' ' project="flumotion"\n' ' worker="worker"\n' ' version="%(version)s">\n' ' <eater name="default">\n' ' <feed>name</feed>\n' ' </eater>\n' ' </component>\n' ' <component name="name"\n' ' type="second"\n' ' project="flumotion"\n' ' worker="worker"\n' ' version="%(version)s">\n' ' </component>\n' ' </flow>\n' '</planet>\n' % dict(version=configure.version)), writer.getXML())
def testEmpty(self): writer = ConfigurationWriter('', [], []) testsuite.diffStrings( XMLWriter.encoding + \ ("<planet>\n" "</planet>\n"), writer.getXML())
def testComponentWithFeeders(self): c1 = Component() c1.name = 'name' c1.componentType = 'first' c1.worker = 'worker' c2 = Component() c2.name = 'name' c2.componentType = 'second' c2.worker = 'worker' c2.link(c1) writer = ConfigurationWriter('flow', [c1, c2], []) testsuite.diffStrings( XMLWriter.encoding + \ ('<planet>\n' ' <flow name="flow">\n' ' <component name="name"\n' ' type="first"\n' ' project="flumotion"\n' ' worker="worker"\n' ' version="%(version)s">\n' ' <eater name="default">\n' ' <feed>name</feed>\n' ' </eater>\n' ' </component>\n' ' <component name="name"\n' ' type="second"\n' ' project="flumotion"\n' ' worker="worker"\n' ' version="%(version)s">\n' ' </component>\n' ' </flow>\n' '</planet>\n' % dict(version=configure.version)), writer.getXML())
def getXML(self): """Creates an XML configuration of the state set @returns: the xml configuration @rtype: string """ self._handleProducers() self._handleMuxers() # Naming conflicts can only be solved after the rest is done, # since some components might get removed self._resolveNameConflicts() self._validateComponents() writer = ConfigurationWriter(self._flowName, self._flowComponents, self._atmosphereComponents) xml = writer.getXML() return xml
def testFlowComponent(self): c = Component() c.name = 'name' c.componentType = 'streamer' c.worker = 'worker' writer = ConfigurationWriter('flow', [c], []) testsuite.diffStrings( ('<planet>\n' ' <flow name="flow">\n' ' <component name="name"\n' ' type="streamer"\n' ' project="flumotion"\n' ' worker="worker"\n' ' version="%(version)s">\n' ' </component>\n' ' </flow>\n' '</planet>\n' % dict(version=configure.version)), writer.getXML())
def testFlowComponent(self): c = Component() c.name = 'name' c.componentType = 'streamer' c.worker = 'worker' writer = ConfigurationWriter('flow', [c], []) testsuite.diffStrings( XMLWriter.encoding + \ ('<planet>\n' ' <flow name="flow">\n' ' <component name="name"\n' ' type="streamer"\n' ' project="flumotion"\n' ' worker="worker"\n' ' version="%(version)s">\n' ' </component>\n' ' </flow>\n' '</planet>\n' % dict(version=configure.version)), writer.getXML())
def getXML(self): """Creates an XML configuration of the state set @returns: the xml configuration @rtype: string """ if self._confXml: return self._confXml self._handleProducers() self._handleMuxers() # Naming conflicts can only be solved after the rest is done, # since some components might get removed self._resolveNameConflicts() self._validateComponents() writer = ConfigurationWriter(self._flowName, self._flowComponents, self._atmosphereComponents) xml = writer.getXML() return xml
def testAtmosphereComponent(self): c = Component() c.name = 'name' c.componentType = 'streamer' c.worker = 'worker' c.properties.foo = 'bar' writer = ConfigurationWriter('', [], [c]) testsuite.diffStrings( ('<planet>\n' ' <atmosphere>\n' ' <component name="name"\n' ' type="streamer"\n' ' project="flumotion"\n' ' worker="worker"\n' ' version="%(version)s">\n' ' \n' ' <property name="foo">bar</property>\n' ' </component>\n' ' </atmosphere>\n' '</planet>\n' % dict(version=configure.version)), writer.getXML())
def testAtmosphereComponent(self): c = Component() c.name = 'name' c.componentType = 'streamer' c.worker = 'worker' c.properties.foo = 'bar' writer = ConfigurationWriter('', [], [c]) testsuite.diffStrings( XMLWriter.encoding + \ ('<planet>\n' ' <atmosphere>\n' ' <component name="name"\n' ' type="streamer"\n' ' project="flumotion"\n' ' worker="worker"\n' ' version="%(version)s">\n' ' \n' ' <property name="foo">bar</property>\n' ' </component>\n' ' </atmosphere>\n' '</planet>\n' % dict(version=configure.version)), writer.getXML())