Merge lp:~larryprice/libertine/fix-service-test-sigs into lp:libertine

Proposed by Larry Price
Status: Merged
Approved by: Christopher Townsend
Approved revision: 409
Merged at revision: 436
Proposed branch: lp:~larryprice/libertine/fix-service-test-sigs
Merge into: lp:libertine
Diff against target: 81 lines (+27/-22)
1 file modified
tests/integration/test_libertine_service.py (+27/-22)
To merge this branch: bzr merge lp:~larryprice/libertine/fix-service-test-sigs
Reviewer Review Type Date Requested Status
Christopher Townsend Approve
Libertine CI Bot continuous-integration Approve
Review via email: mp+319599@code.launchpad.net

Commit message

Update signal handlers in test_libertine_service to reflect new API.

Description of the change

Update signal handlers in test_libertine_service to reflect new API. This will fix the test failures which occur when the signals are actually fired.

To post a comment you must log in.
409. By Larry Price

attach signals in setup

Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:408
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/459/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/846
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/696
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=zesty,testname=default/696
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/696
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=zesty,testname=default/696
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/856
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/848
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/848/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/848
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/848/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/848
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/848/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/848
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/848/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/459/rebuild

review: Approve (continuous-integration)
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:409
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/460/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/847
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/697
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=zesty,testname=default/697
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/697
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=zesty,testname=default/697
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/857
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/849
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/849/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/849
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/849/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/849
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/849/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/849
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/849/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/460/rebuild

review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Ok, good, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/integration/test_libertine_service.py'
2--- tests/integration/test_libertine_service.py 2017-03-07 19:41:49 +0000
3+++ tests/integration/test_libertine_service.py 2017-03-10 16:38:39 +0000
4@@ -71,11 +71,19 @@
5 self.error = None
6 self.result = None
7 self.event = threading.Event()
8+ self.signals = []
9
10 for retries in range(1, 11):
11 try:
12 self._bus = dbus.SessionBus()
13 self._libertined = self._bus.get_object(constants.SERVICE_NAME, constants.OPERATIONS_OBJECT)
14+
15+ self.signals.append(self._bus.add_signal_receiver(path=constants.OPERATIONS_MONITOR_OBJECT, handler_function=self._finished_handler,
16+ dbus_interface=constants.OPERATIONS_MONITOR_INTERFACE, signal_name='finished'))
17+ self.signals.append(self._bus.add_signal_receiver(path=constants.OPERATIONS_MONITOR_OBJECT, handler_function=self._data_handler,
18+ dbus_interface=constants.OPERATIONS_MONITOR_INTERFACE, signal_name='data'))
19+ self.signals.append(self._bus.add_signal_receiver(path=constants.OPERATIONS_MONITOR_OBJECT, handler_function=self._error_handler,
20+ dbus_interface=constants.OPERATIONS_MONITOR_INTERFACE, signal_name='error'))
21 break
22 except dbus.DBusException as e:
23 print("Service not available (attempt %i/10). Exception: %s" % (retries, str(e)))
24@@ -85,39 +93,36 @@
25 except Exception as e:
26 self.fail('Exception occurred during connection: %s' % str(e))
27
28+ def tearDown(self):
29+ for signal in self.signals:
30+ self._bus._clean_up_signal_match(signal)
31+
32 def _finished_handler(self, path):
33- self.event.set()
34-
35- def _data_handler(self, message):
36- self.result = message
37-
38- def _error_handler(self, message):
39- self.error = message
40- self.event.set()
41+ if self.path == path:
42+ self.event.set()
43+
44+ def _data_handler(self, path, message):
45+ if self.path == path:
46+ self.result = message
47+
48+ def _error_handler(self, path, message):
49+ if self.path == path:
50+ self.error = message
51+ self.event.set()
52
53 def _send(self, func):
54 self.event.clear()
55 self.result = None
56
57- obj_path = func()
58- signals = []
59- signals.append(self._bus.add_signal_receiver(path=constants.OPERATIONS_MONITOR_OBJECT, handler_function=self._finished_handler,
60- dbus_interface=constants.OPERATIONS_MONITOR_INTERFACE, signal_name='finished'))
61- signals.append(self._bus.add_signal_receiver(path=constants.OPERATIONS_MONITOR_OBJECT, handler_function=self._data_handler,
62- dbus_interface=constants.OPERATIONS_MONITOR_INTERFACE, signal_name='data'))
63- signals.append(self._bus.add_signal_receiver(path=constants.OPERATIONS_MONITOR_OBJECT, handler_function=self._error_handler,
64- dbus_interface=constants.OPERATIONS_MONITOR_INTERFACE, signal_name='error'))
65+ self.path = func()
66
67 monitor = self._bus.get_object(constants.SERVICE_NAME, constants.OPERATIONS_MONITOR_OBJECT)
68- if monitor.running(obj_path):
69+ if monitor.running(self.path):
70 self.event.wait(5)
71 self.assertIsNone(self.error)
72
73- self.assertEqual('', monitor.last_error(obj_path))
74- self.result = monitor.result(obj_path)
75-
76- for signal in signals:
77- self._bus._clean_up_signal_match(signal)
78+ self.assertEqual('', monitor.last_error(self.path))
79+ self.result = monitor.result(self.path)
80
81 return self.result
82

Subscribers

People subscribed via source and target branches