@@ -109,27 +109,23 @@ def queue_spec():
109
109
def test_api_queue_declare (requests_mock , rmqapi , queue_spec ):
110
110
requests_mock .put ("/api/queues/zocalo/foo" )
111
111
rmqapi .queue_declare (queue = queue_spec )
112
- rmqapi .create_component (queue_spec )
113
- assert requests_mock .call_count == 2
114
- for history in requests_mock .request_history :
115
- assert history .method == "PUT"
116
- assert history .url .endswith ("/api/queues/zocalo/foo" )
117
- assert history .json () == {
118
- "auto_delete" : True ,
119
- "arguments" : queue_spec .arguments ,
120
- }
112
+ assert requests_mock .call_count == 1
113
+ history = requests_mock .request_history [0 ]
114
+ assert history .method == "PUT"
115
+ assert history .url .endswith ("/api/queues/zocalo/foo" )
116
+ assert history .json () == {
117
+ "auto_delete" : True ,
118
+ "arguments" : queue_spec .arguments ,
119
+ }
121
120
122
121
123
122
def test_api_queue_delete (requests_mock , rmqapi , queue_spec ):
124
123
requests_mock .delete ("/api/queues/zocalo/foo" )
125
124
rmqapi .queue_delete (vhost = "zocalo" , name = "foo" , if_unused = True , if_empty = True )
126
- rmqapi .delete_component (queue_spec , if_unused = True , if_empty = True )
127
- assert requests_mock .call_count == 2
128
- for history in requests_mock .request_history :
129
- assert history .method == "DELETE"
130
- assert history .url .endswith (
131
- "/api/queues/zocalo/foo?if_unused=True&if_empty=True"
132
- )
125
+ assert requests_mock .call_count == 1
126
+ history = requests_mock .request_history [0 ]
127
+ assert history .method == "DELETE"
128
+ assert history .url .endswith ("/api/queues/zocalo/foo?if_unused=True&if_empty=True" )
133
129
134
130
135
131
def test_api_nodes (requests_mock , rmqapi ):
@@ -215,26 +211,24 @@ def exchange_spec(name):
215
211
def test_api_exchange_declare (name , requests_mock , rmqapi ):
216
212
requests_mock .put (f"/api/exchanges/zocalo/{ name } /" )
217
213
rmqapi .exchange_declare (exchange = exchange_spec (name ))
218
- rmqapi .create_component (exchange_spec (name ))
219
- assert requests_mock .call_count == 2
220
- for history in requests_mock .request_history :
221
- assert history .method == "PUT"
222
- assert history .url .endswith (f"/api/exchanges/zocalo/{ name } /" )
223
- assert history .json () == {
224
- "type" : "fanout" ,
225
- "auto_delete" : True ,
226
- "durable" : True ,
227
- }
214
+ assert requests_mock .call_count == 1
215
+ history = requests_mock .request_history [0 ]
216
+ assert history .method == "PUT"
217
+ assert history .url .endswith (f"/api/exchanges/zocalo/{ name } /" )
218
+ assert history .json () == {
219
+ "type" : "fanout" ,
220
+ "auto_delete" : True ,
221
+ "durable" : True ,
222
+ }
228
223
229
224
230
225
def test_api_exchange_delete (requests_mock , rmqapi ):
231
226
requests_mock .delete ("/api/exchanges/zocalo/foo" )
232
227
rmqapi .exchange_delete (vhost = "zocalo" , name = "foo" , if_unused = True )
233
- rmqapi .delete_component (exchange_spec ("foo" ), if_unused = True )
234
- assert requests_mock .call_count == 2
235
- for history in requests_mock .request_history :
236
- assert history .method == "DELETE"
237
- assert history .url .endswith ("/api/exchanges/zocalo/foo?if_unused=True" )
228
+ assert requests_mock .call_count == 1
229
+ history = requests_mock .request_history [0 ]
230
+ assert history .method == "DELETE"
231
+ assert history .url .endswith ("/api/exchanges/zocalo/foo?if_unused=True" )
238
232
239
233
240
234
def test_api_connections (requests_mock , rmqapi ):
@@ -298,26 +292,24 @@ def user_spec():
298
292
def test_api_add_user (requests_mock , rmqapi , user_spec ):
299
293
requests_mock .put (f"/api/users/{ user_spec .name } /" )
300
294
rmqapi .add_user (user = user_spec )
301
- rmqapi .create_component (user_spec )
302
- assert requests_mock .call_count == 2
303
- for history in requests_mock .request_history :
304
- assert history .method == "PUT"
305
- assert history .url .endswith (f"/api/users/{ user_spec .name } /" )
306
- assert history .json () == {
307
- "password_hash" : "guest" ,
308
- "hashing_algorithm" : "rabbit_password_hashing_sha256" ,
309
- "tags" : "administrator" ,
310
- }
295
+ assert requests_mock .call_count == 1
296
+ history = requests_mock .request_history [0 ]
297
+ assert history .method == "PUT"
298
+ assert history .url .endswith (f"/api/users/{ user_spec .name } /" )
299
+ assert history .json () == {
300
+ "password_hash" : "guest" ,
301
+ "hashing_algorithm" : "rabbit_password_hashing_sha256" ,
302
+ "tags" : "administrator" ,
303
+ }
311
304
312
305
313
306
def test_api_delete_user (requests_mock , rmqapi , user_spec ):
314
307
requests_mock .delete ("/api/users/guest/" )
315
308
rmqapi .delete_user (name = "guest" )
316
- rmqapi .delete_component (user_spec )
317
- assert requests_mock .call_count == 2
318
- for history in requests_mock .request_history :
319
- assert history .method == "DELETE"
320
- assert history .url .endswith ("/api/users/guest/" )
309
+ assert requests_mock .call_count == 1
310
+ history = requests_mock .request_history [0 ]
311
+ assert history .method == "DELETE"
312
+ assert history .url .endswith ("/api/users/guest/" )
321
313
322
314
323
315
def test_api_policies (requests_mock , rmqapi ):
@@ -359,23 +351,21 @@ def policy_spec():
359
351
def test_api_set_policy (requests_mock , rmqapi , policy_spec ):
360
352
requests_mock .put (f"/api/policies/foo/{ policy_spec .name } /" )
361
353
rmqapi .set_policy (policy = policy_spec )
362
- rmqapi .create_component (policy_spec )
363
- assert requests_mock .call_count == 2
364
- for history in requests_mock .request_history :
365
- assert history .method == "PUT"
366
- assert history .url .endswith (f"/api/policies/foo/{ policy_spec .name } /" )
367
- assert history .json () == {
368
- "pattern" : "^amq." ,
369
- "apply-to" : "queues" ,
370
- "definition" : {"delivery-limit" : 5 },
371
- }
354
+ assert requests_mock .call_count == 1
355
+ history = requests_mock .request_history [0 ]
356
+ assert history .method == "PUT"
357
+ assert history .url .endswith (f"/api/policies/foo/{ policy_spec .name } /" )
358
+ assert history .json () == {
359
+ "pattern" : "^amq." ,
360
+ "apply-to" : "queues" ,
361
+ "definition" : {"delivery-limit" : 5 },
362
+ }
372
363
373
364
374
365
def test_api_clear_policy (requests_mock , rmqapi , policy_spec ):
375
366
requests_mock .delete ("/api/policies/foo/bar/" )
376
367
rmqapi .clear_policy (vhost = "foo" , name = "bar" )
377
- rmqapi .delete_component (policy_spec )
378
- assert requests_mock .call_count == 2
379
- for history in requests_mock .request_history :
380
- assert history .method == "DELETE"
381
- assert history .url .endswith ("/api/policies/foo/bar/" )
368
+ assert requests_mock .call_count == 1
369
+ history = requests_mock .request_history [0 ]
370
+ assert history .method == "DELETE"
371
+ assert history .url .endswith ("/api/policies/foo/bar/" )
0 commit comments