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

Side by Side Diff: third_party/boto/tests/unit/cloudsearch2/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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 #!/usr/bin env python
2
3 from tests.unit import AWSMockServiceTestCase
4
5 from boto.cloudsearch2.domain import Domain
6 from boto.cloudsearch2.layer1 import CloudSearchConnection
7
8
9 class TestCloudSearchCreateDomain(AWSMockServiceTestCase):
10 connection_class = CloudSearchConnection
11
12 def default_body(self):
13 return """
14 {
15 "CreateDomainResponse": {
16 "CreateDomainResult": {
17 "DomainStatus": {
18 "SearchInstanceType": null,
19 "DomainId": "1234567890/demo",
20 "DomainName": "demo",
21 "Deleted": false,
22 "SearchInstanceCount": 0,
23 "Created": true,
24 "SearchService": {
25 "Endpoint": "search-demo.us-east-1.cloudsearch.amazonaws.com"
26 },
27 "RequiresIndexDocuments": false,
28 "Processing": false,
29 "DocService": {
30 "Endpoint": "doc-demo.us-east-1.cloudsearch.amazonaws.com"
31 },
32 "ARN": "arn:aws:cs:us-east-1:1234567890:domain/demo",
33 "SearchPartitionCount": 0
34 }
35 },
36 "ResponseMetadata": {
37 "RequestId": "00000000-0000-0000-0000-000000000000"
38 }
39 }
40 }
41 """
42
43 def test_create_domain(self):
44 self.set_http_response(status_code=200)
45 self.service_connection.create_domain('demo')
46
47 self.assert_request_parameters({
48 'Action': 'CreateDomain',
49 'ContentType': 'JSON',
50 'DomainName': 'demo',
51 'Version': '2013-01-01',
52 })
53
54 def test_cloudsearch_connect_result_endpoints(self):
55 """Check that endpoints & ARNs are correctly returned from AWS"""
56
57 self.set_http_response(status_code=200)
58 api_response = self.service_connection.create_domain('demo')
59 domain = Domain(self, api_response['CreateDomainResponse']
60 ['CreateDomainResult']
61 ['DomainStatus'])
62
63 self.assertEqual(
64 domain.doc_service_endpoint,
65 "doc-demo.us-east-1.cloudsearch.amazonaws.com")
66 self.assertEqual(domain.service_arn,
67 "arn:aws:cs:us-east-1:1234567890:domain/demo")
68 self.assertEqual(
69 domain.search_service_endpoint,
70 "search-demo.us-east-1.cloudsearch.amazonaws.com")
71
72 def test_cloudsearch_connect_result_statuses(self):
73 """Check that domain statuses are correctly returned from AWS"""
74 self.set_http_response(status_code=200)
75 api_response = self.service_connection.create_domain('demo')
76 domain = Domain(self, api_response['CreateDomainResponse']
77 ['CreateDomainResult']
78 ['DomainStatus'])
79
80 self.assertEqual(domain.created, True)
81 self.assertEqual(domain.processing, False)
82 self.assertEqual(domain.requires_index_documents, False)
83 self.assertEqual(domain.deleted, False)
84
85 def test_cloudsearch_connect_result_details(self):
86 """Check that the domain information is correctly returned from AWS"""
87 self.set_http_response(status_code=200)
88 api_response = self.service_connection.create_domain('demo')
89 domain = Domain(self, api_response['CreateDomainResponse']
90 ['CreateDomainResult']
91 ['DomainStatus'])
92
93 self.assertEqual(domain.id, "1234567890/demo")
94 self.assertEqual(domain.name, "demo")
95
96 def test_cloudsearch_documentservice_creation(self):
97 self.set_http_response(status_code=200)
98 api_response = self.service_connection.create_domain('demo')
99 domain = Domain(self, api_response['CreateDomainResponse']
100 ['CreateDomainResult']
101 ['DomainStatus'])
102
103 document = domain.get_document_service()
104
105 self.assertEqual(
106 document.endpoint,
107 "doc-demo.us-east-1.cloudsearch.amazonaws.com")
108
109 def test_cloudsearch_searchservice_creation(self):
110 self.set_http_response(status_code=200)
111 api_response = self.service_connection.create_domain('demo')
112 domain = Domain(self, api_response['CreateDomainResponse']
113 ['CreateDomainResult']
114 ['DomainStatus'])
115
116 search = domain.get_search_service()
117
118 self.assertEqual(
119 search.endpoint,
120 "search-demo.us-east-1.cloudsearch.amazonaws.com")
121
122
123 class CloudSearchConnectionDeletionTest(AWSMockServiceTestCase):
124 connection_class = CloudSearchConnection
125
126 def default_body(self):
127 return """
128 {
129 "DeleteDomainResponse": {
130 "DeleteDomainResult": {
131 "DomainStatus": {
132 "SearchInstanceType": null,
133 "DomainId": "1234567890/demo",
134 "DomainName": "test",
135 "Deleted": true,
136 "SearchInstanceCount": 0,
137 "Created": true,
138 "SearchService": {
139 "Endpoint": null
140 },
141 "RequiresIndexDocuments": false,
142 "Processing": false,
143 "DocService": {
144 "Endpoint": null
145 },
146 "ARN": "arn:aws:cs:us-east-1:1234567890:domain/demo",
147 "SearchPartitionCount": 0
148 }
149 },
150 "ResponseMetadata": {
151 "RequestId": "00000000-0000-0000-0000-000000000000"
152 }
153 }
154 }
155 """
156
157 def test_cloudsearch_deletion(self):
158 """
159 Check that the correct arguments are sent to AWS when creating a
160 cloudsearch connection.
161 """
162 self.set_http_response(status_code=200)
163 self.service_connection.delete_domain('demo')
164
165 self.assert_request_parameters({
166 'Action': 'DeleteDomain',
167 'ContentType': 'JSON',
168 'DomainName': 'demo',
169 'Version': '2013-01-01',
170 })
171
172
173 class CloudSearchConnectionIndexDocumentTest(AWSMockServiceTestCase):
174 connection_class = CloudSearchConnection
175
176 def default_body(self):
177 return """
178 {
179 "IndexDocumentsResponse": {
180 "IndexDocumentsResult": {
181 "FieldNames": [
182 "average_score",
183 "brand_id",
184 "colors",
185 "context",
186 "context_owner",
187 "created_at",
188 "creator_id",
189 "description",
190 "file_size",
191 "format",
192 "has_logo",
193 "has_messaging",
194 "height",
195 "image_id",
196 "ingested_from",
197 "is_advertising",
198 "is_photo",
199 "is_reviewed",
200 "modified_at",
201 "subject_date",
202 "tags",
203 "title",
204 "width"
205 ]
206 },
207 "ResponseMetadata": {
208 "RequestId": "42e618d9-c4d9-11e3-8242-c32da3041159"
209 }
210 }
211 }
212 """
213
214 def test_cloudsearch_index_documents(self):
215 """
216 Check that the correct arguments are sent to AWS when indexing a
217 domain.
218 """
219 self.set_http_response(status_code=200)
220 self.service_connection.index_documents('demo')
221
222 self.assert_request_parameters({
223 'Action': 'IndexDocuments',
224 'ContentType': 'JSON',
225 'DomainName': 'demo',
226 'Version': '2013-01-01',
227 })
228
229 def test_cloudsearch_index_documents_resp(self):
230 """
231 Check that the AWS response is being parsed correctly when indexing a
232 domain.
233 """
234 self.set_http_response(status_code=200)
235 api_response = self.service_connection.index_documents('demo')
236
237 fields = (api_response['IndexDocumentsResponse']
238 ['IndexDocumentsResult']
239 ['FieldNames'])
240
241 self.assertEqual(fields, ['average_score', 'brand_id', 'colors',
242 'context', 'context_owner',
243 'created_at', 'creator_id',
244 'description', 'file_size', 'format',
245 'has_logo', 'has_messaging', 'height',
246 'image_id', 'ingested_from',
247 'is_advertising', 'is_photo',
248 'is_reviewed', 'modified_at',
249 'subject_date', 'tags', 'title',
250 'width'])
OLDNEW
« no previous file with comments | « third_party/boto/tests/unit/cloudsearch2/__init__.py ('k') | third_party/boto/tests/unit/cloudsearch2/test_document.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698