@@ -108,61 +108,59 @@ def init_response(
108
108
)
109
109
110
110
if quote :
111
+ response_data = {
112
+ "1" : {
113
+ "id" : 1 ,
114
+ "name" : "Bitcoin" ,
115
+ "slug" : "bitcoin" ,
116
+ "symbol" : "BTC" ,
117
+ "circulating_supply" : 100 ,
118
+ "total_supply" : 1000 ,
119
+ "date_added" : (now - timedelta (days = 5 )).strftime (iso_fmt ),
120
+ "num_market_pairs" : 1 ,
121
+ "cmc_rank" : 1 ,
122
+ "last_updated" : (now - timedelta (hours = 1 )).strftime (iso_fmt ),
123
+ "tags" : [],
124
+ "quote" : {
125
+ "BTC" : {
126
+ "price" : 2 ,
127
+ "volume_24h" : 5 ,
128
+ "market_cap" : 97 ,
129
+ "percent_change_1h" : 12.5 ,
130
+ "percent_change_24h" : 17.4 ,
131
+ "percent_change_7d" : 54.1 ,
132
+ "last_updated" : (now - timedelta (minutes = 6 )).strftime (iso_fmt ),
133
+ },
134
+ "USD" : {
135
+ "price" : 50000000000 ,
136
+ "volume_24h" : 20 ,
137
+ "market_cap" : 92 ,
138
+ "percent_change_1h" : 14.5 ,
139
+ "percent_change_24h" : pct_change ,
140
+ "percent_change_7d" : 24.5 ,
141
+ "last_updated" : (now - timedelta (minutes = 3 )).strftime (iso_fmt ),
142
+ },
143
+ },
144
+ },
145
+ }
146
+ data = {
147
+ "status" : {
148
+ "timestamp" : now .strftime (iso_fmt ),
149
+ "error_code" : 400 if error_msg else 200 ,
150
+ "error_message" : error_msg ,
151
+ "elapsed" : 1 ,
152
+ "credit_count" : 1 ,
153
+ },
154
+ }
155
+ if not error_msg :
156
+ data ["data" ] = response_data
157
+
111
158
mock_requests .add (
112
159
MatchAPIKey (
113
160
"GET" ,
114
161
"https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=BTC&convert=USD%2CBTC" ,
115
162
api_key = "APIKEY" if check_api_key else None ,
116
- json = {
117
- "status" : {
118
- "timestamp" : now .strftime (iso_fmt ),
119
- "error_code" : 400 if error_msg else 200 ,
120
- "error_message" : error_msg ,
121
- "elapsed" : 1 ,
122
- "credit_count" : 1 ,
123
- },
124
- "data" : {
125
- "1" : {
126
- "id" : 1 ,
127
- "name" : "Bitcoin" ,
128
- "slug" : "bitcoin" ,
129
- "symbol" : "BTC" ,
130
- "circulating_supply" : 100 ,
131
- "total_supply" : 1000 ,
132
- "date_added" : (now - timedelta (days = 5 )).strftime (iso_fmt ),
133
- "num_market_pairs" : 1 ,
134
- "cmc_rank" : 1 ,
135
- "last_updated" : (now - timedelta (hours = 1 )).strftime (
136
- iso_fmt
137
- ),
138
- "tags" : [],
139
- "quote" : {
140
- "BTC" : {
141
- "price" : 2 ,
142
- "volume_24h" : 5 ,
143
- "market_cap" : 97 ,
144
- "percent_change_1h" : 12.5 ,
145
- "percent_change_24h" : 17.4 ,
146
- "percent_change_7d" : 54.1 ,
147
- "last_updated" : (
148
- now - timedelta (minutes = 6 )
149
- ).strftime (iso_fmt ),
150
- },
151
- "USD" : {
152
- "price" : 50000000000 ,
153
- "volume_24h" : 20 ,
154
- "market_cap" : 92 ,
155
- "percent_change_1h" : 14.5 ,
156
- "percent_change_24h" : pct_change ,
157
- "percent_change_7d" : 24.5 ,
158
- "last_updated" : (
159
- now - timedelta (minutes = 3 )
160
- ).strftime (iso_fmt ),
161
- },
162
- },
163
- },
164
- },
165
- },
163
+ json = data ,
166
164
)
167
165
)
168
166
0 commit comments