1+ from _pytest .logging import LogCaptureFixture
12import pytest
23
4+ from pytest_mock import MockerFixture
5+
36from mock import AsyncMock
47
58
6- from pythclient .solana import SolanaAccount , SolanaPublicKey
9+ from pythclient .solana import SolanaAccount , SolanaPublicKey , SolanaClient
710
811
912@pytest .fixture
10- def solana_pubkey ():
13+ def solana_pubkey () -> SolanaPublicKey :
1114 return SolanaPublicKey ("AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J" )
1215
1316
1417@pytest .fixture
15- def solana_account (solana_pubkey , solana_client ) :
18+ def solana_account (solana_pubkey : SolanaPublicKey , solana_client : SolanaClient ) -> SolanaAccount :
1619 return SolanaAccount (
1720 key = solana_pubkey ,
1821 solana = solana_client ,
1922 )
2023
2124
2225@pytest .fixture ()
23- def mock_get_account_info (mocker ) :
26+ def mock_get_account_info (mocker : MockerFixture ) -> AsyncMock :
2427 async_mock = AsyncMock ()
2528 mocker .patch ('pythclient.solana.SolanaClient.get_account_info' , side_effect = async_mock )
2629 return async_mock
2730
2831
2932def test_solana_account_update_with_rpc_response (
30- solana_pubkey , solana_client
31- ):
33+ solana_pubkey : SolanaPublicKey , solana_client : SolanaClient
34+ ) -> None :
3235 actual = SolanaAccount (
3336 key = solana_pubkey ,
3437 solana = solana_client ,
@@ -48,7 +51,8 @@ def test_solana_account_update_with_rpc_response(
4851
4952
5053@pytest .mark .asyncio
51- async def test_solana_account_update_success (mock_get_account_info , solana_pubkey , solana_client ):
54+ async def test_solana_account_update_success (mock_get_account_info : AsyncMock ,
55+ solana_pubkey : SolanaPublicKey , solana_client : SolanaClient ) -> None :
5256 actual = SolanaAccount (
5357 key = solana_pubkey ,
5458 solana = solana_client ,
@@ -62,7 +66,10 @@ async def test_solana_account_update_success(mock_get_account_info, solana_pubke
6266
6367
6468@pytest .mark .asyncio
65- async def test_solana_account_update_fail (mock_get_account_info , caplog , solana_pubkey , solana_client ):
69+ async def test_solana_account_update_fail (mock_get_account_info : AsyncMock ,
70+ caplog : LogCaptureFixture ,
71+ solana_pubkey : SolanaPublicKey ,
72+ solana_client : SolanaClient ) -> None :
6673 actual = SolanaAccount (
6774 key = solana_pubkey ,
6875 solana = solana_client ,
@@ -74,7 +81,10 @@ async def test_solana_account_update_fail(mock_get_account_info, caplog, solana_
7481
7582
7683@pytest .mark .asyncio
77- async def test_solana_account_update_null (mock_get_account_info , caplog , solana_pubkey , solana_client ):
84+ async def test_solana_account_update_null (mock_get_account_info : AsyncMock ,
85+ caplog : LogCaptureFixture ,
86+ solana_pubkey : SolanaPublicKey ,
87+ solana_client : SolanaClient ) -> None :
7888 actual = SolanaAccount (
7989 key = solana_pubkey ,
8090 solana = solana_client ,
@@ -86,7 +96,7 @@ async def test_solana_account_update_null(mock_get_account_info, caplog, solana_
8696 assert exc_message in caplog .text
8797
8898
89- def test_solana_account_str (solana_account ) :
99+ def test_solana_account_str (solana_account : SolanaAccount ) -> None :
90100 actual = str (solana_account )
91101 expected = f"SolanaAccount ({ solana_account .key } )"
92102 assert actual == expected
0 commit comments