"""Configuration for tests.""" from datetime import datetime import io import paramiko import pytest from .helpers import Helpers from soundrecording_utils.metadata.types import Asset from soundrecording_utils.metadata.types import ExplicitStatus from soundrecording_utils.metadata.types import Genre from soundrecording_utils.metadata.types import Label from soundrecording_utils.metadata.types import LabelID from soundrecording_utils.metadata.types import LabelParticipant from soundrecording_utils.metadata.types import LabelType from soundrecording_utils.metadata.types import Language from soundrecording_utils.metadata.types import OrchardSoundRecording from soundrecording_utils.metadata.types import Product from soundrecording_utils.metadata.types import ProductStatus from soundrecording_utils.metadata.types import Subgenre from soundrecording_utils.metadata.types import Track from soundrecording_utils.metadata.types import TrackConnection from soundrecording_utils.metadata.types import TrackParticipation @pytest.fixture def helpers(): """Test helpers.""" return Helpers() @pytest.fixture def execution_meta(): """Create Execution Metadata with default values.""" return { 'message_thread_id': 'message_thread_id', 'message_id': 'message_id', 'timestamp': datetime.fromisoformat('2020-01-02T03:04:05+00:00'), } @pytest.fixture def private_key(): """Generate private key.""" file_obj = io.StringIO('') pkey = paramiko.RSAKey.generate(1024) pkey.write_private_key(file_obj, password=None) return file_obj.getvalue() @pytest.fixture def sftp_server_and_conn_obj_pkey(sftpserver, private_key, request): """Generate sftp connection params with private key.""" return sftpserver, { 'hostname': sftpserver.host, 'port': sftpserver.port, 'username': 'username', 'pkey': private_key } @pytest.fixture def mock_label() -> Label: """Create a mock label with default values.""" return Label( uuid='94177d6a-51d4-496f-aa1a-a52b75516814', name='Test Label', type=LabelType('Subaccount'), id=LabelID( vendor=999, subaccount=888 ) ) @pytest.fixture def mock_product(mock_label: Label) -> Product: """Create a mock product with default values.""" return Product( label=mock_label, status=ProductStatus.in_content, release_date='2019-06-15', subgenre=Subgenre( id=2, name='Electronic', genre=Genre( id=1, name='Rock' ) ), id='777', display_upc='upc-123' ) @pytest.fixture def mock_label_participant() -> LabelParticipant: """Create a mock LabelParticipant with default values.""" return LabelParticipant( name='Test Participant', uuid='00000000-0000-0000-0000-000000000000' ) @pytest.fixture def mock_track_participation( mock_label_participant: LabelParticipant, ) -> TrackParticipation: """Create a mock Track Participation with default values.""" return TrackParticipation( participant=mock_label_participant, participated_as='performer' ) @pytest.fixture def mock_track(mock_product: Product, mock_asset: Asset) -> Track: """Create a mock track with default values.""" return Track( tuid='123', primary=True, explicit=ExplicitStatus.N, product=mock_product, isrc='XXAAA2100000', name='Test Track Name', version=None, duration_minutes=1, duration_seconds=2, meta_language_code=None, language=Language(iso_639_1_code=None), p_info='2021 Example Label', territories=['XX'], participations=[], original_rights_holder_country=None, recording_country=None, label_sound_recording=None ) @pytest.fixture def mock_asset() -> Asset: """Create a mock asset with default values.""" return Asset( uuid='b3955ca9-bfb0-4d09-8f18-9eb4fd8737ff', filename='90e575bd-94a5-4a3e-9f1f-dade36feb8c3', extension='flac', ) @pytest.fixture def mock_orchard_sound_recording( mock_track: Track, mock_asset: Asset) -> OrchardSoundRecording: """Create a mock OrchardSoundRecording with one track.""" return OrchardSoundRecording( track_connection=TrackConnection( tracks=[ mock_track, ], ), assets=[mock_asset], isrc='isrc-123' )