1
1
from blockfrost import BlockFrostApi , ApiError
2
2
from blockfrost .api .cardano .accounts import \
3
3
AccountResponse , \
4
- AccountRewardResponse
4
+ AccountRewardResponse , \
5
+ AccountHistoryResponse , \
6
+ AccountDelegationResponse , \
7
+ AccountRegistrationResponse , \
8
+ AccountWithdrawalResponse , \
9
+ AccountMIRSResponse , \
10
+ AccountAddressResponse , \
11
+ AccountAddressesAssetResponse
5
12
6
- address = 'addr1q9ucyt3s5f4naz3n7fwpnt3a0t75kl3rxdvpe63e2gdes7dzs4s26v4800nwg8jygvrdqh6xhsphct0d4zqsnd3sagxq6kwrts'
7
13
stake_address = 'stake1ux3g2c9dx2nhhehyrezyxpkstartcqmu9hk63qgfkccw5rqttygt7'
8
14
9
15
@@ -23,7 +29,7 @@ def test_accounts(requests_mock):
23
29
}
24
30
requests_mock .get (f"{ api .url } /accounts/{ stake_address } " , json = mock_data )
25
31
mock_object = AccountResponse (** mock_data )
26
- assert api .accounts (stake_address = stake_address ). stake_address == mock_object . stake_address
32
+ assert api .accounts (stake_address = stake_address ) == mock_object
27
33
28
34
29
35
def test_account_rewards (requests_mock ):
@@ -52,68 +58,133 @@ def test_account_rewards(requests_mock):
52
58
]
53
59
requests_mock .get (f"{ api .url } /accounts/{ stake_address } /rewards" , json = mock_data )
54
60
mock_object = [AccountRewardResponse (** data ) for data in mock_data ]
55
- assert api .account_rewards (stake_address = stake_address )[ 0 ]. pool_id == mock_object [ 0 ]. pool_id
61
+ assert api .account_rewards (stake_address = stake_address ) == mock_object
56
62
57
63
58
- def test_account_history ():
59
- assert True
60
-
61
-
62
- def test_account_delegations ():
63
- assert True
64
-
65
-
66
- def test_account_registrations ():
67
- assert True
68
-
69
-
70
- def test_account_withdrawals ():
71
- assert True
72
-
73
-
74
- def test_account_mirs ():
75
- assert True
76
-
77
-
78
- def test_account_addresses ():
79
- assert True
80
-
81
-
82
- def test_account_addresses_assets ():
83
- assert True
84
-
85
-
86
- def test_account ():
87
- assert True
88
-
89
-
90
- def test_account_reward ():
91
- assert True
92
-
93
-
94
- def test_account_history ():
95
- assert True
64
+ def test_account_history (requests_mock ):
65
+ api = BlockFrostApi ()
66
+ mock_data = [
67
+ {
68
+ "active_epoch" : 210 ,
69
+ "amount" : "12695385" ,
70
+ "pool_id" : "pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
71
+ },
72
+ {
73
+ "active_epoch" : 211 ,
74
+ "amount" : "22695385" ,
75
+ "pool_id" : "pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
76
+ }
77
+ ]
78
+ requests_mock .get (f"{ api .url } /accounts/{ stake_address } /history" , json = mock_data )
79
+ mock_object = [AccountHistoryResponse (** data ) for data in mock_data ]
80
+ assert api .account_history (stake_address = stake_address ) == mock_object
96
81
97
82
98
- def test_account_delegation ():
99
- assert True
83
+ def test_account_delegations (requests_mock ):
84
+ api = BlockFrostApi ()
85
+ mock_data = [
86
+ {
87
+ "active_epoch" : 210 ,
88
+ "tx_hash" : "2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531" ,
89
+ "amount" : "12695385" ,
90
+ "pool_id" : "pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
91
+ },
92
+ {
93
+ "active_epoch" : 242 ,
94
+ "tx_hash" : "1a0570af966fb355a7160e4f82d5a80b8681b7955f5d44bec0dde628516157f0" ,
95
+ "amount" : "12691385" ,
96
+ "pool_id" : "pool1kchver88u3kygsak8wgll7htr8uxn5v35lfrsyy842nkscrzyvj"
97
+ }
98
+ ]
99
+ requests_mock .get (f"{ api .url } /accounts/{ stake_address } /delegations" , json = mock_data )
100
+ mock_object = [AccountDelegationResponse (** data ) for data in mock_data ]
101
+ assert api .account_delegations (stake_address = stake_address ) == mock_object
100
102
101
103
102
- def test_account_registration ():
103
- assert True
104
+ def test_account_registrations (requests_mock ):
105
+ api = BlockFrostApi ()
106
+ mock_data = [
107
+ {
108
+ "tx_hash" : "2dd15e0ef6e6a17841cb9541c27724072ce4d4b79b91e58432fbaa32d9572531" ,
109
+ "action" : "registered"
110
+ },
111
+ {
112
+ "tx_hash" : "1a0570af966fb355a7160e4f82d5a80b8681b7955f5d44bec0dde628516157f0" ,
113
+ "action" : "deregistered"
114
+ }
115
+ ]
116
+ requests_mock .get (f"{ api .url } /accounts/{ stake_address } /registrations" , json = mock_data )
117
+ mock_object = [AccountRegistrationResponse (** data ) for data in mock_data ]
118
+ assert api .account_registrations (stake_address = stake_address ) == mock_object
104
119
105
120
106
- def test_account_withdrawals ():
107
- assert True
121
+ def test_account_withdrawals (requests_mock ):
122
+ api = BlockFrostApi ()
123
+ mock_data = [
124
+ {
125
+ "tx_hash" : "48a9625c841eea0dd2bb6cf551eabe6523b7290c9ce34be74eedef2dd8f7ecc5" ,
126
+ "amount" : "454541212442"
127
+ },
128
+ {
129
+ "tx_hash" : "4230b0cbccf6f449f0847d8ad1d634a7a49df60d8c142bb8cc2dbc8ca03d9e34" ,
130
+ "amount" : "97846969"
131
+ }
132
+ ]
133
+ requests_mock .get (f"{ api .url } /accounts/{ stake_address } /withdrawals" , json = mock_data )
134
+ mock_object = [AccountWithdrawalResponse (** data ) for data in mock_data ]
135
+ assert api .account_withdrawals (stake_address = stake_address ) == mock_object
108
136
109
137
110
- def test_account_mirs ():
111
- assert True
138
+ def test_account_mirs (requests_mock ):
139
+ api = BlockFrostApi ()
140
+ mock_data = [
141
+ {
142
+ "tx_hash" : "69705bba1d687a816ff5a04ec0c358a1f1ef075ab7f9c6cc2763e792581cec6d" ,
143
+ "amount" : "2193707473"
144
+ },
145
+ {
146
+ "tx_hash" : "baaa77b63d4d7d2bb3ab02c9b85978c2092c336dede7f59e31ad65452d510c13" ,
147
+ "amount" : "14520198574"
148
+ }
149
+ ]
150
+ requests_mock .get (f"{ api .url } /accounts/{ stake_address } /mirs" , json = mock_data )
151
+ mock_object = [AccountMIRSResponse (** data ) for data in mock_data ]
152
+ assert api .account_mirs (stake_address = stake_address ) == mock_object
112
153
113
154
114
- def test_account_address ():
115
- assert True
155
+ def test_account_addresses (requests_mock ):
156
+ api = BlockFrostApi ()
157
+ mock_data = [
158
+ {
159
+ "address" : "addr1qx2kd28nq8ac5prwg32hhvudlwggpgfp8utlyqxu6wqgz62f79qsdmm5dsknt9ecr5w468r9ey0fxwkdrwh08ly3tu9sy0f4qd"
160
+ },
161
+ {
162
+ "address" : "addr1qys3czp8s9thc6u2fqed9yq3h24nyw28uk0m6mkgn9dkckjf79qsdmm5dsknt9ecr5w468r9ey0fxwkdrwh08ly3tu9suth4w4"
163
+ },
164
+ {
165
+ "address" : "addr1q8j55h253zcvl326sk5qdt2n8z7eghzspe0ekxgncr796s2f79qsdmm5dsknt9ecr5w468r9ey0fxwkdrwh08ly3tu9sjmd35m"
166
+ },
167
+ {
168
+ "address" : "addr1q8f7gxrprank3drhx8k5grlux7ene0nlwun8y9thu8mc3yjf79qsdmm5dsknt9ecr5w468r9ey0fxwkdrwh08ly3tu9sls6vnt"
169
+ }
170
+ ]
171
+ requests_mock .get (f"{ api .url } /accounts/{ stake_address } /addresses" , json = mock_data )
172
+ mock_object = [AccountAddressResponse (** data ) for data in mock_data ]
173
+ assert api .account_addresses (stake_address = stake_address ) == mock_object
116
174
117
175
118
- def test_account_addresses_asset ():
119
- assert True
176
+ def test_account_addresses_assets (requests_mock ):
177
+ api = BlockFrostApi ()
178
+ mock_data = [
179
+ {
180
+ "unit" : "d5e6bf0500378d4f0da4e8dde6becec7621cd8cbf5cbb9b87013d4cc537061636542756433343132" ,
181
+ "quantity" : "1"
182
+ },
183
+ {
184
+ "unit" : "b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e" ,
185
+ "quantity" : "125"
186
+ }
187
+ ]
188
+ requests_mock .get (f"{ api .url } /accounts/{ stake_address } /addresses/assets" , json = mock_data )
189
+ mock_object = [AccountAddressesAssetResponse (** data ) for data in mock_data ]
190
+ assert api .account_addresses_assets (stake_address = stake_address ) == mock_object
0 commit comments