3
from landscape.tests.helpers import LandscapeTest
4
from landscape.ui.model.registration.mechanism import (
5
RegistrationMechanism, INTERFACE_NAME)
8
class MechanismTest(LandscapeTest):
10
L{MechanismTest} mocks out the actual registration process and allows us to
11
simply and quickly check the outputs of registration that are relied on
16
super(MechanismTest, self).setUp()
17
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
18
bus = dbus.SessionBus(private=True)
19
self.bus_name = dbus.service.BusName(INTERFACE_NAME, bus)
21
def make_registration(self, succeed):
23
def _do_registration(this, config_path):
26
return _do_registration
28
def test_registration_succeed(self):
30
Test we get appropriate feedback from a successful connection when we
31
call L{register} synchronously.
33
RegistrationMechanism._do_registration = self.make_registration(True)
34
mechanism = RegistrationMechanism(self.bus_name)
35
self.assertEqual((True, "Connected\n"), mechanism.register("foo"))
37
def test_registration_fail(self):
39
Test we get appropriate feedback from a failed connection when we
40
call L{register} synchronously.
42
RegistrationMechanism._do_registration = self.make_registration(False)
43
mechanism = RegistrationMechanism(self.bus_name)
44
self.assertEqual((False, "Failed to connect\n"),
45
mechanism.register("foo"))