r6264 - in flumotion/trunk: . flumotion/manager flumotion/test
flumotion-commit at lists.fluendo.com
flumotion-commit at lists.fluendo.com
Wed Feb 20 16:19:39 CET 2008
Author: jdahlin
Date: Wed Feb 20 16:19:37 2008
New Revision: 6264
Log:
2008-02-20 Johan Dahlin <jdahlin at async.com.br>
* flumotion/test/test_manager_config.py:
* flumotion/manager/config.py:
Add a new test file
* flumotion/test/Makefile.am:
Reindent and remove trailing whitespace
Added:
flumotion/trunk/flumotion/test/test_manager_config.py (contents, props changed)
Modified:
flumotion/trunk/ChangeLog
flumotion/trunk/flumotion/manager/config.py
flumotion/trunk/flumotion/test/Makefile.am
Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog (original)
+++ flumotion/trunk/ChangeLog Wed Feb 20 16:19:37 2008
@@ -1,3 +1,12 @@
+2008-02-20 Johan Dahlin <jdahlin at async.com.br>
+
+ * flumotion/test/test_manager_config.py:
+ * flumotion/manager/config.py:
+ Add a new test file
+
+ * flumotion/test/Makefile.am:
+ Reindent and remove trailing whitespace
+
2008-02-20 Johan Dahlin <johan at gnome.org>
* flumotion/test/test_component_httpserver.py
Modified: flumotion/trunk/flumotion/manager/config.py
==============================================================================
--- flumotion/trunk/flumotion/manager/config.py (original)
+++ flumotion/trunk/flumotion/manager/config.py Wed Feb 20 16:19:37 2008
@@ -117,7 +117,7 @@
if eater is None:
if not eaterDefs:
raise errors.ConfigError(
- "Feed %r cannot be connected, component has no eaters" %
+ "Feed %r cannot be connected, component has no eaters" %
(feedId,))
# cope with old <source> entries
eater = eaterDefs[0].getName()
@@ -505,7 +505,7 @@
# </planet>
root = self.doc.documentElement
if root.nodeName != 'planet':
- raise errors.ConfigError("unexpected root node': %s" %
+ raise errors.ConfigError("unexpected root node': %s" %
(root.nodeName,))
parsers = {'atmosphere': (self._parseAtmosphere,
@@ -517,7 +517,7 @@
self.doc.unlink()
self.doc = None
-
+
def _parseAtmosphere(self, node):
# <atmosphere>
# <component>
@@ -637,7 +637,7 @@
def _parseParameters(self):
root = self.doc.documentElement
if not root.nodeName == 'planet':
- raise errors.ConfigError("unexpected root node': %s" %
+ raise errors.ConfigError("unexpected root node': %s" %
(root.nodeName,))
parsers = {'atmosphere': (_ignore, _ignore),
@@ -693,7 +693,7 @@
self.bouncer = val
def parseplugs(node):
return fluconfig.buildPlugsSet(self.parsePlugs(node),
- self.MANAGER_SOCKETS)
+ self.MANAGER_SOCKETS)
def gotplugs(newplugs):
for socket in self.plugs:
self.plugs[socket].extend(newplugs[socket])
@@ -715,7 +715,7 @@
# </planet>
root = self.doc.documentElement
if not root.nodeName == 'planet':
- raise errors.ConfigError("unexpected root node': %s" %
+ raise errors.ConfigError("unexpected root node': %s" %
(root.nodeName,))
parsers = {'atmosphere': (_ignore, _ignore),
Modified: flumotion/trunk/flumotion/test/Makefile.am
==============================================================================
--- flumotion/trunk/flumotion/test/Makefile.am (original)
+++ flumotion/trunk/flumotion/test/Makefile.am Wed Feb 20 16:19:37 2008
@@ -60,6 +60,7 @@
test_keycards.py \
test_logfilter.py \
test_manager_admin.py \
+ test_manager_config.py \
test_manager_manager.py \
test_manager_worker.py \
test_misc_httpfile.py \
Added: flumotion/trunk/flumotion/test/test_manager_config.py
==============================================================================
--- (empty file)
+++ flumotion/trunk/flumotion/test/test_manager_config.py Wed Feb 20 16:19:37 2008
@@ -0,0 +1,109 @@
+# -*- Mode: Python; test-case-name: flumotion.test.test_manager_config -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# Flumotion - a streaming media server
+# Copyright (C) 2004,2005,2006,2007,2008 Fluendo, S.L. (www.fluendo.com).
+# All rights reserved.
+
+# This file may be distributed and/or modified under the terms of
+# the GNU General Public License version 2 as published by
+# the Free Software Foundation.
+# This file is distributed without any warranty; without even the implied
+# warranty of merchantability or fitness for a particular purpose.
+# See "LICENSE.GPL" in the source distribution for more information.
+
+# Licensees having purchased or holding a valid Flumotion Advanced
+# Streaming Server license may use this file in accordance with the
+# Flumotion Advanced Streaming Server Commercial License Agreement.
+# See "LICENSE.Flumotion" in the source distribution for more information.
+
+# Headers in this file shall remain intact.
+
+from cStringIO import StringIO
+
+from flumotion.common import testsuite
+from flumotion.common.errors import ConfigError
+from flumotion.manager.config import ManagerConfigParser, ConfigEntryManager, \
+ ConfigEntryComponent
+
+__version__ = "$Rev$"
+
+def flatten(seq):
+ rv = []
+ for item in seq:
+ rv.extend(item)
+ return rv
+
+def build(child, extra=''):
+ return StringIO('<planet><manager%s>%s</manager></planet>' % (
+ extra, child))
+
+
+class TestConfigParser(testsuite.TestCase):
+ def testParseEmpty(self):
+ f = StringIO("")
+ self.assertRaises(ConfigError, ManagerConfigParser, f)
+
+ def testParseSimple(self):
+ f = StringIO("<planet/>")
+ parser = ManagerConfigParser(f)
+ self.failIf(parser.manager)
+
+ def testParseManager(self):
+ f = build("""<host>mhost</host>
+ <port>999</port>
+ <transport>tcp</transport>
+ <certificate>manager.cert</certificate>
+ <debug>true</debug>""",
+ extra=' name="mname"')
+ parser = ManagerConfigParser(f)
+ self.failUnless(parser.manager)
+ manager = parser.manager
+ self.failUnless(isinstance(manager, ConfigEntryManager))
+ self.assertEquals(manager.name, 'mname')
+ self.assertEquals(manager.host, 'mhost')
+ self.assertEquals(manager.port, 999)
+ self.assertEquals(manager.transport, 'tcp')
+ self.assertEquals(manager.certificate, 'manager.cert')
+ self.assertEquals(manager.fludebug, 'true')
+
+ def testParseManagerInvalid(self):
+ f = build('<transport>foo</transport>')
+ self.assertRaises(ConfigError, ManagerConfigParser, f)
+ f = build('<xxx/>')
+ self.assertRaises(ConfigError, ManagerConfigParser, f)
+ f = build('<host>xxx</host><host>xxx</host>')
+ self.assertRaises(ConfigError, ManagerConfigParser, f)
+ f = build('<host><xxx/></host>')
+ self.assertRaises(ConfigError, ManagerConfigParser, f)
+
+ def testParseBouncerComponent(self):
+ f = build("""<component name="foobar" type="bouncer"/>""")
+ parser = ManagerConfigParser(f)
+ self.failIf(parser.bouncer)
+ parser.parseBouncerAndPlugs()
+ self.failUnless(parser.bouncer)
+ self.failUnless(isinstance(parser.bouncer, ConfigEntryComponent))
+ self.assertEquals(parser.bouncer.type, 'bouncer')
+ self.assertEquals(parser.bouncer.name, 'foobar')
+
+ def testParsePlugs(self):
+ f = build("""<plugs>
+ <plug socket="flumotion.component.plugs.adminaction.AdminAction"
+ type="adminactionfilelogger">
+ <property name="logfile">/dev/stdout</property>
+ </plug>
+ </plugs>""")
+ parser = ManagerConfigParser(f)
+ self.failIf(flatten(parser.plugs.values()))
+ parser.parseBouncerAndPlugs()
+ values = flatten(parser.plugs.values())
+ self.failUnless(values)
+ first = values[0]
+ self.failUnless(isinstance(first, dict))
+ self.failUnless('type' in first)
+ self.assertEquals(first['type'], 'adminactionfilelogger')
+ self.failUnless('properties' in first)
+ properties = first['properties']
+ self.failUnless('logfile' in properties)
+ self.assertEquals(properties['logfile'], '/dev/stdout')
More information about the flumotion-commit
mailing list