def test_org_key_success(self, private_bus, environ_get):
     """Test the RegisterWithOrganizationKeyTask - success."""
     # register server proxy
     register_server_proxy = Mock()
     # private register proxy
     get_proxy = private_bus.return_value.__enter__.return_value.get_proxy
     private_register_proxy = get_proxy.return_value
     private_register_proxy.Register.return_value = True, ""
     # instantiate the task and run it
     task = RegisterWithOrganizationKeyTask(
         rhsm_register_server_proxy=register_server_proxy,
         organization="123456789",
         activation_keys=["foo", "bar", "baz"])
     task.run()
     # check private register proxy RegisterWithActivationKeys method was called correctly
     private_register_proxy.RegisterWithActivationKeys.assert_called_with(
         "123456789", ["foo", "bar", "baz"], {}, {}, 'en_US.UTF-8')
 def test_org_key_failure(self, private_bus, environ_get):
     """Test the RegisterWithOrganizationKeyTask - failure."""
     # register server proxy
     register_server_proxy = Mock()
     # private register proxy
     get_proxy = private_bus.return_value.__enter__.return_value.get_proxy
     private_register_proxy = get_proxy.return_value
     # raise DBusError with error message in JSON
     json_error = '{"message": "Registration failed."}'
     private_register_proxy.RegisterWithActivationKeys.side_effect = DBusError(
         json_error)
     # instantiate the task and run it
     task = RegisterWithOrganizationKeyTask(
         rhsm_register_server_proxy=register_server_proxy,
         organization="123456789",
         activation_keys=["foo", "bar", "baz"])
     with self.assertRaises(RegistrationError):
         task.run()
     # check private register proxy RegisterWithActivationKeys method was called correctly
     private_register_proxy.RegisterWithActivationKeys.assert_called_with(
         "123456789", ["foo", "bar", "baz"], {}, {}, 'en_US.UTF-8')