summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lindsley <daniel@toastdriven.com>2013-02-22 01:46:19 -0600
committerDaniel Lindsley <daniel@toastdriven.com>2013-02-25 21:14:15 -0600
commite5ef558347ff2cddcfb86b956395bc7b584ec93c (patch)
tree95a8abdd65cf2730ca2f9b4609166b927b3afa59
parent726d78adbe6d6737c02f5fbe6be76be9538ec68f (diff)
downloadboto-e5ef558347ff2cddcfb86b956395bc7b584ec93c.tar.gz
Added a regression test for SQS's delete behavior & updated the docs.
-rw-r--r--boto/sqs/connection.py8
-rw-r--r--docs/source/sqs_tut.rst2
-rw-r--r--tests/integration/sqs/test_connection.py25
3 files changed, 28 insertions, 7 deletions
diff --git a/boto/sqs/connection.py b/boto/sqs/connection.py
index d993064a..e076de12 100644
--- a/boto/sqs/connection.py
+++ b/boto/sqs/connection.py
@@ -100,12 +100,8 @@ class SQSConnection(AWSQueryConnection):
:param queue: The SQS queue to be deleted
:type force_deletion: Boolean
- :param force_deletion: Normally, SQS will not delete a queue
- that contains messages. However, if the force_deletion
- argument is True, the queue will be deleted regardless of
- whether there are messages in the queue or not. USE WITH
- CAUTION. This will delete all messages in the queue as
- well.
+ :param force_deletion: A deprecated parameter that is no longer used by
+ SQS's API.
:rtype: bool
:return: True if the command succeeded, False otherwise
diff --git a/docs/source/sqs_tut.rst b/docs/source/sqs_tut.rst
index 9445de26..452dc7c3 100644
--- a/docs/source/sqs_tut.rst
+++ b/docs/source/sqs_tut.rst
@@ -217,7 +217,7 @@ If I want to delete the entire queue, I would use:
>>> conn.delete_queue(q)
-However, and this is a good safe guard, this won't succeed unless the queue is empty.
+This will delete the queue, even if there are still messages within the queue.
Additional Information
----------------------
diff --git a/tests/integration/sqs/test_connection.py b/tests/integration/sqs/test_connection.py
index 611d5219..0926fd1a 100644
--- a/tests/integration/sqs/test_connection.py
+++ b/tests/integration/sqs/test_connection.py
@@ -30,6 +30,7 @@ from threading import Timer
from tests.unit import unittest
from boto.sqs.connection import SQSConnection
+from boto.sqs.message import Message
from boto.sqs.message import MHMessage
from boto.exception import SQSError
@@ -215,3 +216,27 @@ class SQSConnectionTest(unittest.TestCase):
# we're giving +- .5 seconds for the total time the queue
# was blocked on the read call.
self.assertTrue(4.5 <= (end - start) <= 5.5)
+
+ def test_queue_deletion_affects_full_queues(self):
+ conn = SQSConnection()
+
+ # Nuke any leftover queues.
+ for q in conn.get_all_queues():
+ q.delete()
+
+ empty = conn.create_queue('empty%d' % int(time.time()))
+ full = conn.create_queue('full%d' % int(time.time()))
+ # Make sure they're both around.
+ self.assertEqual(len(conn.get_all_queues()), 2)
+
+ # Put a message in the full queue.
+ m1 = Message()
+ m1.set_body('This is a test message.')
+ full.write(m1)
+ self.assertEqual(full.count(), 1)
+
+ self.assertTrue(conn.delete_queue(empty))
+ # Here's the regression for the docs. SQS will delete a queue with
+ # messages in it, no ``force_deletion`` needed.
+ self.assertTrue(conn.delete_queue(full))
+ self.assertEqual(len(conn.get_all_queues()), 0)