"""Tests for the DELETE /users/identity/ endpoint.""" import uuid import requests from tests.integration import config def test_create_and_delete_identity(grass_headers, identity_payload): """Test creating and deleting an identity, then attempting to fetch it.""" res = requests.post( f'{config.QA_BASE_URL}/users/identity', headers=grass_headers, json=identity_payload, ) assert res.status_code == 200, res.text res = requests.delete(f'{config.QA_BASE_URL}/users/identity/{identity_payload["identity_id"]}') assert res.status_code == 204, res.text res = requests.get( f'{config.QA_BASE_URL}/users/identity/{identity_payload["identity_id"]}', headers=grass_headers, ) assert res.status_code == 404, res.text def test_delete_nonexistent_identity(grass_headers): """Test deleting a nonexistent identity.""" res = requests.delete( f'{config.QA_BASE_URL}/users/identity/{uuid.uuid4()}', headers=grass_headers, ) assert res.status_code == 400, res.text body = res.json() assert body['code'] == 'not_found' assert body['message'] == 'Identity not found'