refactor: use shared ProfileUpdate validation in admin routes
This commit is contained in:
parent
5fd63d61ff
commit
7bfea306ab
2 changed files with 56 additions and 16 deletions
|
|
@ -153,7 +153,7 @@ async def test_update_profile(client: AsyncClient) -> None:
|
|||
"family_name": "Smith",
|
||||
"preferred_username": "bobby",
|
||||
"email": "bob@example.com",
|
||||
"phone_number": "+1234567890",
|
||||
"phone_number": "+46701234567",
|
||||
"picture": "https://example.com/bob.jpg",
|
||||
"locale": "en-US",
|
||||
},
|
||||
|
|
@ -183,7 +183,23 @@ async def test_update_profile_invalid_email(client: AsyncClient) -> None:
|
|||
headers={"X-CSRF-Token": token},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert "Invalid email" in response.text
|
||||
assert "alert" in response.text
|
||||
assert "email" in response.text.lower()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_profile_invalid_phone(client: AsyncClient) -> None:
|
||||
await _login(client)
|
||||
target = await _create_target_user(client, username="bob")
|
||||
token = await get_csrf_token(client)
|
||||
response = await client.post(
|
||||
f"/admin/users/{target.userid}/profile",
|
||||
data={"phone_number": "not-a-phone"},
|
||||
headers={"X-CSRF-Token": token},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert "alert" in response.text
|
||||
assert "phone" in response.text.lower()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue