Handle AlreadyExistsError on user creation with non-unique email

This commit is contained in:
Montana
2018-10-08 10:36:40 -04:00
parent e5753762fa
commit 3c95063293
5 changed files with 23 additions and 25 deletions

View File

@@ -2,7 +2,7 @@ import pytest
from uuid import uuid4
from atst.domain.users import Users
from atst.domain.exceptions import NotFoundError
from atst.domain.exceptions import NotFoundError, AlreadyExistsError
DOD_ID = "my_dod_id"
@@ -12,6 +12,12 @@ def test_create_user():
assert user.atat_role.name == "developer"
def test_create_user_with_existing_email():
Users.create(DOD_ID, "developer", email="thisusersemail@usersRus.com")
with pytest.raises(AlreadyExistsError):
Users.create(DOD_ID, "admin", email="thisusersemail@usersRus.com")
def test_create_user_with_nonexistent_role():
with pytest.raises(NotFoundError):
Users.create(DOD_ID, "nonexistent")