"""Unit tests for the logic related to using the shared validation logic.""" from unittest.mock import MagicMock, patch from adjustment_file_validation.validations.shared_validation import ( validate_with_shared_validation, ) @patch('adjustment_file_validation.validations.shared_validation.validate_adjustments') @patch( 'adjustment_file_validation.validations.shared_validation.AdjustmentsValidationSnowflakeExecutor' ) def test_validate_with_shared_validation(mock_sf, mock_validate): """Test running the shared validation.""" adjustments = MagicMock() statement_period_id = 1 sf_executor_mock = MagicMock() mock_sf.return_value.__enter__.return_value = sf_executor_mock mock_validate.return_value = {0: {'ERROR 1'}, 1: {'ERROR 1', 'ERROR 2'}} results = validate_with_shared_validation( adjustments=adjustments, statement_period_id=statement_period_id, start_index=2, ) mock_validate.assert_called_once_with( adjustments, statement_period_id, sf_executor_mock ) assert list(results.keys()) == [2, 3] assert 'ERROR 1' in results[2] assert 'ERROR 2' not in results[2] assert 'ERROR 1' in results[3] assert 'ERROR 2' in results[3]