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")
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")