mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-25 00:33:41 -04:00
Merge branch 'main' into notify-api-446
This commit is contained in:
@@ -211,6 +211,7 @@ def sample_service(sample_user):
|
||||
data = {
|
||||
"name": service_name,
|
||||
"message_limit": 1000,
|
||||
"total_message_limit": 250000,
|
||||
"restricted": False,
|
||||
"email_from": email_from,
|
||||
"created_by": sample_user,
|
||||
|
||||
@@ -107,6 +107,7 @@ def create_service(
|
||||
email_from=None,
|
||||
prefix_sms=True,
|
||||
message_limit=1000,
|
||||
total_message_limit=250000,
|
||||
organization_type="federal",
|
||||
check_if_service_exists=False,
|
||||
go_live_user=None,
|
||||
@@ -123,6 +124,7 @@ def create_service(
|
||||
service = Service(
|
||||
name=service_name,
|
||||
message_limit=message_limit,
|
||||
total_message_limit=total_message_limit,
|
||||
restricted=restricted,
|
||||
email_from=email_from
|
||||
if email_from
|
||||
|
||||
@@ -248,6 +248,7 @@ def test_get_service_by_id(admin_request, sample_service):
|
||||
"id",
|
||||
"inbound_api",
|
||||
"message_limit",
|
||||
"total_message_limit",
|
||||
"name",
|
||||
"notes",
|
||||
"organization",
|
||||
@@ -372,6 +373,7 @@ def test_create_service(
|
||||
"name": "created service",
|
||||
"user_id": str(sample_user.id),
|
||||
"message_limit": 1000,
|
||||
"total_message_limit": 250000,
|
||||
"restricted": False,
|
||||
"active": False,
|
||||
"email_from": "created.service",
|
||||
@@ -441,6 +443,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,
|
||||
"restricted": False,
|
||||
"active": False,
|
||||
"email_from": "created.service",
|
||||
@@ -465,6 +468,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,
|
||||
"restricted": False,
|
||||
"active": False,
|
||||
"email_from": "created.service",
|
||||
@@ -488,6 +492,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,
|
||||
"restricted": False,
|
||||
"active": False,
|
||||
"email_from": "created.service",
|
||||
@@ -518,6 +523,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,
|
||||
"restricted": False,
|
||||
"active": False,
|
||||
"email_from": "created.service",
|
||||
@@ -536,6 +542,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,
|
||||
"restricted": False,
|
||||
"active": False,
|
||||
"created_by": str(fake_uuid),
|
||||
@@ -556,6 +563,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,
|
||||
"restricted": False,
|
||||
"active": False,
|
||||
"user_id": str(sample_user.id),
|
||||
@@ -581,6 +589,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,
|
||||
"restricted": False,
|
||||
"active": False,
|
||||
"created_by": str(fake_uuid),
|
||||
@@ -623,6 +632,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,
|
||||
"restricted": False,
|
||||
"active": False,
|
||||
"email_from": "sample.service2",
|
||||
@@ -650,6 +660,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,
|
||||
"restricted": False,
|
||||
"active": False,
|
||||
"email_from": "first.service",
|
||||
@@ -1137,6 +1148,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,
|
||||
"restricted": False,
|
||||
"active": False,
|
||||
"email_from": "created.service",
|
||||
|
||||
@@ -5,6 +5,7 @@ import pytest
|
||||
|
||||
from app.commands import (
|
||||
_update_template,
|
||||
create_new_service,
|
||||
create_test_user,
|
||||
fix_billable_units,
|
||||
insert_inbound_numbers_from_file,
|
||||
@@ -24,6 +25,7 @@ from app.models import (
|
||||
Job,
|
||||
Notification,
|
||||
Organization,
|
||||
Service,
|
||||
Template,
|
||||
User,
|
||||
)
|
||||
@@ -324,3 +326,39 @@ def test_update_template(notify_db_session, email_2fa_code_template):
|
||||
t = Template.query.all()
|
||||
|
||||
assert t[0].name == "Example text message template!"
|
||||
|
||||
|
||||
def test_create_service_command(notify_db_session, notify_api):
|
||||
notify_api.test_cli_runner().invoke(
|
||||
create_test_user,
|
||||
[
|
||||
"--email",
|
||||
"somebody@fake.gov",
|
||||
"--mobile_number",
|
||||
"202-555-5555",
|
||||
"--password",
|
||||
"correct horse battery staple",
|
||||
"--name",
|
||||
"Fake Personson",
|
||||
],
|
||||
)
|
||||
|
||||
user = User.query.first()
|
||||
|
||||
service_count = Service.query.count()
|
||||
|
||||
# run the command
|
||||
result = notify_api.test_cli_runner().invoke(
|
||||
create_new_service,
|
||||
["-e", "somebody@fake.gov", "-n", "Fake Service", "-c", user.id],
|
||||
)
|
||||
print(result)
|
||||
|
||||
# there should be one more service
|
||||
assert Service.query.count() == service_count + 1
|
||||
|
||||
# that service should be the one we added
|
||||
service = Service.query.filter_by(name="Fake Service").first()
|
||||
assert service.email_from == "somebody@fake.gov"
|
||||
assert service.restricted is False
|
||||
assert service.message_limit == 40000
|
||||
|
||||
Reference in New Issue
Block a user