Exemplo n.º 1
0
 def test_attach_subscription_task_success(self, environ_get):
     """Test the AttachSubscriptionTask - success."""
     rhsm_attach_proxy = Mock()
     task = AttachSubscriptionTask(rhsm_attach_proxy=rhsm_attach_proxy,
                                   sla="foo_sla")
     task.run()
     rhsm_attach_proxy.AutoAttach.assert_called_once_with(
         "foo_sla", {}, "en_US.UTF-8")
Exemplo n.º 2
0
 def test_attach_subscription_task_failure(self, environ_get):
     """Test the AttachSubscriptionTask - failure."""
     rhsm_attach_proxy = Mock()
     # raise DBusError with error message in JSON
     json_error = '{"message": "Failed to attach subscription."}'
     rhsm_attach_proxy.AutoAttach.side_effect = DBusError(json_error)
     task = AttachSubscriptionTask(rhsm_attach_proxy=rhsm_attach_proxy,
                                   sla="foo_sla")
     with self.assertRaises(SubscriptionError):
         task.run()
     rhsm_attach_proxy.AutoAttach.assert_called_once_with(
         "foo_sla", {}, "en_US.UTF-8")
Exemplo n.º 3
0
    def attach_subscription_with_task(self):
        """Attach a subscription.

        This should only be run on a system that has been successfully registered.
        Attached subscription depends on system type, system purpose data
        and entitlements available for the account that has been used for registration.

        :return: a DBus path of an installation task
        """
        sla = self.system_purpose_data.sla
        rhsm_attach_proxy = self.rhsm_observer.get_proxy(RHSM_ATTACH)
        task = AttachSubscriptionTask(rhsm_attach_proxy=rhsm_attach_proxy,
                                      sla=sla)
        # if the task succeeds, it means a subscription has been attached
        task.succeeded_signal.connect(
            lambda: self.set_subscription_attached(True))
        return task