mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 13:38:53 -04:00
tests & prompts for user creation command
This commit is contained in:
@@ -736,10 +736,10 @@ def populate_annual_billing_with_defaults(year, missing_services_only):
|
|||||||
|
|
||||||
|
|
||||||
@notify_command(name='create-test-user')
|
@notify_command(name='create-test-user')
|
||||||
@click.option('-e', '--email', required=True)
|
@click.option('-n', '--name', required=True, prompt=True)
|
||||||
@click.option('-m', '--mobile_number', required=True)
|
@click.option('-e', '--email', required=True, prompt=True)
|
||||||
@click.option('-p', '--password', required=True)
|
@click.option('-m', '--mobile_number', required=True, prompt=True)
|
||||||
@click.option('-n', '--name', required=True)
|
@click.option('-p', '--password', required=True, prompt=True, hide_input=True, confirmation_prompt=True)
|
||||||
@click.option('-a', '--auth_type', default="sms_auth")
|
@click.option('-a', '--auth_type', default="sms_auth")
|
||||||
@click.option('-s', '--state', default="active")
|
@click.option('-s', '--state', default="active")
|
||||||
@click.option('-d', '--admin', default=False, type=bool)
|
@click.option('-d', '--admin', default=False, type=bool)
|
||||||
@@ -754,7 +754,7 @@ def create_test_user(name,email, mobile_number, password, auth_type, state, admi
|
|||||||
'mobile_number': mobile_number,
|
'mobile_number': mobile_number,
|
||||||
'password': password,
|
'password': password,
|
||||||
'auth_type': auth_type,
|
'auth_type': auth_type,
|
||||||
'state': state,
|
'state': state, # skip the email verification for our test user
|
||||||
'platform_admin': admin,
|
'platform_admin': admin,
|
||||||
}
|
}
|
||||||
user = User(**data)
|
user = User(**data)
|
||||||
|
|||||||
@@ -1,14 +1,45 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from app.commands import (
|
from app.commands import (
|
||||||
|
create_test_user,
|
||||||
insert_inbound_numbers_from_file,
|
insert_inbound_numbers_from_file,
|
||||||
populate_annual_billing_with_defaults,
|
populate_annual_billing_with_defaults,
|
||||||
)
|
)
|
||||||
from app.dao.inbound_numbers_dao import dao_get_available_inbound_numbers
|
from app.dao.inbound_numbers_dao import dao_get_available_inbound_numbers
|
||||||
from app.models import AnnualBilling
|
from app.models import AnnualBilling, User
|
||||||
from tests.app.db import create_annual_billing, create_service
|
from tests.app.db import create_annual_billing, create_service
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_test_user_command(notify_db_session, notify_api):
|
||||||
|
|
||||||
|
# number of users before adding ours
|
||||||
|
user_count = User.query.count()
|
||||||
|
|
||||||
|
# run the command
|
||||||
|
notify_api.test_cli_runner().invoke(
|
||||||
|
create_test_user, [
|
||||||
|
'--email', 'somebody@fake.gov',
|
||||||
|
'--mobile_number', '555-555-5555',
|
||||||
|
'--password', 'correct horse battery staple',
|
||||||
|
'--name', 'Fake Personson',
|
||||||
|
# '--auth_type', 'sms_auth', # this is the default
|
||||||
|
# '--state', 'active', # this is the default
|
||||||
|
# '--admin', 'False', # this is the default
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
# there should be one more user
|
||||||
|
assert User.query.count() == user_count + 1
|
||||||
|
|
||||||
|
# that user should be the one we added
|
||||||
|
user = User.query.filter_by(
|
||||||
|
name = 'Fake Personson'
|
||||||
|
).first()
|
||||||
|
assert user.email_address == 'somebody@fake.gov'
|
||||||
|
assert user.auth_type == 'sms_auth'
|
||||||
|
assert user.state == 'active'
|
||||||
|
|
||||||
|
|
||||||
def test_insert_inbound_numbers_from_file(notify_db_session, notify_api, tmpdir):
|
def test_insert_inbound_numbers_from_file(notify_db_session, notify_api, tmpdir):
|
||||||
numbers_file = tmpdir.join("numbers.txt")
|
numbers_file = tmpdir.join("numbers.txt")
|
||||||
numbers_file.write("07700900373\n07700900473\n07700900375\n\n\n\n")
|
numbers_file.write("07700900373\n07700900473\n07700900375\n\n\n\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user