"""Tests for commit functions.""" from types import SimpleNamespace as Obj from unittest.mock import patch from accounting_run_commit import complete_commit from accounting_run_commit import notify_failure import pytest @patch('accounting_run_commit.update_accounting_run') def test_complete_commit(mock_update, accounting_run_commit_dag_config): """Test successful completion of accounting_run_commit.""" accounting_run_id = accounting_run_commit_dag_config['target_id'] complete_commit(Obj(conf=accounting_run_commit_dag_config)) mock_update.assert_called_with( accounting_run_id, accounting_run_status='Committed' ) @patch('accounting_run_commit.update_accounting_run') def test_notify_failure(mock_update, accounting_run_commit_dag_config): """Test accounting_run_commit failure.""" accounting_run_id = accounting_run_commit_dag_config['target_id'] with pytest.raises(ValueError): notify_failure(Obj(conf=accounting_run_commit_dag_config)) mock_update.assert_called_with(accounting_run_id, accounting_run_status='Error')