@@ -753,6 +753,7 @@ def test_spice_flight_authenticate_with_api_key(
753753 tls_root_certs = b"cert" ,
754754 )
755755
756+ assert flight_instance is not None
756757 mock_client .authenticate_basic_token .assert_called_with ("" , "test-api-key" )
757758
758759 @patch ("spicepy._client.flight" )
@@ -761,7 +762,7 @@ def test_spice_flight_query_basic(
761762 mock_flight : MagicMock ,
762763 ) -> None :
763764 """Test _SpiceFlight.query method."""
764- from spicepy ._client import _SpiceFlight , _ArrowFlightCallThread
765+ from spicepy ._client import _SpiceFlight
765766
766767 mock_client = MagicMock ()
767768 mock_flight .connect .return_value = mock_client
@@ -774,19 +775,18 @@ def test_spice_flight_query_basic(
774775 mock_client .get_flight_info .return_value = mock_flight_info
775776
776777 mock_reader = MagicMock ()
777- mock_client .do_get .return_value = mock_reader
778778
779779 flight_instance = _SpiceFlight (
780780 grpc = "grpc://localhost:50051" ,
781781 api_key = "" ,
782782 tls_root_certs = b"cert" ,
783783 )
784784
785- with patch .object (_ArrowFlightCallThread , "start" ):
786- with patch .object (_ArrowFlightCallThread , "is_alive" , return_value = False ):
787- with patch .object (_ArrowFlightCallThread , "reader" , mock_reader , create = True ):
788- result = flight_instance .query ("SELECT 1" )
785+ # Mock the _threaded_flight_do_get method directly
786+ with patch .object (flight_instance , "_threaded_flight_do_get" , return_value = mock_reader ):
787+ result = flight_instance .query ("SELECT 1" )
789788
789+ assert result is mock_reader
790790 mock_client .get_flight_info .assert_called_once ()
791791
792792 @patch ("spicepy._client.flight" )
@@ -795,7 +795,7 @@ def test_spice_flight_query_with_timeout(
795795 mock_flight : MagicMock ,
796796 ) -> None :
797797 """Test _SpiceFlight.query with timeout parameter."""
798- from spicepy ._client import _SpiceFlight , _ArrowFlightCallThread
798+ from spicepy ._client import _SpiceFlight
799799
800800 mock_client = MagicMock ()
801801 mock_flight .connect .return_value = mock_client
@@ -815,10 +815,9 @@ def test_spice_flight_query_with_timeout(
815815 tls_root_certs = b"cert" ,
816816 )
817817
818- with patch .object (_ArrowFlightCallThread , "start" ):
819- with patch .object (_ArrowFlightCallThread , "is_alive" , return_value = False ):
820- with patch .object (_ArrowFlightCallThread , "reader" , mock_reader , create = True ):
821- flight_instance .query ("SELECT 1" , timeout = 60 )
818+ # Mock the _threaded_flight_do_get method directly
819+ with patch .object (flight_instance , "_threaded_flight_do_get" , return_value = mock_reader ):
820+ flight_instance .query ("SELECT 1" , timeout = 60 )
822821
823822 @patch ("spicepy._client.flight" )
824823 def test_spice_flight_query_invalid_timeout_raises (
@@ -849,9 +848,10 @@ def test_spice_flight_query_reauthenticate_on_unauthenticated(
849848 mock_flight : MagicMock ,
850849 ) -> None :
851850 """Test _SpiceFlight.query re-authenticates on FlightUnauthenticatedError."""
852- from spicepy ._client import _SpiceFlight , _ArrowFlightCallThread
853851 from pyarrow ._flight import FlightUnauthenticatedError
854852
853+ from spicepy ._client import _SpiceFlight
854+
855855 mock_client = MagicMock ()
856856 mock_flight .connect .return_value = mock_client
857857 mock_flight .FlightUnauthenticatedError = FlightUnauthenticatedError
@@ -894,7 +894,6 @@ def test_spice_flight_authenticate_without_api_key(
894894 ) -> None :
895895 """Test _SpiceFlight authentication without API key."""
896896 from spicepy ._client import _SpiceFlight
897- from spicepy .config import SPICE_USER_AGENT
898897
899898 mock_client = MagicMock ()
900899 mock_flight .connect .return_value = mock_client
@@ -1012,4 +1011,3 @@ def test_is_macos_arm64_false_intel_mac(self, mock_platform: MagicMock) -> None:
10121011 mock_platform .machine .return_value = "x86_64"
10131012
10141013 assert is_macos_arm64 () is False
1015-
0 commit comments