~jseutter/landscape-client/invalid-integer

« back to all changes in this revision

Viewing changes to landscape/ui/model/registration/tests/test_mechanism.py

Merged ui-permissions-and-panel [r=therve,free.ekanayaka][f=911665]

The following changes have been made:
  - Split Configuration model into a DBus service mechanism and a proxy for the client.
  - Split Registration model in to a DBus service mechanism and a proxy for the client (with asynchronous registration).
  - Create PolicyKit policies for configuration and registration and cause these to be checked by the relevant DBus service mechanism when it receives dbus calls (effectively trigger a challenge for a password and only allow admin users to continue).
   - Create DBus service and conf files for the two service mechanisms (Allowing them to be run by the System bus on demand)
   - Create an application desktop file causing the landscape-client-settings-ui program to be launchable from gnome-control-center
   - Create the icon preferences-management-service.svg to represent this activity in gnome-control-center.
   - Create setupui.py - a distutils script for the settings-ui components.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import dbus
 
2
 
 
3
from landscape.tests.helpers import LandscapeTest
 
4
from landscape.ui.model.registration.mechanism import (
 
5
    RegistrationMechanism, INTERFACE_NAME)
 
6
 
 
7
 
 
8
class MechanismTest(LandscapeTest):
 
9
    """
 
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
 
12
    elsewhere.
 
13
    """
 
14
 
 
15
    def setUp(self):
 
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)
 
20
 
 
21
    def make_registration(self, succeed):
 
22
 
 
23
        def _do_registration(this, config_path):
 
24
            return succeed
 
25
 
 
26
        return _do_registration
 
27
 
 
28
    def test_registration_succeed(self):
 
29
        """
 
30
        Test we get appropriate feedback from a successful connection when we
 
31
        call L{register} synchronously.
 
32
        """
 
33
        RegistrationMechanism._do_registration = self.make_registration(True)
 
34
        mechanism = RegistrationMechanism(self.bus_name)
 
35
        self.assertEqual((True, "Connected\n"), mechanism.register("foo"))
 
36
 
 
37
    def test_registration_fail(self):
 
38
        """
 
39
        Test we get appropriate feedback from a failed connection when we
 
40
        call L{register} synchronously.
 
41
        """
 
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"))