"""Test for HFA model.""" from unittest.mock import MagicMock from product.connectors import mysql from product.models import hfa from product.models.sql.hfa_pending_tracks import ( HFA_ELIGIBLE_TRACKS ) def test_get_hfa_eligible_tracks( monkeypatch, mock_hfa_eligible_tracks ): """Test get_hfa_eligible_tracks_info returns expected rows.""" mock_result = MagicMock() mock_result.mappings.return_value.all.return_value = mock_hfa_eligible_tracks mock_session = MagicMock() mock_session.execute.return_value = mock_result mock_db_session = MagicMock() mock_db_session.__enter__.return_value = mock_session mock_db_session.__exit__.return_value = None monkeypatch.setattr(mysql, "db_session", lambda: mock_db_session) result = hfa.get_hfa_eligible_tracks() assert result == mock_hfa_eligible_tracks mock_session.execute.assert_called_once_with(HFA_ELIGIBLE_TRACKS) def test_get_hfa_eligible_tracks_empty(monkeypatch): """Test get_hfa_eligible_tracks_info returns empty data.""" mock_session = MagicMock() mock_session.execute.return_value.mappings.return_value.all.return_value = [] mock_db_session = MagicMock() mock_db_session.__enter__.return_value = mock_session monkeypatch.setattr(mysql, "db_session", lambda: mock_db_session) result = hfa.get_hfa_eligible_tracks() assert result == [] mock_session.execute.assert_called_once_with(HFA_ELIGIBLE_TRACKS)