"""Unit tests for metadata-consistency-checks logic.""" import pytest from src.common.models.graphql import Participant from src.common.models.graphql import Participation from src.common.models.graphql import Track from src.common.models.metadata import InconsistencyReport from src.common.models.metadata import InconsistencyType from src.common.models.metadata import MissingRecord from src.common.models.metadata import TrackTable from src.logic.consistency_checks import check_label_sound_recordings class TestCheckLabelSoundRecordings: """Tests for check_track_participations.""" def test_get_track_participations_diff_full_match( self, product_metadata): """Test check_label_sound_recordings full match.""" result = check_label_sound_recordings(product_metadata) assert result.to_dict() == {} @pytest.fixture def product_metadata_with_missing_label_sound_recording( self, product_metadata, tuid_2, isrc_2, participant_uuid, participant_name, participant_role): """Fixture for art_relations.get_track_participations.""" product_metadata.product.tracks.append( Track( tuid=tuid_2, isrc=isrc_2, participations=[ Participation( participant=Participant( uuid=participant_uuid, name=participant_name ), participated_as=participant_role ) ], labelSoundRecording=None ) ) return product_metadata def test_check_label_sound_recordings_missing( self, product_metadata_with_missing_label_sound_recording, tuid_2): """Test check_label_sound_recordings missing label_sound_recording.""" result = check_label_sound_recordings(product_metadata_with_missing_label_sound_recording) expected_result = InconsistencyReport( inconsistency_type=InconsistencyType.BAD_LABEL_SOUND_RECORDINGS, missing_data=[ MissingRecord( table_name=TrackTable.name, primary_key_name=TrackTable.primary_key_name, record_id=int(tuid_2) ) ] ) assert result == expected_result