"""Test configs for accounting_run_commit tasks.""" from types import SimpleNamespace import pytest from lib import constants @pytest.fixture def mock_accounting_run_abacus_states(): """Mock a set of abacus states.""" return [ { 'action_name': 'some_other_name', 'abacus_state_id': 1, 'action_status': 'init', 'parent_table_id': '1337', 'parent_table_name': 'accounting_run' }, { 'action_name': 'commit_royalties', 'abacus_state_id': 2, 'action_status': 'init', 'parent_table_id': '2322', 'parent_table_name': 'accounting_run' } ] @pytest.fixture def mock_commit_event(): """Mock "commit" abacus_event that would be passed between DAG tasks.""" return { 'abacus_event_id': 1, 'event_date': '2022-08-03 18:57:21.590679', 'event_name': constants.DAG_ACCOUNTING_RUN_COMMIT_EVENT_NAME, 'statement_period_id': 200, 'target_id': 1021, 'target_type': constants.DAG_ACCOUNTING_RUN_COMMIT_TARGET_TYPE, 'user_id': '1', 'user_type': 'orchard-suite' } @pytest.fixture def mock_commit_dag_run(mock_commit_event): """Mock commit dag run passed between DAG tasks.""" return SimpleNamespace(conf=mock_commit_event) @pytest.fixture def mock_commit_royalties_event(): """Mock accounting_period 'commit_royalties' abacus_event.""" return { 'abacus_event_id': 1, 'event_date': '2020-07-17 18:57:21.590679', 'event_name': constants.DAG_COMMIT_COMMIT_ROYALTIES_EVENT_NAME, 'target_id': 1021, 'target_type': constants.DAG_ACCOUNTING_RUN_COMMIT_TARGET_TYPE, 'user_id': '1', 'user_type': 'orchard-suite' } @pytest.fixture def mock_take_reserves_event(): """Mock 'take_reserves' abacus_event, created for invoking reserves_take lambda.""" return { 'abacus_event_id': 2, 'event_date': '2022-08-03 18:57:21.590679', 'event_name': constants.DAG_COMMIT_TAKE_RESERVES_EVENT_NAME, 'statement_period_id': 200, 'target_id': 1021, 'target_type': constants.DAG_ACCOUNTING_RUN_COMMIT_TARGET_TYPE, 'user_id': '1', 'user_type': 'orchard-suite' } @pytest.fixture def mock_schedule_reserves_event(): """Mock 'schedule_reserves' abacus_event.""" return { 'abacus_event_id': 1, 'event_date': '2020-07-17 18:57:21.590679', 'event_name': constants.DAG_SCHEDULE_RESERVES, 'target_id': 1021, 'target_type': constants.DAG_ACCOUNTING_RUN_COMMIT_TARGET_TYPE, 'user_id': '1', 'user_type': 'orchard-suite' } @pytest.fixture def mock_accounting_run(): """Mock accounting_run details.""" return { 'accounting_run_id': 1021, 'accounting_period_name': 'Mock Period 2', 'accounting_period_id': 1, 'accounting_run_status': 'Committed', 'run_controller_id': 1, 'run_controller_name': 'Parallel Run Tests', 'summary_export_url': 's3://sales-files/2-mock-period-2/monthly-summary.tsv', # noqa: E501 'start_date': '2021-11-01' }