Exemplo n.º 1
0
    def test_module_observer(self):
        """Test the module observer."""
        dbus = Mock()
        observer = ModuleObserver(dbus, "my.test.module")

        # Setup the observer.
        self._setup_observer(observer)
        assert observer._proxy is None

        with pytest.raises(DBusObserverError):
            observer.proxy.DoSomething()

        # Service available.
        self._make_service_available(observer)
        assert observer._proxy is None

        # Access the proxy.
        observer.proxy.DoSomething()
        dbus.get_proxy.assert_called_once_with("my.test.module",
                                               "/my/test/module")
        assert observer._proxy is not None

        # Service unavailable.

        self._make_service_unavailable(observer)
        assert observer._proxy is None

        with pytest.raises(DBusObserverError):
            observer.proxy.DoSomething()
Exemplo n.º 2
0
 def _get_module_observer(self, service_path, module_proxy, available=True):
     observer = ModuleObserver(Mock(), service_path)
     observer._proxy = module_proxy
     observer._is_service_available = available
     return observer