"""Test IdentityToProfile schema.""" import pytest from users.validation.schemas import identity_to_profile @pytest.mark.parametrize( ('payload', 'expected_errors'), [ # no errors ( { 'profile_id': 12345, 'profile_type': 'InsightsProfile', 'identity_id': '123456789123456789123456', }, {}, ), # missing required fields ( {'profile_id': 12345}, { 'profile_type': ['Missing data for required field.'], 'identity_id': ['Missing data for required field.'], }, ), # invalid types ( { 'profile_id': 'test', 'profile_type': 'InsightsProfile', 'identity_id': '123456789123456789123456', }, {'profile_id': ['Not a valid integer.']}, ), # invalid enum type ( { 'profile_id': 12345, 'profile_type': 'BadProfile', 'identity_id': '123456789123456789123456', }, {'profile_type': ['Invalid enum member BadProfile']}, ), ], ) def test_validate_identity_schema(payload, expected_errors): """Test validate IdentityToProfile schema.""" identity_to_profile_schema = identity_to_profile.IdentityToProfile() errors = identity_to_profile_schema.validate(payload) assert errors == expected_errors