"""Test DELETE POST /users/identity//device/ endpoint.""" import requests from tests.integration import config from tests.integration.api.device import conftest def test_delete_one_device(new_identity, grass_headers): """Test deletion of one of two devices attached to an identity.""" identity_id = new_identity['id'] device1_payload = conftest.create_device_payload() requests.post( f'{config.QA_BASE_URL}/users/identity/{identity_id}/device', headers=grass_headers, json=device1_payload, ) device2_payload = conftest.create_device_payload() device2_payload['platform_type'] = 'android' requests.post( f'{config.QA_BASE_URL}/users/identity/{identity_id}/device', headers=grass_headers, json=device2_payload, ) # Verify two exist res = requests.get( f'{config.QA_BASE_URL}/users/identity/{identity_id}/device', headers=grass_headers, ) assert res.status_code == 200 assert len(res.json()) == 2 # Delete one device1_id = device1_payload['device_id'] res = requests.delete( f'{config.QA_BASE_URL}/users/identity/{identity_id}/device/{device1_id}', headers=grass_headers, ) assert res.status_code == 204 # Verify one still exists res = requests.get( f'{config.QA_BASE_URL}/users/identity/{identity_id}/device', headers=grass_headers, ) assert res.status_code == 200 body = res.json() assert len(body) == 1 assert body[0]['device_id'] == device2_payload['device_id']