diff options
author | Daniel Lindsley <daniel@toastdriven.com> | 2013-08-22 14:08:22 -0700 |
---|---|---|
committer | Daniel Lindsley <daniel@toastdriven.com> | 2013-08-22 14:08:22 -0700 |
commit | b22091fa21d4925e54ed0146d2f205ceb36995e4 (patch) | |
tree | e1c37db214ada098b03d055982206c732714c305 /tests/integration | |
parent | 1857409d6ca36c0b03138bc7c3116b4d31eedaea (diff) | |
download | boto-b22091fa21d4925e54ed0146d2f205ceb36995e4.tar.gz |
Added a passing test for SQS queue attributes.
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/sqs/test_connection.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/integration/sqs/test_connection.py b/tests/integration/sqs/test_connection.py index 9b2ab59a..237ae7e2 100644 --- a/tests/integration/sqs/test_connection.py +++ b/tests/integration/sqs/test_connection.py @@ -239,3 +239,44 @@ class SQSConnectionTest(unittest.TestCase): # Wait long enough for SQS to finally remove the queues. time.sleep(90) self.assertEqual(len(conn.get_all_queues()), initial_count) + + def test_get_messages_attributes(self): + conn = SQSConnection() + current_timestamp = int(time.time()) + queue_name = 'test%d' % int(time.time()) + test = conn.create_queue(queue_name) + self.addCleanup(conn.delete_queue, test) + time.sleep(65) + + # Put a message in the queue. + m1 = Message() + m1.set_body('This is a test message.') + test.write(m1) + self.assertEqual(test.count(), 1) + + # Check all attributes. + msgs = test.get_messages( + num_messages=1, + attributes='All' + ) + for msg in msgs: + self.assertEqual(msg.attributes['ApproximateReceiveCount'], '1') + first_rec = msg.attributes['ApproximateFirstReceiveTimestamp'] + first_rec = int(first_rec) / 1000 + self.assertTrue(first_rec >= current_timestamp) + + # Put another message in the queue. + m2 = Message() + m2.set_body('This is another test message.') + test.write(m2) + self.assertEqual(test.count(), 1) + + # Check a specific attribute. + msgs = test.get_messages( + num_messages=1, + attributes='ApproximateReceiveCount' + ) + for msg in msgs: + self.assertEqual(msg.attributes['ApproximateReceiveCount'], '1') + with self.assertRaises(KeyError): + msg.attributes['ApproximateFirstReceiveTimestamp'] |