"""Test DeviceSchema schema.""" import pytest from users.validation.schemas import device @pytest.mark.parametrize( ('payload', 'expected_errors'), [ # no errors ( { 'identity_id': 'abc', 'push_token': 'abcd-2345', 'platform_type': 'ios', }, {}, ), ( { 'identity_id': 'abc', 'push_token': 'abcd-2345', 'platform_type': 'ios', 'brand': 'awal', }, {}, ), # missing required fields ( { 'push_token': 'abcd-2345', }, { 'platform_type': ['Missing data for required field.'], 'identity_id': ['Missing data for required field.'], }, ), # invalid types ( { 'identity_id': 'abc', 'push_token': 'abcd-2345', 'platform_type': 'dummy', }, { 'platform_type': ['Invalid enum member dummy'], }, ), ( { 'identity_id': 'abc', 'push_token': 'abcd-2345', 'platform_type': 'ios', 'brand': 'dummy', }, { 'brand': [ 'Must be one of: theorchard, sme, overdrive, ' 'awal, knr, orchard, helpcenter, ab, msk, altafonte.' ] }, ), ], ) def test_validate_identity_schema(payload, expected_errors): """Test validate DeviceSchema.""" schema = device.DeviceSchema() errors = schema.validate(payload) assert errors == expected_errors