BlockingChannel.basic_nack with requeue=False
(self)
| 1258 | class TestBasicNackNoRequeue(BlockingTestCaseBase): |
| 1259 | |
| 1260 | def test(self): |
| 1261 | """BlockingChannel.basic_nack with requeue=False""" |
| 1262 | connection = self._connect() |
| 1263 | |
| 1264 | ch = connection.channel() |
| 1265 | |
| 1266 | q_name = 'TestBasicNackNoRequeue_q' + uuid.uuid1().hex |
| 1267 | |
| 1268 | # Place channel in publisher-acknowledgments mode so that the message |
| 1269 | # may be delivered synchronously to the queue by publishing it with |
| 1270 | # mandatory=True |
| 1271 | ch.confirm_delivery() |
| 1272 | |
| 1273 | # Declare a new queue |
| 1274 | ch.queue_declare(q_name, exclusive=True) |
| 1275 | |
| 1276 | # Deposit two messages in the queue via default exchange |
| 1277 | ch.basic_publish(exchange='', |
| 1278 | routing_key=q_name, |
| 1279 | body='TestBasicNackNoRequeue1', |
| 1280 | mandatory=True) |
| 1281 | ch.basic_publish(exchange='', |
| 1282 | routing_key=q_name, |
| 1283 | body='TestBasicNackNoRequeue2', |
| 1284 | mandatory=True) |
| 1285 | |
| 1286 | # Get the messages |
| 1287 | (rx_method, _, rx_body) = ch.basic_get(q_name, auto_ack=False) |
| 1288 | self.assertEqual(rx_body, as_bytes('TestBasicNackNoRequeue1')) |
| 1289 | |
| 1290 | (rx_method, _, rx_body) = ch.basic_get(q_name, auto_ack=False) |
| 1291 | self.assertEqual(rx_body, as_bytes('TestBasicNackNoRequeue2')) |
| 1292 | |
| 1293 | # Nack the second message |
| 1294 | ch.basic_nack(rx_method.delivery_tag, requeue=False) |
| 1295 | |
| 1296 | # Verify that no messages are present in the queue |
| 1297 | self._assert_exact_message_count_with_retries(channel=ch, |
| 1298 | queue=q_name, |
| 1299 | expected_count=0) |
| 1300 | |
| 1301 | |
| 1302 | class TestBasicNackMultiple(BlockingTestCaseBase): |
nothing calls this directly
no test coverage detected