Пример #1
0
 def test_unregister_success(self, environ_get):
     """Test the UnregisterTask - success."""
     # register server proxy
     rhsm_unregister_proxy = Mock()
     # instantiate the task and run it
     task = UnregisterTask(rhsm_unregister_proxy=rhsm_unregister_proxy)
     task.run()
     # check the unregister proxy Unregister method was called correctly
     rhsm_unregister_proxy.Unregister.assert_called_once_with({},
                                                              "en_US.UTF-8")
Пример #2
0
 def test_unregister_failure(self, environ_get):
     """Test the UnregisterTask - failure."""
     # register server proxy
     rhsm_unregister_proxy = Mock()
     # raise DBusError with error message in JSON
     json_error = '{"message": "Unregistration failed."}'
     rhsm_unregister_proxy.Unregister.side_effect = DBusError(json_error)
     # instantiate the task and run it
     task = UnregisterTask(rhsm_unregister_proxy=rhsm_unregister_proxy)
     with self.assertRaises(DBusError):
         task.run()
     # check the unregister proxy Unregister method was called correctly
     rhsm_unregister_proxy.Unregister.assert_called_once_with({},
                                                              "en_US.UTF-8")
Пример #3
0
    def unregister_with_task(self):
        """Unregister the system.

        :return: a DBus path of an installation task
        """
        rhsm_unregister_proxy = self.rhsm_observer.get_proxy(RHSM_UNREGISTER)
        task = UnregisterTask(rhsm_unregister_proxy=rhsm_unregister_proxy)
        # we will no longer be registered and subscribed if the task is successful,
        # so set the corresponding properties appropriately
        task.succeeded_signal.connect(lambda: self.set_registered(False))
        task.succeeded_signal.connect(
            lambda: self.set_subscription_attached(False))
        # and clear attached subscriptions
        task.succeeded_signal.connect(
            lambda: self.set_attached_subscriptions([]))
        return task