notify-api-59 make command to create new service

This commit is contained in:
Kenneth Kehl
2023-08-30 13:13:43 -07:00
parent 85de5bfc63
commit fb3a6cca68
3 changed files with 63 additions and 1 deletions

View File

@@ -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