'Call ``DELETE /users/{user_id}``.
As well as making sure the delete succeeds, we ensure
that any credentials that reference this user are
also deleted, while other credentials are unaffected.
In addition, no tokens should remain valid for this user.'

def test_delete_user(self):

    r = self.credential_api.get_credential(self.credential['id'])
    self.assertDictEqual(self.credential, r)
    user2 = unit.new_user_ref(domain_id=self.domain['id'], project_id=self.project['id'])
    user2 = self.identity_api.create_user(user2)
    credential2 = unit.new_credential_ref(user_id=user2['id'], project_id=self.project['id'])
    self.credential_api.create_credential(credential2['id'], credential2)
    auth_data = self.build_authentication_request(user_id=self.user['id'], password=self.user['password'], project_id=self.project['id'])
    token = self.get_requested_token(auth_data)
    self.head('/auth/tokens', headers={'X-Subject-Token': token}, expected_status=http_client.OK)
    self.delete(('/users/%(user_id)s' % {'user_id': self.user['id']}))
    self.assertRaises(exception.CredentialNotFound, self.credential_api.get_credential, self.credential['id'])
    tokens = self.token_provider_api._persistence._list_tokens(self.user['id'])
    self.assertEqual(0, len(tokens))
    r = self.credential_api.get_credential(credential2['id'])
    self.assertDictEqual(credential2, r)
