mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
Create schema for RequestVerifyCodeSchema
Previously we were using a schema that mapped onto db.Model. However, the json in the request did not reflect the VerfiyCode db Model. I did not add validation on the to field, we did not have that previously.
This commit is contained in:
@@ -348,3 +348,21 @@ def test_send_user_code_for_email_uses_optional_to_field(notify_api,
|
||||
'11111',
|
||||
'notify@digital.cabinet-office.gov.uk',
|
||||
'Verification code')
|
||||
|
||||
|
||||
def test_request_verify_code_schema_invalid_code_type(notify_api, notify_db, notify_db_session, sample_user):
|
||||
import json
|
||||
from app.schemas import request_verify_code_schema
|
||||
data = json.dumps({'code_type': 'not_sms'})
|
||||
code, error = request_verify_code_schema.loads(data)
|
||||
assert code == {}
|
||||
assert error == {'code_type': ['Invalid code type']}
|
||||
|
||||
|
||||
def test_request_verify_code_schema_with_to(notify_api, notify_db, notify_db_session, sample_user):
|
||||
import json
|
||||
from app.schemas import request_verify_code_schema
|
||||
data = json.dumps({'code_type': 'sms', 'to': 'some@one.gov.uk'})
|
||||
code, error = request_verify_code_schema.loads(data)
|
||||
assert code == {'code_type': 'sms', 'to': 'some@one.gov.uk'}
|
||||
assert error == {}
|
||||
|
||||
Reference in New Issue
Block a user