mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-20 02:14:26 -05:00
lots of renaming of send_texts/emails/letters to send_messages, and manage_settings/users to manage_service
57 lines
1.5 KiB
Python
57 lines
1.5 KiB
Python
from unittest.mock import ANY
|
|
|
|
from app import invite_api_client
|
|
|
|
|
|
def test_client_creates_invite(
|
|
app_,
|
|
mocker,
|
|
fake_uuid,
|
|
sample_invite,
|
|
):
|
|
|
|
mocker.patch('app.notify_client.current_user')
|
|
|
|
mock_post = mocker.patch(
|
|
'app.invite_api_client.post',
|
|
return_value={'data': dict.fromkeys({
|
|
'id', 'service', 'from_user', 'email_address',
|
|
'permissions', 'status', 'created_at', 'auth_type'
|
|
})}
|
|
)
|
|
|
|
invite_api_client.create_invite(
|
|
'12345', '67890', 'test@example.com', {'send_messages'}, 'sms_auth'
|
|
)
|
|
|
|
mock_post.assert_called_once_with(
|
|
url='/service/{}/invite'.format('67890'),
|
|
data={
|
|
'auth_type': 'sms_auth',
|
|
'email_address': 'test@example.com',
|
|
'from_user': '12345',
|
|
'service': '67890',
|
|
'created_by': ANY,
|
|
'permissions': 'send_emails,send_letters,send_texts',
|
|
'invite_link_host': 'http://localhost:6012',
|
|
}
|
|
)
|
|
|
|
|
|
def test_client_returns_invite(mocker, sample_invite):
|
|
|
|
sample_invite['status'] = 'pending'
|
|
service_id = sample_invite['service']
|
|
|
|
expected_data = {'data': [sample_invite]}
|
|
|
|
expected_url = '/service/{}/invite'.format(service_id)
|
|
|
|
mock_get = mocker.patch('app.notify_client.invite_api_client.InviteApiClient.get', return_value=expected_data)
|
|
|
|
invites = invite_api_client.get_invites_for_service(service_id)
|
|
|
|
mock_get.assert_called_once_with(expected_url)
|
|
assert len(invites) == 1
|
|
assert invites[0].status == 'pending'
|