"""Tests for ProductParticpantHandlers.""" from mock import Mock from switchboard_consumer.constants.system import ORCHARD, SONY from switchboard_consumer.logic.participant.project_participant_handler \ import ProjectParticipantHandler def test_project_handler_process(): """Test project participant handlers.""" project_data = { 'owningSystem': SONY, 'ids': [ {'localId': '12345', 'system': SONY}, ], 'artist': { 'name': 'Project Artist', 'ids': [ {'localId': '000111', 'system': SONY}, ] }, 'name': 'Testing Project A', 'description': None, 'labelAccount': { 'companyCode': '222222', }, 'subAccount': { 'companyCode': '333333', }, } project_participant_handler = ProjectParticipantHandler( Mock(), Mock(), Mock(), Mock(), Mock() ) project_participant_handler.handle_participant = Mock() project_participant_handler.process(project_data) project_participant_handler.handle_participant.assert_called_with( project_data['artist'], 'primary_artist', project_data['artist']['ids'][0], None ) def test_project_handler_process_with_orchard_mapping(): """Test project participant handlers.""" project_data = { 'owningSystem': SONY, 'ids': [ {'localId': '12345', 'system': SONY}, ], 'artist': { 'name': 'Project Artist', 'ids': [ {'localId': '000111', 'system': SONY}, {'localId': 'AIID:123', 'system': ORCHARD}, ] }, 'name': 'Testing Project A', 'description': None, 'labelAccount': { 'companyCode': '222222', }, 'subAccount': { 'companyCode': '333333', }, } project_participant_handler = ProjectParticipantHandler( Mock(), Mock(), Mock(), Mock(), Mock() ) project_participant_handler.handle_participant = Mock() project_participant_handler.process(project_data) project_participant_handler.handle_participant.assert_called_with( project_data['artist'], 'primary_artist', project_data['artist']['ids'][0], project_data['artist']['ids'][1], )