32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import pytest
|
|
import random
|
|
from tests.base.authentication_web import AuthenticationWeb
|
|
|
|
|
|
class TestDeleteRole:
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_delete_role_success(self, authentication_web: AuthenticationWeb):
|
|
"""Test deleting a role successfully."""
|
|
suffix = str(random.randint(10000, 99999))
|
|
role = await authentication_web.create_role({
|
|
"role_key": f"delrole_{suffix}",
|
|
"role_name": f"delrole_{suffix}",
|
|
"role_description": "desc",
|
|
"role_level": 1
|
|
})
|
|
role_id = role.json()["id"]
|
|
resp = await authentication_web.delete_role(role_data={"role_id": role_id})
|
|
assert resp.status_code == 200
|
|
assert resp.json()["success"] is True
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_delete_role_fail_not_found(self, authentication_web: AuthenticationWeb):
|
|
"""Test deleting a role fails when role_id does not exist."""
|
|
resp = await authentication_web.delete_role(role_data={"role_id": "000000000000000000000000"})
|
|
assert resp.status_code == 422 or resp.status_code == 400
|
|
|
|
|
|
if __name__ == '__main__':
|
|
pytest.main([__file__])
|