"""Test Profile schema.""" import pytest from users.validation.schemas import profile @pytest.mark.parametrize( ('payload', 'expected_errors'), [ # no errors ( { 'orchard_identity_id': 'abcdfghj123456789qweqz', 'profile_id': 12345, 'profile_name': 'Profile Name', 'profile_type': 'ArtistProfile', 'roles': ['accounting', 'catalog', 'analytics'], }, {}, ), ( { 'orchard_identity_id': 'abcdfghj123456789qweqz', 'profile_id': 12345, 'profile_name': 'Profile Name', 'profile_type': 'ArtistProfile', 'first_name': 'first_name', 'last_name': 'last_name', 'roles': ['accounting', 'catalog', 'analytics'], 'brand': 'sme', }, {}, ), # missing required fields ( { 'orchard_identity_id': 'abcdfghj123456789qweqz', 'roles': ['accounting', 'catalog', 'analytics'], }, { 'profile_name': ['Missing data for required field.'], 'profile_type': ['Missing data for required field.'], }, ), # invalid types ( { 'orchard_identity_id': 'abcdfghj123456789qweqz', 'profile_id': '8a76bc9', 'profile_name': 777, 'profile_type': 'ArtistProfile', 'roles': 'pizza', 'brand': 'brand', }, { 'profile_id': ['Not a valid integer.'], 'roles': ['Not a valid list.'], 'profile_name': ['Not a valid string.'], 'brand': [ 'Must be one of: theorchard, sme, overdrive, ' 'awal, knr, orchard, helpcenter, ab, msk, altafonte.' ], }, ), # invalid enum value ( { 'orchard_identity_id': 'abcdfghj123456789qweqz', 'profile_id': 12345, 'profile_name': 'Profile Name', 'profile_type': 'banana', 'roles': ['accounting', 'catalog', 'analytics'], }, {'profile_type': ['Invalid enum member banana']}, ), ], ) def test_validate_profile_schema(payload, expected_errors): """Test validate Profile schema.""" profile_schema = profile.Profile() errors = profile_schema.validate(payload) assert errors == expected_errors