Exemplo n.º 1
0
    def test_service_available(self, get_proxy):
        """Test that RHSMObserver returns proxy if service is available."""

        startup_check_method = Mock()
        observer = RHSMObserver(startup_check_method)

        self._setup_observer(observer)
        self._make_service_available(observer)

        # check the observer is returning a reasonably looking proxy
        observer.get_proxy("BAZ")
        get_proxy.assert_called_once_with("com.redhat.RHSM1", "BAZ", "BAZ")
Exemplo n.º 2
0
    def test_service_not_available_success(self, get_proxy):
        """Test that RHSMObserver checks service startup status and succeeds."""

        startup_check_method = Mock()
        # report that startup was successful
        startup_check_method.return_value = True
        observer = RHSMObserver(startup_check_method)

        self._setup_observer(observer)
        self._make_service_unavailable(observer)

        # check the observer is returning a reasonably looking proxy
        observer.get_proxy("BAZ")
        get_proxy.assert_called_once_with("com.redhat.RHSM1", "BAZ", "BAZ")

        # check that the startup check method was called
        startup_check_method.assert_called_once_with(RHSM_SERVICE_TIMEOUT)
Exemplo n.º 3
0
    def test_service_not_available_failure(self, get_proxy):
        """Test that RHSMObserver checks service startup status and fails."""

        startup_check_method = Mock()
        # report that startup failed
        startup_check_method.return_value = False
        observer = RHSMObserver(startup_check_method)

        self._setup_observer(observer)
        self._make_service_unavailable(observer)
        # DBusObserverError should be raise
        with pytest.raises(DBusObserverError):
            observer.get_proxy("BAZ")
        # the observer should raise the exception before trying to get a proxy
        get_proxy.assert_not_called()

        # check that the startup check method was called
        startup_check_method.assert_called_once_with(RHSM_SERVICE_TIMEOUT)