@@ -20,18 +20,18 @@ async def test_get_evm_vouchers(mock_post_response, make_mock_aiohttp_session):
20
20
client = AlephHttpClient (api_server = "http://localhost" )
21
21
22
22
# Patch only the get_posts who is used to fetch voucher update for EVM
23
- client . get_posts = AsyncMock (return_value = mock_post_response )
24
- voucher_service = Vouchers (client = client )
23
+ with patch . object ( client , " get_posts" , AsyncMock (return_value = mock_post_response )):
24
+ voucher_service = Vouchers (client = client )
25
25
26
- session = make_mock_aiohttp_session (MOCK_METADATA )
26
+ session = make_mock_aiohttp_session (MOCK_METADATA )
27
27
28
- # Here we patch the client sessions who gonna fetch the metdata of the NFT
29
- with patch ("aiohttp.ClientSession" , return_value = session ):
30
- vouchers = await voucher_service .get_evm_vouchers (MOCK_ADDRESS )
28
+ # Here we patch the client sessions who gonna fetch the metdata of the NFT
29
+ with patch ("aiohttp.ClientSession" , return_value = session ):
30
+ vouchers = await voucher_service .get_evm_vouchers (MOCK_ADDRESS )
31
31
32
- assert len (vouchers ) == 1
33
- assert vouchers [0 ].id == MOCK_VOUCHER_ID
34
- assert vouchers [0 ].name == MOCK_METADATA ["name" ]
32
+ assert len (vouchers ) == 1
33
+ assert vouchers [0 ].id == MOCK_VOUCHER_ID
34
+ assert vouchers [0 ].name == MOCK_METADATA ["name" ]
35
35
36
36
37
37
@pytest .mark .asyncio
@@ -61,17 +61,17 @@ async def test_fetch_vouchers_by_chain_for_evm(
61
61
mock_post_response , make_mock_aiohttp_session
62
62
):
63
63
client = AlephHttpClient (api_server = "http://localhost" )
64
- client . get_posts = AsyncMock (return_value = mock_post_response )
65
- voucher_service = Vouchers (client = client )
64
+ with patch . object ( client , " get_posts" , AsyncMock (return_value = mock_post_response )):
65
+ voucher_service = Vouchers (client = client )
66
66
67
- metadata_session = make_mock_aiohttp_session (MOCK_METADATA )
68
- with patch ("aiohttp.ClientSession" , return_value = metadata_session ):
69
- vouchers = await voucher_service .fetch_vouchers_by_chain (
70
- Chain .ETH , MOCK_ADDRESS
71
- )
67
+ metadata_session = make_mock_aiohttp_session (MOCK_METADATA )
68
+ with patch ("aiohttp.ClientSession" , return_value = metadata_session ):
69
+ vouchers = await voucher_service .fetch_vouchers_by_chain (
70
+ Chain .ETH , MOCK_ADDRESS
71
+ )
72
72
73
- assert len (vouchers ) == 1
74
- assert vouchers [0 ].id == "voucher123"
73
+ assert len (vouchers ) == 1
74
+ assert vouchers [0 ].id == "voucher123"
75
75
76
76
77
77
@pytest .mark .asyncio
@@ -98,23 +98,23 @@ async def test_get_vouchers_detects_chain(
98
98
make_mock_aiohttp_session , mock_post_response
99
99
):
100
100
client = AlephHttpClient (api_server = "http://localhost" )
101
- client . get_posts = AsyncMock (return_value = mock_post_response )
102
- voucher_service = Vouchers (client = client )
103
-
104
- # EVM
105
- metadata_session = make_mock_aiohttp_session (MOCK_METADATA )
106
- with patch ("aiohttp.ClientSession" , return_value = metadata_session ):
107
- vouchers = await voucher_service .get_vouchers (MOCK_ADDRESS )
108
- assert len (vouchers ) == 1
109
- assert vouchers [0 ].id == "voucher123"
110
-
111
- # Solana
112
- registry_session = make_mock_aiohttp_session (MOCK_SOLANA_REGISTRY )
113
- metadata_session = make_mock_aiohttp_session (MOCK_METADATA )
114
-
115
- with patch (
116
- "aiohttp.ClientSession" , side_effect = [registry_session , metadata_session ]
117
- ):
118
- vouchers = await voucher_service .get_vouchers (MOCK_SOLANA_ADDRESS )
119
- assert len (vouchers ) == 1
120
- assert vouchers [0 ].id == "solticket123"
101
+ with patch . object ( client , " get_posts" , AsyncMock (return_value = mock_post_response )):
102
+ voucher_service = Vouchers (client = client )
103
+
104
+ # EVM
105
+ metadata_session = make_mock_aiohttp_session (MOCK_METADATA )
106
+ with patch ("aiohttp.ClientSession" , return_value = metadata_session ):
107
+ vouchers = await voucher_service .get_vouchers (MOCK_ADDRESS )
108
+ assert len (vouchers ) == 1
109
+ assert vouchers [0 ].id == "voucher123"
110
+
111
+ # Solana
112
+ registry_session = make_mock_aiohttp_session (MOCK_SOLANA_REGISTRY )
113
+ metadata_session = make_mock_aiohttp_session (MOCK_METADATA )
114
+
115
+ with patch (
116
+ "aiohttp.ClientSession" , side_effect = [registry_session , metadata_session ]
117
+ ):
118
+ vouchers = await voucher_service .get_vouchers (MOCK_SOLANA_ADDRESS )
119
+ assert len (vouchers ) == 1
120
+ assert vouchers [0 ].id == "solticket123"
0 commit comments