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")
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)
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)
def __init__(self): super().__init__() # system purpose self._valid_roles = [] self._valid_slas = [] self._valid_usage_types = [] self._system_purpose_data = SystemPurposeData() self.system_purpose_data_changed = Signal() self._load_valid_system_purpose_values() # subscription request self._subscription_request = SubscriptionRequest() self.subscription_request_changed = Signal() # attached subscriptions self._attached_subscriptions = [] self.attached_subscriptions_changed = Signal() # Insights # What are the defaults for Red Hat Insights ? # - during a kickstart installation, the user # needs to opt-in by using the rhsm command # with the --connect-to-insights option # - during a GUI interactive installation the # "connect to Insights" checkbox is checked by default, # making Insights opt-out # - in both cases the system also needs to be subscribed, # or else the system can't be connected to Insights self._connect_to_insights = False self.connect_to_insights_changed = Signal() # registration status self.registered_changed = Signal() self._registered = False # subscription status self.subscription_attached_changed = Signal() self._subscription_attached = False # RHSM service startup and access self._rhsm_startup_task = StartRHSMTask( verify_ssl=conf.payload.verify_ssl) self._rhsm_observer = RHSMObserver( self._rhsm_startup_task.is_service_available) # RHSM config default values cache self._rhsm_config_defaults = None