mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-16 11:20:41 -04:00
try UserState enum
This commit is contained in:
@@ -16,7 +16,7 @@ from app.dao.organization_dao import (
|
||||
dao_get_users_for_organization,
|
||||
dao_update_organization,
|
||||
)
|
||||
from app.enums import OrganizationType
|
||||
from app.enums import OrganizationType, UserState
|
||||
from app.models import Organization, Service
|
||||
from app.utils import utc_now
|
||||
from tests.app.db import (
|
||||
@@ -310,7 +310,7 @@ def test_dao_get_users_for_organization_only_returns_active_users(sample_organiz
|
||||
organization_id=sample_organization.id, user_id=second.id
|
||||
)
|
||||
|
||||
second.state = "inactive"
|
||||
second.state = UserState.INACTIVE
|
||||
|
||||
results = dao_get_users_for_organization(organization_id=sample_organization.id)
|
||||
assert len(results) == 1
|
||||
|
||||
@@ -26,7 +26,7 @@ from app.dao.users_dao import (
|
||||
update_user_password,
|
||||
user_can_be_archived,
|
||||
)
|
||||
from app.enums import AuthType, CodeType, PermissionType
|
||||
from app.enums import AuthType, CodeType, PermissionType, UserState
|
||||
from app.errors import InvalidRequest
|
||||
from app.models import User, VerifyCode
|
||||
from app.utils import utc_now
|
||||
@@ -271,7 +271,7 @@ def test_dao_archive_user(sample_user, sample_organization, fake_uuid):
|
||||
assert sample_user.current_session_id == uuid.UUID(
|
||||
"00000000-0000-0000-0000-000000000000"
|
||||
)
|
||||
assert sample_user.state == "inactive"
|
||||
assert sample_user.state == UserState.INACTIVE
|
||||
assert not sample_user.check_password("password")
|
||||
|
||||
|
||||
@@ -329,8 +329,8 @@ def test_user_cannot_be_archived_if_they_belong_to_a_service_with_no_other_activ
|
||||
sample_service,
|
||||
):
|
||||
active_user = create_user(email="1@test.com")
|
||||
pending_user = create_user(email="2@test.com", state="pending")
|
||||
inactive_user = create_user(email="3@test.com", state="inactive")
|
||||
pending_user = create_user(email="2@test.com", state=UserState.PENDING)
|
||||
inactive_user = create_user(email="3@test.com", state=UserState.INACTIVE)
|
||||
|
||||
sample_service.users = [active_user, pending_user, inactive_user]
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ from app.enums import (
|
||||
NotificationType,
|
||||
OrganizationType,
|
||||
TemplateType,
|
||||
UserState,
|
||||
)
|
||||
from app.models import (
|
||||
AnnualBilling,
|
||||
@@ -273,7 +274,7 @@ def test_create_test_user_command(notify_db_session, notify_api):
|
||||
user = db.session.execute(stmt).scalars().first()
|
||||
assert user.email_address == "somebody@fake.gov"
|
||||
assert user.auth_type == AuthType.SMS
|
||||
assert user.state == "active"
|
||||
assert user.state == UserState.ACTIVE
|
||||
|
||||
|
||||
def test_insert_inbound_numbers_from_file(notify_db_session, notify_api, tmpdir):
|
||||
|
||||
@@ -10,7 +10,7 @@ from sqlalchemy import delete, func, select
|
||||
|
||||
from app import db
|
||||
from app.dao.service_user_dao import dao_get_service_user, dao_update_service_user
|
||||
from app.enums import AuthType, KeyType, NotificationType, PermissionType
|
||||
from app.enums import AuthType, KeyType, NotificationType, PermissionType, UserState
|
||||
from app.models import Notification, Permission, User
|
||||
from tests.app.db import (
|
||||
create_organization,
|
||||
@@ -766,23 +766,23 @@ def test_send_user_confirm_new_email_returns_400_when_email_missing(
|
||||
|
||||
|
||||
def test_activate_user(admin_request, sample_user):
|
||||
sample_user.state = "pending"
|
||||
sample_user.state = UserState.PENDING
|
||||
|
||||
resp = admin_request.post("user.activate_user", user_id=sample_user.id)
|
||||
|
||||
assert resp["data"]["id"] == str(sample_user.id)
|
||||
assert resp["data"]["state"] == "active"
|
||||
assert sample_user.state == "active"
|
||||
assert sample_user.state == UserState.ACTIVE
|
||||
|
||||
|
||||
def test_deactivate_user(admin_request, sample_user):
|
||||
sample_user.state = "active"
|
||||
sample_user.state = UserState.ACTIVE
|
||||
|
||||
resp = admin_request.post("user.deactivate_user", user_id=sample_user.id)
|
||||
|
||||
assert resp["data"]["id"] == str(sample_user.id)
|
||||
assert resp["data"]["state"] == "pending"
|
||||
assert sample_user.state == "pending"
|
||||
assert sample_user.state == UserState.PENDING
|
||||
|
||||
|
||||
def test_activate_user_fails_if_already_active(admin_request, sample_user):
|
||||
@@ -790,7 +790,7 @@ def test_activate_user_fails_if_already_active(admin_request, sample_user):
|
||||
"user.activate_user", user_id=sample_user.id, _expected_status=400
|
||||
)
|
||||
assert resp["message"] == "User already active"
|
||||
assert sample_user.state == "active"
|
||||
assert sample_user.state == UserState.ACTIVE
|
||||
|
||||
|
||||
def test_update_user_auth_type(admin_request, sample_user):
|
||||
|
||||
Reference in New Issue
Block a user