aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'pmstestsuite/library/standard/dbus_case.py')
-rw-r--r--pmstestsuite/library/standard/dbus_case.py140
1 files changed, 8 insertions, 132 deletions
diff --git a/pmstestsuite/library/standard/dbus_case.py b/pmstestsuite/library/standard/dbus_case.py
index ac9c4d1..14258b7 100644
--- a/pmstestsuite/library/standard/dbus_case.py
+++ b/pmstestsuite/library/standard/dbus_case.py
@@ -2,143 +2,19 @@
# (c) 2011-2012 Michał Górny <mgorny@gentoo.org>
# Released under the terms of the 2-clause BSD license.
-import dbus.service
-
from pmstestsuite.library.case import EbuildTestCase
from pmstestsuite.library.depend_case import EbuildDependencyTestCase, \
EclassDependencyTestCase
from pmstestsuite.library.eclass_case import EclassTestCase
-from pmstestsuite.dbus_handler import DBusHandler, dbus_interface_name, dbus_object_prefix
-
-dbus_handler = DBusHandler()
-
-class DBusBaseTestCase(dbus.service.Object):
- """ A base D-Bus test case class. """
-
- def __init__(self):
- """
- Initialize the D-Bus interface for the test.
- """
- self.reset()
- dbus.service.Object.__init__(
- self,
- dbus_handler.bus,
- '%s/%s' % (dbus_object_prefix, self.p.replace('-', '_'))
- )
-
- def reset(self):
- """
- Reset test results.
- """
- self.dbus_output = []
- self.dbus_started = False
-
- @dbus.service.method(
- dbus_interface=dbus_interface_name,
- in_signature='', out_signature='')
- def test_started(self):
- """
- Notify the test suite that a particular test has been started.
- """
- self.dbus_started = True
-
- @dbus.service.method(
- dbus_interface=dbus_interface_name,
- in_signature='s', out_signature='')
- def append_output(self, l):
- """
- Append the string to the test output.
-
- @param l: result string
- @type l: C{dbus.UTF8String}
- """
- self.dbus_output.append(str(l))
-
- def _finalize(self):
- """
- Finalize the object, ensuring that C{pkg_setup()} will be called.
- """
- if self.phase_funcs['pkg_setup']:
- self.phase_funcs['pkg_setup'].insert(0, 'pms-test_pkg_setup')
-
- def check_dbus_result(self, output, pm):
- """
- Check whether the output sent through D-Bus matches expected test
- output.
-
- The default implementation simply checks whether the test was merged
- alike L{EbuildTestCase.check_result()}.
-
- @param output: the D-Bus output
- @type output: list(str)
- @param pm: the package manager instance
- @type pm: L{PackageManager}
- @return: C{True} if output matches expected test result, C{False}
- otherwise
- @rtype: bool
- """
- pass
-
- def _pop_dbus_output(self):
- ret = self.dbus_output
- self.reset()
- return ret
-
- def check_result(self, pm):
- self.assertTrue(self.dbus_started, 'build started')
- self.check_dbus_result(self._pop_dbus_output(), pm)
-
-class DBusEbuildTestCase(DBusBaseTestCase, EbuildTestCase):
- """ D-Bus capable ebuild test case. """
-
- def __init__(self, *args, **kwargs):
- """ Initialize the test case and the D-Bus object for it. """
- EbuildTestCase.__init__(self, *args, **kwargs)
- DBusBaseTestCase.__init__(self)
-
- def check_dbus_result(self, output, pm):
- EbuildTestCase.check_result(self, pm)
-
-class DBusEclassTestCase(DBusBaseTestCase, EclassTestCase):
- """ D-Bus capable eclass test case. """
-
- def __init__(self, *args, **kwargs):
- """ Initialize the test case and the D-Bus object for it. """
- EclassTestCase.__init__(self, *args, **kwargs)
- DBusBaseTestCase.__init__(self)
-
- def check_dbus_result(self, output, pm):
- EclassTestCase.check_result(self, pm)
-
-class DBusEbuildDependencyTestCase(DBusBaseTestCase, EbuildDependencyTestCase):
- """ D-Bus capable dependency test case. """
-
- def __init__(self, *args, **kwargs):
- """ Initialize the test case and the D-Bus object for it. """
- EbuildDependencyTestCase.__init__(self, *args, **kwargs)
- DBusBaseTestCase.__init__(self)
-
- def check_dbus_result(self, output, pm):
- EbuildDependencyTestCase.check_result(self, pm)
-
- def check_result(self, pm):
- started = self.dbus_started
- self.check_dbus_result(self._pop_dbus_output(), pm)
- self.assertBool(not self.expect_failure, started, 'build started')
-
-class DBusEclassDependencyTestCase(DBusBaseTestCase, EclassDependencyTestCase):
- """ D-Bus capable eclass dependency test case. """
+class DBusEbuildTestCase(EbuildTestCase):
+ pass
- def __init__(self, *args, **kwargs):
- """ Initialize the test case and the D-Bus object for it. """
- EclassDependencyTestCase.__init__(self, *args, **kwargs)
- DBusBaseTestCase.__init__(self)
+class DBusEclassTestCase(EclassTestCase):
+ pass
- def check_dbus_result(self, output, pm):
- EclassDependencyTestCase.check_result(self, pm)
+class DBusEbuildDependencyTestCase(EbuildDependencyTestCase):
+ pass
- def check_result(self, pm):
- started = self.dbus_started
- self.check_dbus_result(self._pop_dbus_output(), pm)
- self.assertBool(not self.expect_failure, started, 'build started')
+class DBusEclassDependencyTestCase(EclassDependencyTestCase):
+ pass