1
+ from _pytest .logging import LogCaptureFixture
1
2
import pytest
2
3
4
+ from pytest_mock import MockerFixture
5
+
3
6
from mock import AsyncMock
4
7
5
8
6
- from pythclient .solana import SolanaAccount , SolanaPublicKey
9
+ from pythclient .solana import SolanaAccount , SolanaPublicKey , SolanaClient
7
10
8
11
9
12
@pytest .fixture
10
- def solana_pubkey ():
13
+ def solana_pubkey () -> SolanaPublicKey :
11
14
return SolanaPublicKey ("AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J" )
12
15
13
16
14
17
@pytest .fixture
15
- def solana_account (solana_pubkey , solana_client ) :
18
+ def solana_account (solana_pubkey : SolanaPublicKey , solana_client : SolanaClient ) -> SolanaAccount :
16
19
return SolanaAccount (
17
20
key = solana_pubkey ,
18
21
solana = solana_client ,
19
22
)
20
23
21
24
22
25
@pytest .fixture ()
23
- def mock_get_account_info (mocker ) :
26
+ def mock_get_account_info (mocker : MockerFixture ) -> AsyncMock :
24
27
async_mock = AsyncMock ()
25
28
mocker .patch ('pythclient.solana.SolanaClient.get_account_info' , side_effect = async_mock )
26
29
return async_mock
27
30
28
31
29
32
def test_solana_account_update_with_rpc_response (
30
- solana_pubkey , solana_client
31
- ):
33
+ solana_pubkey : SolanaPublicKey , solana_client : SolanaClient
34
+ ) -> None :
32
35
actual = SolanaAccount (
33
36
key = solana_pubkey ,
34
37
solana = solana_client ,
@@ -48,7 +51,8 @@ def test_solana_account_update_with_rpc_response(
48
51
49
52
50
53
@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 :
52
56
actual = SolanaAccount (
53
57
key = solana_pubkey ,
54
58
solana = solana_client ,
@@ -62,7 +66,10 @@ async def test_solana_account_update_success(mock_get_account_info, solana_pubke
62
66
63
67
64
68
@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 :
66
73
actual = SolanaAccount (
67
74
key = solana_pubkey ,
68
75
solana = solana_client ,
@@ -74,7 +81,10 @@ async def test_solana_account_update_fail(mock_get_account_info, caplog, solana_
74
81
75
82
76
83
@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 :
78
88
actual = SolanaAccount (
79
89
key = solana_pubkey ,
80
90
solana = solana_client ,
@@ -86,7 +96,7 @@ async def test_solana_account_update_null(mock_get_account_info, caplog, solana_
86
96
assert exc_message in caplog .text
87
97
88
98
89
- def test_solana_account_str (solana_account ) :
99
+ def test_solana_account_str (solana_account : SolanaAccount ) -> None :
90
100
actual = str (solana_account )
91
101
expected = f"SolanaAccount ({ solana_account .key } )"
92
102
assert actual == expected
0 commit comments