arek - in flumotion/trunk: . flumotion/test
flumotion-commit at lists.fluendo.com
flumotion-commit at lists.fluendo.com
Mon Jul 23 14:58:04 CEST 2007
Author: arek
Date: Mon Jul 23 14:58:02 2007
New Revision: 5339
Added:
flumotion/trunk/flumotion/test/comptest.py
- copied, changed from r5338, flumotion/trunk/flumotion/test/pond.py
flumotion/trunk/flumotion/test/test_comptest.py
- copied, changed from r5338, flumotion/trunk/flumotion/test/test_pond.py
Removed:
flumotion/trunk/flumotion/test/pond.py
flumotion/trunk/flumotion/test/test_pond.py
Modified:
flumotion/trunk/ChangeLog
flumotion/trunk/flumotion/test/Makefile.am
Log:
* flumotion/test/Makefile.am:
* flumotion/test/pond.py:
* flumotion/test/comptest.py:
* flumotion/test/test_pond.py:
* flumotion/test/test_comptest.py:
Rename 'Pond' -> 'ComponentTestHelper'.
Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog (original)
+++ flumotion/trunk/ChangeLog Mon Jul 23 14:58:02 2007
@@ -1,5 +1,14 @@
2007-07-23 Arek Korbik <arkadini at gmail.com>
+ * flumotion/test/Makefile.am:
+ * flumotion/test/pond.py:
+ * flumotion/test/comptest.py:
+ * flumotion/test/test_pond.py:
+ * flumotion/test/test_comptest.py:
+ Rename 'Pond' -> 'ComponentTestHelper'.
+
+2007-07-23 Arek Korbik <arkadini at gmail.com>
+
* flumotion/test/pond.py:
Fix component clock synchronization and startup dealy code; turn
some callback functions into less implicit helper functions.
Modified: flumotion/trunk/flumotion/test/Makefile.am
==============================================================================
--- flumotion/trunk/flumotion/test/Makefile.am (original)
+++ flumotion/trunk/flumotion/test/Makefile.am Mon Jul 23 14:58:02 2007
@@ -8,7 +8,7 @@
__init__.py \
common.py \
testclasses.py \
- pond.py \
+ comptest.py \
gtkunit.py \
realm.py
@@ -37,6 +37,7 @@
test_component_httpserver.py \
test_component_httpstreamer.py \
test_component_playlist.py \
+ test_comptest.py \
test_config.py \
test_credentials.py \
test_dag.py \
@@ -57,7 +58,6 @@
test_parts.py \
test_pb.py \
test_pbstream.py \
- test_pond.py \
test_porter.py \
test_reflect.py \
test_registry.py \
Copied: flumotion/trunk/flumotion/test/comptest.py (from r5338, flumotion/trunk/flumotion/test/pond.py)
==============================================================================
--- flumotion/trunk/flumotion/test/pond.py (original)
+++ flumotion/trunk/flumotion/test/comptest.py Mon Jul 23 14:58:02 2007
@@ -19,8 +19,8 @@
# Headers in this file shall remain intact.
-__all__ = ['Pond', 'PondUnitTestMixin', 'cleanup_reactor',
- 'pipeline_src', 'pipeline_cnv']
+__all__ = ['ComponentTestHelper', 'ComponentUnitTestMixin', 'pipeline_src',
+ 'pipeline_cnv']
import common
@@ -48,19 +48,19 @@
from flumotion.twisted import flavors
-class PondException(Exception):
+class ComponentTestException(Exception):
pass
-class WrongReactor(PondException):
+class WrongReactor(ComponentTestException):
pass
-class StartTimeout(PondException):
+class StartTimeout(ComponentTestException):
pass
-class FlowTimeout(PondException):
+class FlowTimeout(ComponentTestException):
pass
-class StopTimeout(PondException):
+class StopTimeout(ComponentTestException):
pass
@@ -85,7 +85,7 @@
class ComponentWrapper(object, log.Loggable):
- logCategory = 'pond-compwrap'
+ logCategory = 'comptest-compwrap'
_u_name_cnt = 0
_registry = None
@@ -181,7 +181,8 @@
sink_name = sink_comp.name
for feeder, eater in links:
if feeder not in self.cfg['feed']:
- raise PondException('Invalid feeder specified: %r' % feeder)
+ raise ComponentTestException('Invalid feeder specified: %r' %
+ feeder)
#self.cfg['feed'].append('%s:%s' % (sink_name, eater))
sink_comp.add_feeder(self, '%s:%s' % (self.name, feeder), eater)
#self.auto_link = False
@@ -212,8 +213,8 @@
return defer.succeed(None)
-class Pond(object, log.Loggable):
- logCategory = 'pond'
+class ComponentTestHelper(object, log.Loggable):
+ logCategory = 'comptest-helper'
guard_timeout = 60.0
guard_delay = 0.5
@@ -486,21 +487,21 @@
callids[1] = reactor.callLater(self.guard_timeout, flow_timed_out)
return guard_d
-class PondUnitTestMixin:
+class ComponentUnitTestMixin:
if not HAVE_GTK2REACTOR:
skip = 'gtk2reactor is required for this test case'
def cleanup_reactor(force=False):
if not HAVE_GTK2REACTOR and not force:
return
- log.debug('pond', 'running cleanup_reactor...')
+ log.debug('comptest', 'running cleanup_reactor...')
delayed = reactor.getDelayedCalls()
for dc in delayed:
dc.cancel()
# the rest is taken from twisted trial...
sels = reactor.removeAll()
if sels:
- log.info('pond', 'leftover selectables...: %r %r' %
+ log.info('comptest', 'leftover selectables...: %r %r' %
(sels, reactor.waker))
for sel in sels:
if interfaces.IProcessTransport.providedBy(sel):
Copied: flumotion/trunk/flumotion/test/test_comptest.py (from r5338, flumotion/trunk/flumotion/test/test_pond.py)
==============================================================================
--- flumotion/trunk/flumotion/test/test_pond.py (original)
+++ flumotion/trunk/flumotion/test/test_comptest.py Mon Jul 23 14:58:02 2007
@@ -32,50 +32,55 @@
from flumotion.common import log, errors
from flumotion.common.planet import moods
-from flumotion.test import pond
+from flumotion.test import comptest
+from flumotion.test.comptest import ComponentTestHelper, ComponentWrapper, \
+ ComponentUnitTestMixin, pipeline_src, pipeline_cnv
from flumotion.component.producers.pipeline.pipeline import Producer
from flumotion.component.converters.pipeline.pipeline import Converter
-class PondTestCase(log.Loggable, unittest.TestCase, pond.PondUnitTestMixin):
- logCategory = 'pond-test'
+class CompTestTestCase(log.Loggable, unittest.TestCase,
+ ComponentUnitTestMixin):
+ logCategory = 'comptest-test'
-class TestPondGtk2Reactorness(unittest.TestCase):
+class TestCompTestGtk2Reactorness(unittest.TestCase):
def test_mixin_class(self):
- class TestPondUnitTestMixin(unittest.TestCase, pond.PondUnitTestMixin):
+ class TestCompTestUnitTestMixin(unittest.TestCase,
+ ComponentUnitTestMixin):
pass
if not isinstance(sys.modules['twisted.internet.reactor'],
gtk2reactor.Gtk2Reactor):
- # not running with a gtk2reactor, TestPondUnitTestMixin
+ # not running with a gtk2reactor, TestCompTestUnitTestMixin
# class should have .skip attribute
- self.failUnless(hasattr(TestPondUnitTestMixin, 'skip'),
- "PondUnitTestMixin doesn't set .skip correctly.")
+ self.failUnless(hasattr(TestCompTestUnitTestMixin, 'skip'),
+ "ComponentUnitTestMixin doesn't set .skip"
+ " correctly.")
else:
- self.failIf(hasattr(TestPondUnitTestMixin, 'skip'),
- "PondUnitTestMixin sets .skip incorrectly.")
+ self.failIf(hasattr(TestCompTestUnitTestMixin, 'skip'),
+ "ComponentUnitTestMixin sets .skip incorrectly.")
def test_have_gtk2reactor(self):
if not isinstance(sys.modules['twisted.internet.reactor'],
gtk2reactor.Gtk2Reactor):
- # not running with a gtk2reactor, pond.HAVE_GTK2REACTOR
+ # not running with a gtk2reactor, comptest.HAVE_GTK2REACTOR
# should be False
- self.failUnlessEquals(pond.HAVE_GTK2REACTOR, False)
+ self.failUnlessEquals(comptest.HAVE_GTK2REACTOR, False)
else:
- self.failIfEquals(pond.HAVE_GTK2REACTOR, False)
+ self.failIfEquals(comptest.HAVE_GTK2REACTOR, False)
class TestComponentWrapper(unittest.TestCase):
def test_get_unique_name(self):
- self.failIfEquals(pond.ComponentWrapper.get_unique_name(),
- pond.ComponentWrapper.get_unique_name())
+ self.failIfEquals(ComponentWrapper.get_unique_name(),
+ ComponentWrapper.get_unique_name())
def test_invalid_type(self):
self.failUnlessRaises(errors.UnknownComponentError,
- pond.ComponentWrapper, 'invalid-comp-type',
+ ComponentWrapper, 'invalid-comp-type',
None)
def test_valid_type(self):
- cw = pond.ComponentWrapper('pipeline-producer', None, name='pp')
+ cw = ComponentWrapper('pipeline-producer', None, name='pp')
self.failUnlessEquals(cw.cfg,
{'feed': ['default'], 'name': 'pp',
'parent': 'default', 'clock-master': None,
@@ -85,20 +90,20 @@
def test_simple_link(self):
- pp = pond.ComponentWrapper('pipeline-producer', None, name='pp')
- pc = pond.ComponentWrapper('pipeline-converter', None)
+ pp = ComponentWrapper('pipeline-producer', None, name='pp')
+ pc = ComponentWrapper('pipeline-converter', None)
pp.feed(pc)
self.failUnlessEquals(pc.cfg['source'], ['pp:default'])
self.failUnlessEquals(pc.cfg['eater'], {'default': ['pp:default']})
def test_non_default_link(self):
- fwp = pond.ComponentWrapper('firewire-producer', None, name='fwp')
- pc = pond.ComponentWrapper('pipeline-converter', None, name='pc')
+ fwp = ComponentWrapper('firewire-producer', None, name='fwp')
+ pc = ComponentWrapper('pipeline-converter', None, name='pc')
# this should raise an exception - firewire-producer doesn't
# have a default feeder
- self.failUnlessRaises(pond.PondException, fwp.feed, pc)
+ self.failUnlessRaises(comptest.ComponentTestException, fwp.feed, pc)
fwp.feed(pc, [('video', 'default')])
fwp.feed(pc, [('audio', 'default')])
@@ -109,9 +114,9 @@
def test_instantiate_and_setup_errors(self):
- pp = pond.ComponentWrapper('pipeline-producer', None, name='pp')
+ pp = ComponentWrapper('pipeline-producer', None, name='pp')
self.failUnlessRaises(TypeError, pp.instantiate) # None()!?
- pp = pond.ComponentWrapper('pipeline-producer', Producer, name='pp')
+ pp = ComponentWrapper('pipeline-producer', Producer, name='pp')
pp.instantiate()
d = pp.setup()
@@ -119,12 +124,12 @@
# the deferred should fail (no mandatory pipeline property) -
# stop the component in any case (to clean the reactor) and
# passthrough the result/failure
- d.addBoth(pond.call_and_passthru_callback, pp.stop)
+ d.addBoth(comptest.call_and_passthru_callback, pp.stop)
return self.failUnlessFailure(d, errors.ComponentSetupHandledError)
def test_setup_pipeline_error(self):
- pp = pond.ComponentWrapper('pipeline-producer', Producer,
- name='pp', props={'pipeline': 'fakesink'})
+ pp = ComponentWrapper('pipeline-producer', Producer,
+ name='pp', props={'pipeline': 'fakesink'})
pp.instantiate()
# we're going to fail in gst - make sure the gst logger is silent
@@ -137,7 +142,7 @@
# the deferred should fail (the only pipeline element doesn't
# have source pads) - stop the component in any case (to clean
# the reactor) and passthrough the result/failure
- d.addBoth(pond.call_and_passthru_callback, pp.stop)
+ d.addBoth(comptest.call_and_passthru_callback, pp.stop)
if old_debug_level != gst.LEVEL_NONE:
def _restore_gst_debug_level(rf):
@@ -147,8 +152,8 @@
return self.failUnlessFailure(d, errors.ComponentSetupHandledError)
def test_setup_and_stop(self):
- pp = pond.ComponentWrapper('pipeline-producer', Producer,
- name='pp', props={'pipeline': 'fakesrc'})
+ pp = ComponentWrapper('pipeline-producer', Producer,
+ name='pp', props={'pipeline': 'fakesrc'})
pp.instantiate()
d = pp.setup()
@@ -156,14 +161,14 @@
d.addCallback(lambda _: pp.stop())
return d
-class TestPondSetup(PondTestCase):
+class TestCompTestSetup(CompTestTestCase):
def setUp(self):
- self.prod = pond.pipeline_src()
- self.cnv1 = pond.pipeline_cnv()
- self.cnv2 = pond.pipeline_cnv()
+ self.prod = pipeline_src()
+ self.cnv1 = pipeline_cnv()
+ self.cnv2 = pipeline_cnv()
self.components = [self.prod, self.cnv1, self.cnv2]
- self.p = pond.Pond()
+ self.p = ComponentTestHelper()
def tearDown(self):
return defer.DeferredList([c.stop() for c in self.components])
@@ -183,7 +188,7 @@
self.failUnlessEquals({'default': [cnv1_feed]}, self.cnv2.cfg['eater'])
def test_dont_auto_link_linked(self):
- p2 = pond.pipeline_src()
+ p2 = pipeline_src()
self.components.append(p2)
p2.feed(self.cnv1)
@@ -206,7 +211,7 @@
self.failUnlessEquals({'default': [prod_feed]}, self.cnv2.cfg['eater'])
def test_master_clock(self):
- p2 = pond.pipeline_src()
+ p2 = pipeline_src()
self.components.append(p2)
p2.feed(self.cnv1)
@@ -231,32 +236,32 @@
self.failUnlessEquals(master.sync, None)
self.failIfEquals(slave.sync, None)
-class TestPondFlow(PondTestCase):
+class TestCompTestFlow(CompTestTestCase):
def setUp(self):
self.duration = 2.0
prod_pp = ('videotestsrc is-live=true ! '
'video/x-raw-rgb,framerate=(fraction)8/1,'
'width=32,height=24')
- self.prod = pond.pipeline_src(prod_pp)
+ self.prod = pipeline_src(prod_pp)
- self.cnv1 = pond.pipeline_cnv()
- self.cnv2 = pond.pipeline_cnv()
+ self.cnv1 = pipeline_cnv()
+ self.cnv2 = pipeline_cnv()
- self.p = pond.Pond()
+ self.p = ComponentTestHelper()
def tearDown(self):
d = self.p.stop_flow()
# add cleanup, otherwise components a.t.m. don't cleanup after
# themselves too well, remove when fixed
- d.addBoth(lambda _: pond.cleanup_reactor())
+ d.addBoth(lambda _: comptest.cleanup_reactor())
return d
def test_setup_fail_gst_linking(self):
- p2 = pond.pipeline_src('fakesink') # this just can't work!
- c2 = pond.pipeline_cnv('fakesink') # and neither can this!
+ p2 = pipeline_src('fakesink') # this just can't work!
+ c2 = pipeline_cnv('fakesink') # and neither can this!
# we're going to fail in gst - make sure the gst logger is silent
import gst
@@ -284,8 +289,8 @@
return d
def test_run_fail_gst_linking(self):
- p2 = pond.pipeline_src('fakesink') # this just can't work!
- c2 = pond.pipeline_cnv('fakesink') # and neither can this!
+ p2 = pipeline_src('fakesink') # this just can't work!
+ c2 = pipeline_cnv('fakesink') # and neither can this!
# we're going to fail in gst - make sure the gst logger is silent
import gst
@@ -305,9 +310,9 @@
def test_run_start_timeout(self):
start_delay_time = 5.0
self.p.guard_timeout = 2.0
- class LingeringCompWrapper(pond.ComponentWrapper):
+ class LingeringCompWrapper(ComponentWrapper):
def start(self, *a, **kw):
- d = pond.ComponentWrapper.start(self, *a, **kw)
+ d = ComponentWrapper.start(self, *a, **kw)
def delay_start(result):
dd = defer.Deferred()
reactor.callLater(start_delay_time, dd.callback, result)
@@ -318,7 +323,7 @@
props={'pipeline': 'identity'})
self.p.set_flow([self.prod, c2])
d = self.p.run_flow(self.duration)
- return self.failUnlessFailure(d, pond.StartTimeout)
+ return self.failUnlessFailure(d, comptest.StartTimeout)
def test_run_with_delays(self):
self.p.start_delay = 0.5
@@ -331,10 +336,10 @@
p2_pp = ('videotestsrc is-live=true ! '
'video/x-raw-rgb,framerate=(fraction)8/1,'
'width=32,height=24')
- p2 = pond.pipeline_src(p2_pp)
+ p2 = pipeline_src(p2_pp)
from flumotion.component.muxers.multipart import Multipart
- mux = pond.ComponentWrapper('multipart-muxer', Multipart, name='mux')
+ mux = ComponentWrapper('multipart-muxer', Multipart, name='mux')
self.prod.feed(mux)
p2.feed(mux)
@@ -398,15 +403,15 @@
d = self.p.run_flow(self.duration, tasks=[task_d])
- return self.failUnlessFailure(d, pond.FlowTimeout)
+ return self.failUnlessFailure(d, comptest.FlowTimeout)
def test_run_stop_timeout(self):
stop_delay_time = 6.0
self.p.guard_timeout = 4.0
- class DelayingCompWrapper(pond.ComponentWrapper):
+ class DelayingCompWrapper(ComponentWrapper):
do_delay = True
def stop(self, *a, **kw):
- d = pond.ComponentWrapper.stop(self, *a, **kw)
+ d = ComponentWrapper.stop(self, *a, **kw)
def delay_stop(result):
if self.do_delay:
self.do_delay = False
@@ -420,7 +425,7 @@
props={'pipeline': 'identity'})
self.p.set_flow([self.prod, c2])
d = self.p.run_flow(self.duration)
- return self.failUnlessFailure(d, pond.StopTimeout)
+ return self.failUnlessFailure(d, comptest.StopTimeout)
def test_run_started_then_fails(self):
self.p.set_flow([self.prod, self.cnv1, self.cnv2])
@@ -449,10 +454,10 @@
class CustomStopException(Exception):
pass
- class BrokenCompWrapper(pond.ComponentWrapper):
+ class BrokenCompWrapper(ComponentWrapper):
do_break = True
def stop(self, *a, **kw):
- d = pond.ComponentWrapper.stop(self, *a, **kw)
+ d = ComponentWrapper.stop(self, *a, **kw)
def delay_stop(result):
# breaking once should be enough
if self.do_break:
@@ -468,7 +473,7 @@
pass
def insert_flow_errors(_):
def insert_error(_ignore):
- raise CustomFlowException("This pond is too small!")
+ raise CustomFlowException("Exception!")
d = defer.Deferred()
d.addCallback(insert_error)
reactor.callLater(flow_error_timeout, d.callback, None)
More information about the flumotion-commit
mailing list