"""Seed data builders for generate_attachments lambda integration tests.""" from datetime import datetime from pathlib import Path from typing import Any from tests import config # tests must run from the tests/ directory FIXTURE_REPORTS_DIR = Path('src/fixture_reports') def _today() -> str: return datetime.now().strftime('%Y%m%d') def _make_seed( *, account_id: int, statement_attachment_type: str, statement_period_id: int = 320, statement_period_name: str = 'August 2025', file_type: str = 'csv', contract_id: int | None = None, subaccount_id: int | None = None, fixture_file_path: Path | None = None, expected_filename: str | None = None, ) -> dict[str, Any]: data: dict[str, Any] = { 'account_id': account_id, 'statement_period_id': statement_period_id, 'statement_period_name': statement_period_name, 'statement_attachment_status': 'in_progress', 'statement_attachment_type': statement_attachment_type, 'file_type': file_type, 'created_by': config.TEST_USER, 'created_at': datetime.now(), } if contract_id is not None: data['contract_id'] = contract_id if subaccount_id is not None: data['subaccount_id'] = subaccount_id if fixture_file_path is not None: data['fixture_file_path'] = fixture_file_path data['expected_filename'] = ( expected_filename if expected_filename is not None else fixture_file_path.stem ) return data # --- Regular account --- def seed_data_revenue_detail_regular() -> dict[str, Any]: filename = 'Times_Ten_Records_323332_August_2025_revenue_details' return _make_seed( account_id=7378, statement_attachment_type='revenue_detail', contract_id=323332, fixture_file_path=(FIXTURE_REPORTS_DIR / 'regular_account' / f'{filename}.csv'), ) def seed_data_revenue_detail_scientific() -> dict[str, Any]: filename = 'Scarlett_Fletcher_t_a_Scarlett_Fae_528703_August_2025_revenue_details' return _make_seed( account_id=64391, statement_attachment_type='revenue_detail', contract_id=528703, fixture_file_path=(FIXTURE_REPORTS_DIR / 'regular_account' / f'{filename}.csv'), ) def seed_data_legacy_revenue_detail_full_regular() -> dict[str, Any]: filename_base = 'August_2025_fullreport_Times_Ten_Records' return _make_seed( account_id=7378, statement_attachment_type='legacy_revenue_detail_full', file_type='xls', contract_id=323332, fixture_file_path=( FIXTURE_REPORTS_DIR / 'regular_account' / f'{filename_base}.xls' ), expected_filename=f'{_today()}_{filename_base}', ) def seed_data_legacy_revenue_detail_physical() -> dict[str, Any]: filename_base = 'August_2025_physicalreport_Mermaid_Music_A_S' return _make_seed( account_id=25251, statement_attachment_type='legacy_revenue_detail_physical', file_type='xls', contract_id=92229, fixture_file_path=( FIXTURE_REPORTS_DIR / 'regular_account' / f'{filename_base}.xls' ), expected_filename=f'{_today()}_{filename_base}', ) def seed_data_nr_performer_revenue() -> dict[str, Any]: filename = 'McCarthy__Nicholas_John_533767_August_2025_nr_revenue_details' return _make_seed( account_id=68273, statement_attachment_type='nr_performer_revenue', file_type='csv', contract_id=533767, fixture_file_path=(FIXTURE_REPORTS_DIR / 'regular_account' / f'{filename}.csv'), ) def seed_data_nr_label_revenue() -> dict[str, Any]: filename = 'Redwing_Records__LLC_535906_August_2025_nr_label_revenue_details' return _make_seed( account_id=68643, statement_attachment_type='nr_label_revenue', file_type='csv', contract_id=535906, fixture_file_path=(FIXTURE_REPORTS_DIR / 'regular_account' / f'{filename}.csv'), ) # --- D3 account --- def seed_data_revenue_detail_d3() -> dict[str, Any]: filename = 'Hal_Leonard_Corporation_307956_August_2025_revenue_details' return _make_seed( account_id=22079, statement_attachment_type='revenue_detail', contract_id=307956, fixture_file_path=(FIXTURE_REPORTS_DIR / 'd3_account' / f'{filename}.csv'), ) def seed_data_legacy_revenue_detail_full_d3() -> dict[str, Any]: filename_base = 'August_2025_fullreport_Hal_Leonard_Corporation' return _make_seed( account_id=22079, statement_attachment_type='legacy_revenue_detail_full', file_type='xls', fixture_file_path=(FIXTURE_REPORTS_DIR / 'd3_account' / f'{filename_base}.xls'), expected_filename=f'{_today()}_{filename_base}', ) def seed_data_legacy_revenue_detail_physical_d3() -> dict[str, Any]: filename_base = ( 'August_2025_physicalreport_XJAZZ__Music_-_Sebastian_Studnitzky___Paul_Kleber' ) return _make_seed( account_id=27149, statement_attachment_type='legacy_revenue_detail_physical', file_type='xls', fixture_file_path=(FIXTURE_REPORTS_DIR / 'd3_account' / f'{filename_base}.xls'), expected_filename=f'{_today()}_{filename_base}_', # trailing _ is intentional ) # --- Subaccount --- def seed_data_revenue_detail_subaccount() -> dict[str, Any]: filename = 'Hal_Leonard_Corporation_August_2025_revenue_details' return _make_seed( account_id=22079, statement_attachment_type='revenue_detail', subaccount_id=10182, fixture_file_path=(FIXTURE_REPORTS_DIR / 'sub_account' / f'{filename}.csv'), ) def seed_data_legacy_revenue_detail_full_subaccount() -> dict[str, Any]: filename_base = 'August_2025_fullreport_Hal_Leonard_Corporation' return _make_seed( account_id=22079, statement_attachment_type='legacy_revenue_detail_full', file_type='xls', subaccount_id=10182, fixture_file_path=( FIXTURE_REPORTS_DIR / 'sub_account' / f'{filename_base}.xls' ), expected_filename=f'{_today()}_{filename_base}', ) def seed_data_legacy_revenue_detail_physical_subaccount() -> dict[str, Any]: filename_base = 'August_2025_physicalreport_XJAZZ_music' return _make_seed( account_id=27149, statement_attachment_type='legacy_revenue_detail_physical', file_type='xls', subaccount_id=42671, fixture_file_path=( FIXTURE_REPORTS_DIR / 'sub_account' / f'{filename_base}.xls' ), expected_filename=f'{_today()}_{filename_base}', ) def seed_data_error_validation() -> dict[str, Any]: return _make_seed( account_id=69006, statement_attachment_type='distribution_fee_invoice', statement_period_id=325, statement_period_name='January 2026', file_type='pdf', contract_id=536526, )