Merge pull request #1541 from GSA/notify-api-1540

change total message limit to 100000
This commit is contained in:
Kenneth Kehl
2025-01-29 08:52:48 -08:00
committed by GitHub
18 changed files with 191 additions and 202 deletions

View File

@@ -397,7 +397,7 @@ def test_create_service(
"name": "created service",
"user_id": str(sample_user.id),
"message_limit": 1000,
"total_message_limit": 250000,
"total_message_limit": 100000,
"restricted": False,
"active": False,
"email_from": "created.service",
@@ -468,7 +468,7 @@ def test_create_service_with_domain_sets_organization(
"name": "created service",
"user_id": str(sample_user.id),
"message_limit": 1000,
"total_message_limit": 250000,
"total_message_limit": 100000,
"restricted": False,
"active": False,
"email_from": "created.service",
@@ -495,7 +495,7 @@ def test_create_service_should_create_annual_billing_for_service(
"name": "created service",
"user_id": str(sample_user.id),
"message_limit": 1000,
"total_message_limit": 250000,
"total_message_limit": 100000,
"restricted": False,
"active": False,
"email_from": "created.service",
@@ -520,7 +520,7 @@ def test_create_service_should_raise_exception_and_not_create_service_if_annual_
"name": "created service",
"user_id": str(sample_user.id),
"message_limit": 1000,
"total_message_limit": 250000,
"total_message_limit": 100000,
"restricted": False,
"active": False,
"email_from": "created.service",
@@ -557,7 +557,7 @@ def test_create_service_inherits_branding_from_organization(
"name": "created service",
"user_id": str(sample_user.id),
"message_limit": 1000,
"total_message_limit": 250000,
"total_message_limit": 100000,
"restricted": False,
"active": False,
"email_from": "created.service",
@@ -576,7 +576,7 @@ def test_should_not_create_service_with_missing_user_id_field(notify_api, fake_u
"email_from": "service",
"name": "created service",
"message_limit": 1000,
"total_message_limit": 250000,
"total_message_limit": 100000,
"restricted": False,
"active": False,
"created_by": str(fake_uuid),
@@ -597,7 +597,7 @@ def test_should_error_if_created_by_missing(notify_api, sample_user):
"email_from": "service",
"name": "created service",
"message_limit": 1000,
"total_message_limit": 250000,
"total_message_limit": 100000,
"restricted": False,
"active": False,
"user_id": str(sample_user.id),
@@ -623,7 +623,7 @@ def test_should_not_create_service_with_missing_if_user_id_is_not_in_database(
"user_id": fake_uuid,
"name": "created service",
"message_limit": 1000,
"total_message_limit": 250000,
"total_message_limit": 100000,
"restricted": False,
"active": False,
"created_by": str(fake_uuid),
@@ -666,7 +666,7 @@ def test_should_not_create_service_with_duplicate_name(
"name": sample_service.name,
"user_id": str(sample_service.users[0].id),
"message_limit": 1000,
"total_message_limit": 250000,
"total_message_limit": 100000,
"restricted": False,
"active": False,
"email_from": "sample.service2",
@@ -694,7 +694,7 @@ def test_create_service_should_throw_duplicate_key_constraint_for_existing_email
"name": service_name,
"user_id": str(first_service.users[0].id),
"message_limit": 1000,
"total_message_limit": 250000,
"total_message_limit": 100000,
"restricted": False,
"active": False,
"email_from": "first.service",
@@ -1220,7 +1220,7 @@ def test_default_permissions_are_added_for_user_service(
"name": "created service",
"user_id": str(sample_user.id),
"message_limit": 1000,
"total_message_limit": 250000,
"total_message_limit": 100000,
"restricted": False,
"active": False,
"email_from": "created.service",
@@ -1665,6 +1665,27 @@ def test_remove_user_from_service(client, sample_user_service_permission):
assert resp.status_code == 204
def test_get_service_message_ratio(mocker, client, sample_user_service_permission):
service = sample_user_service_permission.service
mock_redis = mocker.patch("app.service.rest.redis_store.get")
mock_redis.return_value = 1
endpoint = url_for(
"service.get_service_message_ratio",
service_id=str(service.id),
)
auth_header = create_admin_authorization_header()
resp = client.get(
endpoint, headers=[("Content-Type", "application/json"), auth_header]
)
assert resp.status_code == 200
result = resp.json
assert result["total_message_limit"] == 100000
assert result["messages_sent"] == 1
def test_remove_non_existant_user_from_service(client, sample_user_service_permission):
second_user = create_user(email="new@digital.fake.gov")
endpoint = url_for(
@@ -3709,3 +3730,24 @@ def test_get_service_notification_statistics_by_day(
assert mock_get_service_statistics_for_specific_days.assert_called_once
assert response == mock_data
# def test_valid_request():
# request = MagicMock()
# request.args = {
# "service_id": "123",
# "name": "Test Name",
# "email_from": "test@example.com",
# }
# result = check_request_args(request)
# assert result == ("123", "Test Name", "test@example.com")
# def test_missing_service_id():
# request = MagicMock()
# request.args = {"name": "Test Name", "email_from": "test@example.com"}
# try:
# check_request_args(request)
# except Exception as e:
# assert e.status_code == 400
# assert {"service_id": ["Can't be empty"] in e.errors}