~free.ekanayaka/landscape-client/use-smart-to-get-dpkg-arch

« back to all changes in this revision

Viewing changes to landscape/monitor/tests/test_deployment.py

  • Committer: Thomas Hervé
  • Date: 2009-06-03 15:36:35 UTC
  • mfrom: (110.2.3 broker-restart)
  • Revision ID: thomas@canonical.com-20090603153635-wh7ucq6z10w8c857
Merge broker-restart [f=380633] [r=niemeyer,free.ekayanaka]

Make manager and monitor plugins registered themselves and the mesage types
again if the broker is restarted. The notification happens with a new signal
sent by the broker at start.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
from landscape.broker.tests.test_remote import assertTransmitterActive
9
9
from landscape.tests.test_plugin import assertReceivesMessages
10
10
 
 
11
from twisted.internet.defer import Deferred
 
12
 
11
13
 
12
14
class DeploymentTest(LandscapeTest):
13
15
 
58
60
        return assertReceivesMessages(self, self.monitor.dbus_service,
59
61
                                      self.broker_service, self.remote)
60
62
 
 
63
    def test_register_plugin_on_broker_started(self):
 
64
        """
 
65
        When the broker is restarted, it fires a "broker-started" signal which
 
66
        makes the Monitor plugin register itself again.
 
67
        """
 
68
        d = Deferred()
 
69
        def register_plugin(bus_name, object_path):
 
70
            d.callback((bus_name, object_path))
 
71
        def patch(ignore):
 
72
            self.monitor.remote_broker.register_plugin = register_plugin
 
73
            self.broker_service.dbus_object.broker_started()
 
74
            return d
 
75
        return self.remote.get_registered_plugins(
 
76
            ).addCallback(patch
 
77
            ).addCallback(self.assertEquals,
 
78
                ("com.canonical.landscape.Monitor",
 
79
                 "/com/canonical/landscape/Monitor"))
 
80
 
 
81
    def test_register_message_on_broker_started(self):
 
82
        """
 
83
        When the broker is restarted, it fires a "broker-started" signal which
 
84
        makes the Monitor plugin register all registered messages again.
 
85
        """
 
86
        self.monitor.registry.register_message("foo", lambda x: None)
 
87
        d = Deferred()
 
88
        def register_client_accepted_message_type(type):
 
89
            if type == "foo":
 
90
                d.callback(type)
 
91
        def patch(ignore):
 
92
            self.monitor.remote_broker.register_client_accepted_message_type = \
 
93
                register_client_accepted_message_type
 
94
            self.broker_service.dbus_object.broker_started()
 
95
            return d
 
96
        return self.remote.get_registered_plugins(
 
97
            ).addCallback(patch
 
98
            ).addCallback(self.assertEquals, "foo")
 
99
 
61
100
 
62
101
class MonitorTest(MonitorServiceTest):
63
102