Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: third_party/boto/tests/unit/sqs/test_connection.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved 2 # Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved
3 # Copyright (c) 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved
3 # 4 #
4 # Permission is hereby granted, free of charge, to any person obtaining a 5 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the 6 # copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including 7 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish, dis- 8 # without limitation the rights to use, copy, modify, merge, publish, dis-
8 # tribute, sublicense, and/or sell copies of the Software, and to permit 9 # tribute, sublicense, and/or sell copies of the Software, and to permit
9 # persons to whom the Software is furnished to do so, subject to the fol- 10 # persons to whom the Software is furnished to do so, subject to the fol-
10 # lowing conditions: 11 # lowing conditions:
11 # 12 #
12 # The above copyright notice and this permission notice shall be included 13 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software. 14 # in all copies or substantial portions of the Software.
14 # 15 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 17 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 18 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 # IN THE SOFTWARE. 22 # IN THE SOFTWARE.
22 # 23 #
23 24
24 from tests.unit import unittest 25 from tests.unit import unittest
25 from tests.unit import AWSMockServiceTestCase 26 from tests.unit import AWSMockServiceTestCase
26 27
27 from boto.sqs.connection import SQSConnection 28 from boto.sqs.connection import SQSConnection
28 from boto.sqs.regioninfo import SQSRegionInfo 29 from boto.sqs.regioninfo import SQSRegionInfo
30 from boto.sqs.message import RawMessage
31 from boto.sqs.queue import Queue
29 32
30 33
31 class SQSAuthParams(AWSMockServiceTestCase): 34 class SQSAuthParams(AWSMockServiceTestCase):
32 connection_class = SQSConnection 35 connection_class = SQSConnection
33 36
34 def setUp(self): 37 def setUp(self):
35 super(SQSAuthParams, self).setUp() 38 super(SQSAuthParams, self).setUp()
36 39
37 def default_body(self): 40 def default_body(self):
38 return """<?xml version="1.0"?> 41 return """<?xml version="1.0"?>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 100
98 def test_get_queue_with_owner_account_id_returns_queue(self): 101 def test_get_queue_with_owner_account_id_returns_queue(self):
99 102
100 self.set_http_response(status_code=200) 103 self.set_http_response(status_code=200)
101 self.service_connection.create_queue('my_queue') 104 self.service_connection.create_queue('my_queue')
102 105
103 self.service_connection.get_queue('my_queue', '599169622985') 106 self.service_connection.get_queue('my_queue', '599169622985')
104 107
105 assert 'QueueOwnerAWSAccountId' in self.actual_request.params.keys() 108 assert 'QueueOwnerAWSAccountId' in self.actual_request.params.keys()
106 self.assertEquals(self.actual_request.params['QueueOwnerAWSAccountId'], '599169622985') 109 self.assertEquals(self.actual_request.params['QueueOwnerAWSAccountId'], '599169622985')
107 110
111
112 class SQSMessageAttributesParsing(AWSMockServiceTestCase):
113 connection_class = SQSConnection
114
115 def default_body(self):
116 return """<?xml version="1.0"?>
117 <ReceiveMessageResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/">
118 <ReceiveMessageResult>
119 <Message>
120 <Body>This is a test</Body>
121 <ReceiptHandle>+eXJYhj5rDql5hp2VwGkXvQVsefdjAlsQe5EGS57gyORPB48KwP1d /3Rfy4DrQXt+MgfRPHUCUH36xL9+Ol/UWD/ylKrrWhiXSY0Ip4EsI8jJNTo/aneEjKE/iZnz/nL8MFP5 FmMj8PbDAy5dgvAqsdvX1rm8Ynn0bGnQLJGfH93cLXT65p6Z/FDyjeBN0M+9SWtTcuxOIcMdU8NsoFIw m/6mLWgWAV46OhlYujzvyopCvVwsj+Y8jLEpdSSvTQHNlQEaaY/V511DqAvUwru2p0ZbW7ZzcbhUTn6h HkUROo=</ReceiptHandle>
122 <MD5OfBody>ce114e4501d2f4e2dcea3e17b546f339</MD5OfBody>
123 <MessageAttribute>
124 <Name>Count</Name>
125 <Value>
126 <DataType>Number</DataType>
127 <StringValue>1</StringValue>
128 </Value>
129 </MessageAttribute>
130 <MessageAttribute>
131 <Name>Foo</Name>
132 <Value>
133 <DataType>String</DataType>
134 <StringValue>Bar</StringValue>
135 </Value>
136 </MessageAttribute>
137 <MessageId>7049431b-e5f6-430b-93c4-ded53864d02b</MessageId>
138 <MD5OfMessageAttributes>324758f82d026ac6ec5b31a3b192d1e3</MD5OfMessa geAttributes>
139 </Message>
140 </ReceiveMessageResult>
141 <ResponseMetadata>
142 <RequestId>73f978f2-400b-5460-8d38-3316e39e79c6</RequestId>
143 </ResponseMetadata>
144 </ReceiveMessageResponse>"""
145
146 def test_message_attribute_response(self):
147 self.set_http_response(status_code=200)
148
149 queue = Queue(
150 url='http://sqs.us-east-1.amazonaws.com/123456789012/testQueue/',
151 message_class=RawMessage)
152 message = self.service_connection.receive_message(queue)[0]
153
154 self.assertEqual(message.get_body(), 'This is a test')
155 self.assertEqual(message.id, '7049431b-e5f6-430b-93c4-ded53864d02b')
156 self.assertEqual(message.md5, 'ce114e4501d2f4e2dcea3e17b546f339')
157 self.assertEqual(message.md5_message_attributes,
158 '324758f82d026ac6ec5b31a3b192d1e3')
159
160 mattributes = message.message_attributes
161 self.assertEqual(len(mattributes.keys()), 2)
162 self.assertEqual(mattributes['Count']['data_type'], 'Number')
163 self.assertEqual(mattributes['Foo']['string_value'], 'Bar')
164
165
166 class SQSSendMessageAttributes(AWSMockServiceTestCase):
167 connection_class = SQSConnection
168
169 def default_body(self):
170 return """<SendMessageResponse>
171 <SendMessageResult>
172 <MD5OfMessageBody>
173 fafb00f5732ab283681e124bf8747ed1
174 </MD5OfMessageBody>
175 <MD5OfMessageAttributes>
176 3ae8f24a165a8cedc005670c81a27295
177 </MD5OfMessageAttributes>
178 <MessageId>
179 5fea7756-0ea4-451a-a703-a558b933e274
180 </MessageId>
181 </SendMessageResult>
182 <ResponseMetadata>
183 <RequestId>
184 27daac76-34dd-47df-bd01-1f6e873584a0
185 </RequestId>
186 </ResponseMetadata>
187 </SendMessageResponse>
188 """
189
190 def test_send_message_attributes(self):
191 self.set_http_response(status_code=200)
192
193 queue = Queue(
194 url='http://sqs.us-east-1.amazonaws.com/123456789012/testQueue/',
195 message_class=RawMessage)
196 self.service_connection.send_message(queue, 'Test message',
197 message_attributes={
198 'name1': {
199 'data_type': 'String',
200 'string_value': 'Bob'
201 },
202 'name2': {
203 'data_type': 'Number',
204 'string_value': '1'
205 }
206 })
207
208 self.assert_request_parameters({
209 'Action': 'SendMessage',
210 'MessageAttribute.1.Name': 'name2',
211 'MessageAttribute.1.Value.DataType': 'Number',
212 'MessageAttribute.1.Value.StringValue': '1',
213 'MessageAttribute.2.Name': 'name1',
214 'MessageAttribute.2.Value.DataType': 'String',
215 'MessageAttribute.2.Value.StringValue': 'Bob',
216 'MessageBody': 'Test message',
217 'Version': '2012-11-05'
218 })
219
220
221 class SQSSendBatchMessageAttributes(AWSMockServiceTestCase):
222 connection_class = SQSConnection
223
224 def default_body(self):
225 return """<SendMessageBatchResponse>
226 <SendMessageBatchResult>
227 <SendMessageBatchResultEntry>
228 <Id>test_msg_001</Id>
229 <MessageId>0a5231c7-8bff-4955-be2e-8dc7c50a25fa</MessageId>
230 <MD5OfMessageBody>0e024d309850c78cba5eabbeff7cae71</MD5OfMessageBody>
231 </SendMessageBatchResultEntry>
232 <SendMessageBatchResultEntry>
233 <Id>test_msg_002</Id>
234 <MessageId>15ee1ed3-87e7-40c1-bdaa-2e49968ea7e9</MessageId>
235 <MD5OfMessageBody>7fb8146a82f95e0af155278f406862c2</MD5OfMessageBody>
236 <MD5OfMessageAttributes>295c5fa15a51aae6884d1d7c1d99ca50</MD5OfMessageAt tributes>
237 </SendMessageBatchResultEntry>
238 </SendMessageBatchResult>
239 <ResponseMetadata>
240 <RequestId>ca1ad5d0-8271-408b-8d0f-1351bf547e74</RequestId>
241 </ResponseMetadata>
242 </SendMessageBatchResponse>
243 """
244
245 def test_send_message_attributes(self):
246 self.set_http_response(status_code=200)
247
248 queue = Queue(
249 url='http://sqs.us-east-1.amazonaws.com/123456789012/testQueue/',
250 message_class=RawMessage)
251
252 message1 = (1, 'Message 1', 0, {'name1': {'data_type': 'String',
253 'string_value': 'foo'}})
254 message2 = (2, 'Message 2', 0, {'name2': {'data_type': 'Number',
255 'string_value': '1'}})
256
257 self.service_connection.send_message_batch(queue, (message1, message2))
258
259 self.assert_request_parameters({
260 'Action': 'SendMessageBatch',
261 'SendMessageBatchRequestEntry.1.DelaySeconds': 0,
262 'SendMessageBatchRequestEntry.1.Id': 1,
263 'SendMessageBatchRequestEntry.1.MessageAttribute.1.DataType': 'Strin g',
264 'SendMessageBatchRequestEntry.1.MessageAttribute.1.Name': 'name1',
265 'SendMessageBatchRequestEntry.1.MessageAttribute.1.StringValue': 'fo o',
266 'SendMessageBatchRequestEntry.1.MessageBody': 'Message 1',
267 'SendMessageBatchRequestEntry.2.DelaySeconds': 0,
268 'SendMessageBatchRequestEntry.2.Id': 2,
269 'SendMessageBatchRequestEntry.2.MessageAttribute.1.DataType': 'Numbe r',
270 'SendMessageBatchRequestEntry.2.MessageAttribute.1.Name': 'name2',
271 'SendMessageBatchRequestEntry.2.MessageAttribute.1.StringValue': '1' ,
272 'SendMessageBatchRequestEntry.2.MessageBody': 'Message 2',
273 'Version': '2012-11-05'
274 })
275
108 276
109 if __name__ == '__main__': 277 if __name__ == '__main__':
110 unittest.main() 278 unittest.main()
OLDNEW
« no previous file with comments | « third_party/boto/tests/unit/sns/test_connection.py ('k') | third_party/boto/tests/unit/sts/test_connection.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698