Latest utils commit updates sync with main

This commit is contained in:
samathad2023
2024-03-20 14:09:46 -07:00
23 changed files with 409 additions and 172 deletions

View File

@@ -15,6 +15,7 @@ from app.dao.users_dao import (
dao_archive_user,
delete_codes_older_created_more_than_a_day_ago,
delete_model_user,
get_login_gov_user,
get_user_by_email,
get_user_by_id,
increment_failed_login_count,
@@ -110,6 +111,12 @@ def test_get_user_by_email(sample_user):
assert sample_user == user_from_db
def test_get_login_gov_user(sample_user):
user_from_db = get_login_gov_user("fake_login_gov_uuid", sample_user.email_address)
assert sample_user.email_address == user_from_db.email_address
assert user_from_db.login_uuid is not None
def test_get_user_by_email_is_case_insensitive(sample_user):
email = sample_user.email_address
user_from_db = get_user_by_email(email.upper())

View File

@@ -34,6 +34,7 @@ from app.serialised_models import (
SerialisedService,
SerialisedTemplate,
)
from app.service.utils import service_allowed_to_send_to
from app.utils import get_template_instance
from app.v2.errors import BadRequestError, RateLimitError, TotalRequestsError
from tests.app.db import (
@@ -802,3 +803,21 @@ def test_check_service_over_total_message_limit(mocker, sample_service):
sample_service,
)
assert service_stats == 0
def test_service_allowed_to_send_to_simulated_numbers():
trial_mode_service = create_service(service_name="trial mode", restricted=True)
can_send = service_allowed_to_send_to(
"+14254147755",
trial_mode_service,
KeyType.NORMAL,
allow_guest_list_recipients=True,
)
can_not_send = service_allowed_to_send_to(
"+15555555555",
trial_mode_service,
KeyType.NORMAL,
allow_guest_list_recipients=True,
)
assert can_send is True
assert can_not_send is False