How to use _check_copied_obj method in tempest

Best Python code snippet using tempest_python

test_object_services.py

Source:test_object_services.py Github

copy

Full Screen

...61 src_object_name,62 dst_object_name,63 metadata=metadata)64 return dst_object_name, resp65 def _check_copied_obj(self, dst_object_name, src_body,66 in_meta=None, not_in_meta=None):67 resp, dest_body = self.object_client.get_object(self.container_name,68 dst_object_name)69 self.assertEqual(src_body, dest_body)70 if in_meta:71 for meta_key in in_meta:72 self.assertIn('x-object-meta-' + meta_key, resp)73 if not_in_meta:74 for meta_key in not_in_meta:75 self.assertNotIn('x-object-meta-' + meta_key, resp)76 @test.attr(type='smoke')77 @test.idempotent_id('5b4ce26f-3545-46c9-a2ba-5754358a4c62')78 def test_create_object(self):79 # create object80 object_name = data_utils.rand_name(name='TestObject')81 data = data_utils.arbitrary_string()82 resp, _ = self.object_client.create_object(self.container_name,83 object_name, data)84 # create another object85 object_name = data_utils.rand_name(name='TestObject')86 data = data_utils.arbitrary_string()87 resp, _ = self.object_client.create_object(self.container_name,88 object_name, data)89 self.assertHeaders(resp, 'Object', 'PUT')90 # check uploaded content91 _, body = self.object_client.get_object(self.container_name,92 object_name)93 self.assertEqual(data, body)94 @test.idempotent_id('5daebb1d-f0d5-4dc9-b541-69672eff00b0')95 def test_create_object_with_content_disposition(self):96 # create object with content_disposition97 object_name = data_utils.rand_name(name='TestObject')98 data = data_utils.arbitrary_string()99 metadata = {}100 metadata['content-disposition'] = 'inline'101 resp, _ = self.object_client.create_object(102 self.container_name,103 object_name,104 data,105 metadata=metadata)106 self.assertHeaders(resp, 'Object', 'PUT')107 resp, body = self.object_client.get_object(108 self.container_name,109 object_name,110 metadata=None)111 self.assertIn('content-disposition', resp)112 self.assertEqual(resp['content-disposition'], 'inline')113 self.assertEqual(body, data)114 @test.idempotent_id('605f8317-f945-4bee-ae91-013f1da8f0a0')115 def test_create_object_with_content_encoding(self):116 # create object with content_encoding117 object_name = data_utils.rand_name(name='TestObject')118 # put compressed string119 data_before = 'x' * 2000120 data = zlib.compress(data_before)121 metadata = {}122 metadata['content-encoding'] = 'deflate'123 resp, _ = self.object_client.create_object(124 self.container_name,125 object_name,126 data,127 metadata=metadata)128 self.assertHeaders(resp, 'Object', 'PUT')129 # download compressed object130 metadata = {}131 metadata['accept-encoding'] = 'deflate'132 resp, body = self.object_client.get_object(133 self.container_name,134 object_name,135 metadata=metadata)136 self.assertEqual(body, data_before)137 @test.idempotent_id('73820093-0503-40b1-a478-edf0e69c7d1f')138 def test_create_object_with_etag(self):139 # create object with etag140 object_name = data_utils.rand_name(name='TestObject')141 data = data_utils.arbitrary_string()142 md5 = hashlib.md5(data).hexdigest()143 metadata = {'Etag': md5}144 resp, _ = self.object_client.create_object(145 self.container_name,146 object_name,147 data,148 metadata=metadata)149 self.assertHeaders(resp, 'Object', 'PUT')150 # check uploaded content151 _, body = self.object_client.get_object(self.container_name,152 object_name)153 self.assertEqual(data, body)154 @test.idempotent_id('84dafe57-9666-4f6d-84c8-0814d37923b8')155 def test_create_object_with_expect_continue(self):156 # create object with expect_continue157 object_name = data_utils.rand_name(name='TestObject')158 data = data_utils.arbitrary_string()159 metadata = {'Expect': '100-continue'}160 resp = self.object_client.create_object_continue(161 self.container_name,162 object_name,163 data,164 metadata=metadata)165 self.assertIn('status', resp)166 self.assertEqual(resp['status'], '100')167 self.object_client.create_object_continue(168 self.container_name,169 object_name,170 data,171 metadata=None)172 # check uploaded content173 _, body = self.object_client.get_object(self.container_name,174 object_name)175 self.assertEqual(data, body)176 @decorators.skip_because(bug="1417492")177 @test.attr(type='gate')178 @test.idempotent_id('4f84422a-e2f2-4403-b601-726a4220b54e')179 def test_create_object_with_transfer_encoding(self):180 # create object with transfer_encoding181 object_name = data_utils.rand_name(name='TestObject')182 data = data_utils.arbitrary_string(1024)183 status, _, resp_headers = self.object_client.put_object_with_chunk(184 container=self.container_name,185 name=object_name,186 contents=moves.cStringIO(data),187 chunk_size=512)188 self.assertHeaders(resp_headers, 'Object', 'PUT')189 # check uploaded content190 _, body = self.object_client.get_object(self.container_name,191 object_name)192 self.assertEqual(data, body)193 @test.idempotent_id('0f3d62a6-47e3-4554-b0e5-1a5dc372d501')194 def test_create_object_with_x_fresh_metadata(self):195 # create object with x_fresh_metadata196 object_name_base = data_utils.rand_name(name='TestObject')197 data = data_utils.arbitrary_string()198 metadata_1 = {'X-Object-Meta-test-meta': 'Meta'}199 self.object_client.create_object(self.container_name,200 object_name_base,201 data,202 metadata=metadata_1)203 object_name = data_utils.rand_name(name='TestObject')204 metadata_2 = {'X-Copy-From': '%s/%s' % (self.container_name,205 object_name_base),206 'X-Fresh-Metadata': 'true'}207 resp, _ = self.object_client.create_object(208 self.container_name,209 object_name,210 '',211 metadata=metadata_2)212 self.assertHeaders(resp, 'Object', 'PUT')213 resp, body = self.object_client.get_object(self.container_name,214 object_name)215 #Bug = 1417489216 #self.assertNotIn('x-object-meta-test-meta', resp)217 self.assertEqual(data, body)218 @test.idempotent_id('1c7ed3e4-2099-406b-b843-5301d4811baf')219 def test_create_object_with_x_object_meta(self):220 # create object with object_meta221 object_name = data_utils.rand_name(name='TestObject')222 data = data_utils.arbitrary_string()223 metadata = {'X-Object-Meta-test-meta': 'Meta'}224 resp, _ = self.object_client.create_object(225 self.container_name,226 object_name,227 data,228 metadata=metadata)229 self.assertHeaders(resp, 'Object', 'PUT')230 resp, body = self.object_client.get_object(self.container_name,231 object_name)232 self.assertIn('x-object-meta-test-meta', resp)233 self.assertEqual(resp['x-object-meta-test-meta'], 'Meta')234 self.assertEqual(data, body)235 @test.idempotent_id('e4183917-33db-4153-85cc-4dacbb938865')236 def test_create_object_with_x_object_metakey(self):237 # create object with the blank value of metadata238 object_name = data_utils.rand_name(name='TestObject')239 data = data_utils.arbitrary_string()240 metadata = {'X-Object-Meta-test-meta': ''}241 resp, _ = self.object_client.create_object(242 self.container_name,243 object_name,244 data,245 metadata=metadata)246 self.assertHeaders(resp, 'Object', 'PUT')247 resp, body = self.object_client.get_object(self.container_name,248 object_name)249 self.assertIn('x-object-meta-test-meta', resp)250 self.assertEqual(resp['x-object-meta-test-meta'], '')251 self.assertEqual(data, body)252 @test.idempotent_id('ce798afc-b278-45de-a5ce-2ea124b98b99')253 def test_create_object_with_x_remove_object_meta(self):254 # create object with x_remove_object_meta255 object_name = data_utils.rand_name(name='TestObject')256 data = data_utils.arbitrary_string()257 metadata_add = {'X-Object-Meta-test-meta': 'Meta'}258 self.object_client.create_object(self.container_name,259 object_name,260 data,261 metadata=metadata_add)262 metadata_remove = {'X-Remove-Object-Meta-test-meta': 'Meta'}263 resp, _ = self.object_client.create_object(264 self.container_name,265 object_name,266 data,267 metadata=metadata_remove)268 self.assertHeaders(resp, 'Object', 'PUT')269 resp, body = self.object_client.get_object(self.container_name,270 object_name)271 self.assertNotIn('x-object-meta-test-meta', resp)272 self.assertEqual(data, body)273 @test.idempotent_id('ad21e342-7916-4f9e-ab62-a1f885f2aaf9')274 def test_create_object_with_x_remove_object_metakey(self):275 # create object with the blank value of remove metadata276 object_name = data_utils.rand_name(name='TestObject')277 data = data_utils.arbitrary_string()278 metadata_add = {'X-Object-Meta-test-meta': 'Meta'}279 self.object_client.create_object(self.container_name,280 object_name,281 data,282 metadata=metadata_add)283 metadata_remove = {'X-Remove-Object-Meta-test-meta': ''}284 resp, _ = self.object_client.create_object(285 self.container_name,286 object_name,287 data,288 metadata=metadata_remove)289 self.assertHeaders(resp, 'Object', 'PUT')290 resp, body = self.object_client.get_object(self.container_name,291 object_name)292 self.assertNotIn('x-object-meta-test-meta', resp)293 self.assertEqual(data, body)294 @test.idempotent_id('17738d45-03bd-4d45-9e0b-7b2f58f98687')295 def test_delete_object(self):296 # create object297 object_name = data_utils.rand_name(name='TestObject')298 data = data_utils.arbitrary_string()299 resp, _ = self.object_client.create_object(self.container_name,300 object_name, data)301 # delete object302 resp, _ = self.object_client.delete_object(self.container_name,303 object_name)304 self.assertHeaders(resp, 'Object', 'DELETE')305 @test.attr(type='smoke')306 @test.idempotent_id('7a94c25d-66e6-434c-9c38-97d4e2c29945')307 def test_update_object_metadata(self):308 # update object metadata309 object_name, data = self._create_object()310 metadata = {'X-Object-Meta-test-meta': 'Meta'}311 resp, _ = self.object_client.update_object_metadata(312 self.container_name,313 object_name,314 metadata,315 metadata_prefix='')316 self.assertHeaders(resp, 'Object', 'POST')317 resp, _ = self.object_client.list_object_metadata(318 self.container_name,319 object_name)320 self.assertIn('x-object-meta-test-meta', resp)321 self.assertEqual(resp['x-object-meta-test-meta'], 'Meta')322 @test.idempotent_id('48650ed0-c189-4e1e-ad6b-1d4770c6e134')323 def test_update_object_metadata_with_remove_metadata(self):324 # update object metadata with remove metadata325 object_name = data_utils.rand_name(name='TestObject')326 data = data_utils.arbitrary_string()327 create_metadata = {'X-Object-Meta-test-meta1': 'Meta1'}328 self.object_client.create_object(self.container_name,329 object_name,330 data,331 metadata=create_metadata)332 update_metadata = {'X-Remove-Object-Meta-test-meta1': 'Meta1'}333 resp, _ = self.object_client.update_object_metadata(334 self.container_name,335 object_name,336 update_metadata,337 metadata_prefix='')338 self.assertHeaders(resp, 'Object', 'POST')339 resp, _ = self.object_client.list_object_metadata(340 self.container_name,341 object_name)342 self.assertNotIn('x-object-meta-test-meta1', resp)343 @test.idempotent_id('f726174b-2ded-4708-bff7-729d12ce1f84')344 def test_update_object_metadata_with_create_and_remove_metadata(self):345 # creation and deletion of metadata with one request346 object_name = data_utils.rand_name(name='TestObject')347 data = data_utils.arbitrary_string()348 create_metadata = {'X-Object-Meta-test-meta1': 'Meta1'}349 self.object_client.create_object(self.container_name,350 object_name,351 data,352 metadata=create_metadata)353 update_metadata = {'X-Object-Meta-test-meta2': 'Meta2',354 'X-Remove-Object-Meta-test-meta1': 'Meta1'}355 resp, _ = self.object_client.update_object_metadata(356 self.container_name,357 object_name,358 update_metadata,359 metadata_prefix='')360 self.assertHeaders(resp, 'Object', 'POST')361 resp, _ = self.object_client.list_object_metadata(362 self.container_name,363 object_name)364 self.assertNotIn('x-object-meta-test-meta1', resp)365 self.assertIn('x-object-meta-test-meta2', resp)366 self.assertEqual(resp['x-object-meta-test-meta2'], 'Meta2')367 @test.idempotent_id('08854588-6449-4bb7-8cca-f2e1040f5e6f')368 def test_update_object_metadata_with_x_object_manifest(self):369 # update object metadata with x_object_manifest370 # uploading segments371 object_name, data_segments = self._upload_segments()372 # creating a manifest file373 data_empty = ''374 object_prefix = '%s/%s' % (self.container_name, object_name)375 metadata = {'X-Object-Manifest': object_prefix}376 resp, _ = self.object_client.create_object(self.container_name,377 object_name,378 data_empty,379 metadata=metadata)380 self.assertHeaders(resp, 'Object', 'PUT')381 #Bug = 1417462382 #update_metadata = {'X-Object-Manifest': object_prefix}383 #resp, _ = self.object_client.update_object_metadata(384 # self.container_name,385 # object_name,386 # update_metadata,387 # metadata_prefix='')388 #self.assertHeaders(resp, 'Object', 'POST')389 resp, _ = self.object_client.list_object_metadata(390 self.container_name,391 object_name)392 self.assertIn('x-object-manifest', resp)393 self.assertNotEqual(len(resp['x-object-manifest']), 0)394 @test.idempotent_id('0dbbe89c-6811-4d84-a2df-eca2bdd40c0e')395 def test_update_object_metadata_with_x_object_metakey(self):396 # update object metadata with a blenk value of metadata397 object_name, data = self._create_object()398 update_metadata = {'X-Object-Meta-test-meta': ''}399 resp, _ = self.object_client.update_object_metadata(400 self.container_name,401 object_name,402 update_metadata,403 metadata_prefix='')404 self.assertHeaders(resp, 'Object', 'POST')405 resp, _ = self.object_client.list_object_metadata(406 self.container_name,407 object_name)408 self.assertIn('x-object-meta-test-meta', resp)409 self.assertEqual(resp['x-object-meta-test-meta'], '')410 @test.idempotent_id('9a88dca4-b684-425b-806f-306cd0e57e42')411 def test_update_object_metadata_with_x_remove_object_metakey(self):412 # update object metadata with a blank value of remove metadata413 object_name = data_utils.rand_name(name='TestObject')414 data = data_utils.arbitrary_string()415 create_metadata = {'X-Object-Meta-test-meta': 'Meta'}416 self.object_client.create_object(self.container_name,417 object_name,418 data,419 metadata=create_metadata)420 update_metadata = {'X-Remove-Object-Meta-test-meta': ''}421 resp, _ = self.object_client.update_object_metadata(422 self.container_name,423 object_name,424 update_metadata,425 metadata_prefix='')426 self.assertHeaders(resp, 'Object', 'POST')427 resp, _ = self.object_client.list_object_metadata(428 self.container_name,429 object_name)430 self.assertNotIn('x-object-meta-test-meta', resp)431 @test.attr(type='smoke')432 @test.idempotent_id('9a447cf6-de06-48de-8226-a8c6ed31caf2')433 def test_list_object_metadata(self):434 # get object metadata435 object_name = data_utils.rand_name(name='TestObject')436 data = data_utils.arbitrary_string()437 metadata = {'X-Object-Meta-test-meta': 'Meta'}438 self.object_client.create_object(self.container_name,439 object_name,440 data,441 metadata=metadata)442 resp, _ = self.object_client.list_object_metadata(443 self.container_name,444 object_name)445 self.assertHeaders(resp, 'Object', 'HEAD')446 self.assertIn('x-object-meta-test-meta', resp)447 self.assertEqual(resp['x-object-meta-test-meta'], 'Meta')448 @test.idempotent_id('170fb90e-f5c3-4b1f-ae1b-a18810821172')449 def test_list_no_object_metadata(self):450 # get empty list of object metadata451 object_name, data = self._create_object()452 resp, _ = self.object_client.list_object_metadata(453 self.container_name,454 object_name)455 self.assertHeaders(resp, 'Object', 'HEAD')456 self.assertNotIn('x-object-meta-', str(resp))457 @test.idempotent_id('23a3674c-d6de-46c3-86af-ff92bfc8a3da')458 def test_list_object_metadata_with_x_object_manifest(self):459 # get object metadata with x_object_manifest460 # uploading segments461 object_name, data_segments = self._upload_segments()462 # creating a manifest file463 object_prefix = '%s/%s' % (self.container_name, object_name)464 metadata = {'X-Object-Manifest': object_prefix}465 data_empty = ''466 resp, _ = self.object_client.create_object(467 self.container_name,468 object_name,469 data_empty,470 metadata=metadata)471 resp, _ = self.object_client.list_object_metadata(472 self.container_name,473 object_name)474 # Check only the existence of common headers with custom matcher475 self.assertThat(resp, custom_matchers.ExistsAllResponseHeaders(476 'Object', 'HEAD'))477 self.assertIn('x-object-manifest', resp)478 # Etag value of a large object is enclosed in double-quotations.479 # This is a special case, therefore the formats of response headers480 # are checked without a custom matcher.481 #Bug = 1417462482 #self.assertTrue(resp['etag'].startswith('\"'))483 #self.assertTrue(resp['etag'].endswith('\"'))484 #self.assertTrue(resp['etag'].strip('\"').isalnum())485 self.assertTrue(resp['etag'].isalnum())486 #self.assertTrue(re.match("^\d+\.?\d*\Z", resp['x-timestamp']))487 self.assertNotEqual(len(resp['content-type']), 0)488 #self.assertTrue(re.match("^tx[0-9a-f]*-[0-9a-f]*$",489 # resp['x-trans-id']))490 self.assertNotEqual(len(resp['date']), 0)491 self.assertEqual(resp['accept-ranges'], 'bytes')492 self.assertEqual(resp['x-object-manifest'],493 '%s/%s' % (self.container_name, object_name))494 @test.attr(type='smoke')495 @test.idempotent_id('02610ba7-86b7-4272-9ed8-aa8d417cb3cd')496 def test_get_object(self):497 # retrieve object's data (in response body)498 # create object499 object_name, data = self._create_object()500 # get object501 resp, body = self.object_client.get_object(self.container_name,502 object_name)503 self.assertHeaders(resp, 'Object', 'GET')504 self.assertEqual(body, data)505 @test.idempotent_id('005f9bf6-e06d-41ec-968e-96c78e0b1d82')506 def test_get_object_with_metadata(self):507 # get object with metadata508 object_name = data_utils.rand_name(name='TestObject')509 data = data_utils.arbitrary_string()510 metadata = {'X-Object-Meta-test-meta': 'Meta'}511 self.object_client.create_object(self.container_name,512 object_name,513 data,514 metadata=metadata)515 resp, body = self.object_client.get_object(516 self.container_name,517 object_name,518 metadata=None)519 self.assertHeaders(resp, 'Object', 'GET')520 self.assertIn('x-object-meta-test-meta', resp)521 self.assertEqual(resp['x-object-meta-test-meta'], 'Meta')522 self.assertEqual(body, data)523 @test.idempotent_id('05a1890e-7db9-4a6c-90a8-ce998a2bddfa')524 def test_get_object_with_range(self):525 # get object with range526 object_name = data_utils.rand_name(name='TestObject')527 data = data_utils.arbitrary_string(100)528 self.object_client.create_object(self.container_name,529 object_name,530 data,531 metadata=None)532 rand_num = random.randint(3, len(data) - 1)533 metadata = {'Range': 'bytes=%s-%s' % (rand_num - 3, rand_num - 1)}534 resp, body = self.object_client.get_object(535 self.container_name,536 object_name,537 metadata=metadata)538 self.assertHeaders(resp, 'Object', 'GET')539 self.assertEqual(body, data[rand_num - 3: rand_num])540 @test.idempotent_id('11b4515b-7ba7-4ca8-8838-357ded86fc10')541 def test_get_object_with_x_object_manifest(self):542 # get object with x_object_manifest543 # uploading segments544 object_name, data_segments = self._upload_segments()545 # creating a manifest file546 object_prefix = '%s/%s' % (self.container_name, object_name)547 metadata = {'X-Object-Manifest': object_prefix}548 data_empty = ''549 resp, body = self.object_client.create_object(550 self.container_name,551 object_name,552 data_empty,553 metadata=metadata)554 resp, body = self.object_client.get_object(555 self.container_name,556 object_name,557 metadata=None)558 # Check only the existence of common headers with custom matcher559 self.assertThat(resp, custom_matchers.ExistsAllResponseHeaders(560 'Object', 'GET'))561 self.assertIn('x-object-manifest', resp)562 # Etag value of a large object is enclosed in double-quotations.563 # This is a special case, therefore the formats of response headers564 # are checked without a custom matcher.565 #Bug = 1417462566 #self.assertTrue(resp['etag'].startswith('\"'))567 #self.assertTrue(resp['etag'].endswith('\"'))568 self.assertTrue(resp['etag'].isalnum())569 #self.assertTrue(re.match("^\d+\.?\d*\Z", resp['x-timestamp']))570 self.assertNotEqual(len(resp['content-type']), 0)571 #self.assertTrue(re.match("^tx[0-9a-f]*-[0-9a-f]*$",572 # resp['x-trans-id']))573 self.assertNotEqual(len(resp['date']), 0)574 self.assertEqual(resp['accept-ranges'], 'bytes')575 self.assertEqual(resp['x-object-manifest'],576 '%s/%s' % (self.container_name, object_name))577 self.assertEqual(''.join(data_segments), body)578 @test.idempotent_id('c05b4013-e4de-47af-be84-e598062b16fc')579 def test_get_object_with_if_match(self):580 # get object with if_match581 object_name = data_utils.rand_name(name='TestObject')582 data = data_utils.arbitrary_string(10)583 create_md5 = hashlib.md5(data).hexdigest()584 create_metadata = {'Etag': create_md5}585 self.object_client.create_object(self.container_name,586 object_name,587 data,588 metadata=create_metadata)589 list_metadata = {'If-Match': create_md5}590 resp, body = self.object_client.get_object(591 self.container_name,592 object_name,593 metadata=list_metadata)594 self.assertHeaders(resp, 'Object', 'GET')595 self.assertEqual(body, data)596 @test.idempotent_id('be133639-e5d2-4313-9b1f-2d59fc054a16')597 def test_get_object_with_if_modified_since(self):598 # get object with if_modified_since599 object_name = data_utils.rand_name(name='TestObject')600 data = data_utils.arbitrary_string()601 time_now = time.time()602 self.object_client.create_object(self.container_name,603 object_name,604 data,605 metadata=None)606 http_date = time.ctime(time_now - 86400)607 list_metadata = {'If-Modified-Since': http_date}608 resp, body = self.object_client.get_object(609 self.container_name,610 object_name,611 metadata=list_metadata)612 self.assertHeaders(resp, 'Object', 'GET')613 self.assertEqual(body, data)614 @test.idempotent_id('641500d5-1612-4042-a04d-01fc4528bc30')615 def test_get_object_with_if_none_match(self):616 # get object with if_none_match617 object_name = data_utils.rand_name(name='TestObject')618 data = data_utils.arbitrary_string(10)619 create_md5 = hashlib.md5(data).hexdigest()620 create_metadata = {'Etag': create_md5}621 self.object_client.create_object(self.container_name,622 object_name,623 data,624 metadata=create_metadata)625 list_data = data_utils.arbitrary_string(15)626 list_md5 = hashlib.md5(list_data).hexdigest()627 list_metadata = {'If-None-Match': list_md5}628 resp, body = self.object_client.get_object(629 self.container_name,630 object_name,631 metadata=list_metadata)632 self.assertHeaders(resp, 'Object', 'GET')633 self.assertEqual(body, data)634 @test.idempotent_id('0aa1201c-10aa-467a-bee7-63cbdd463152')635 def test_get_object_with_if_unmodified_since(self):636 # get object with if_unmodified_since637 object_name, data = self._create_object()638 time_now = time.time()639 http_date = time.ctime(time_now + 86400)640 list_metadata = {'If-Unmodified-Since': http_date}641 resp, body = self.object_client.get_object(642 self.container_name,643 object_name,644 metadata=list_metadata)645 self.assertHeaders(resp, 'Object', 'GET')646 self.assertEqual(body, data)647 @test.idempotent_id('94587078-475f-48f9-a40f-389c246e31cd')648 def test_get_object_with_x_newest(self):649 # get object with x_newest650 object_name, data = self._create_object()651 list_metadata = {'X-Newest': 'true'}652 resp, body = self.object_client.get_object(653 self.container_name,654 object_name,655 metadata=list_metadata)656 self.assertHeaders(resp, 'Object', 'GET')657 self.assertEqual(body, data)658 @test.idempotent_id('1a9ab572-1b66-4981-8c21-416e2a5e6011')659 def test_copy_object_in_same_container(self):660 # create source object661 src_object_name = data_utils.rand_name(name='SrcObject')662 src_data = data_utils.arbitrary_string(size=len(src_object_name) * 2,663 base_text=src_object_name)664 resp, _ = self.object_client.create_object(self.container_name,665 src_object_name,666 src_data)667 # create destination object668 dst_object_name = data_utils.rand_name(name='DstObject')669 dst_data = data_utils.arbitrary_string(size=len(dst_object_name) * 3,670 base_text=dst_object_name)671 resp, _ = self.object_client.create_object(self.container_name,672 dst_object_name,673 dst_data)674 # copy source object to destination675 resp, _ = self.object_client.copy_object_in_same_container(676 self.container_name, src_object_name, dst_object_name)677 self.assertHeaders(resp, 'Object', 'PUT')678 # check data679 resp, body = self.object_client.get_object(self.container_name,680 dst_object_name)681 self.assertEqual(body, src_data)682 @test.idempotent_id('2248abba-415d-410b-9c30-22dff9cd6e67')683 def test_copy_object_to_itself(self):684 # change the content type of an existing object685 # create object686 object_name, data = self._create_object()687 # get the old content type688 resp_tmp, _ = self.object_client.list_object_metadata(689 self.container_name, object_name)690 # change the content type of the object691 metadata = {'content-type': 'text/plain; charset=UTF-8'}692 self.assertNotEqual(resp_tmp['content-type'], metadata['content-type'])693 resp, _ = self.object_client.copy_object_in_same_container(694 self.container_name, object_name, object_name, metadata)695 self.assertHeaders(resp, 'Object', 'PUT')696 #Bug = 1417458697 # check the content type698 #resp, _ = self.object_client.list_object_metadata(self.container_name,699 # object_name)700 #self.assertEqual(resp['content-type'], metadata['content-type'])701 @test.idempotent_id('06f90388-2d0e-40aa-934c-e9a8833e958a')702 def test_copy_object_2d_way(self):703 # create source object704 src_object_name = data_utils.rand_name(name='SrcObject')705 src_data = data_utils.arbitrary_string(size=len(src_object_name) * 2,706 base_text=src_object_name)707 resp, _ = self.object_client.create_object(self.container_name,708 src_object_name, src_data)709 # create destination object710 dst_object_name = data_utils.rand_name(name='DstObject')711 dst_data = data_utils.arbitrary_string(size=len(dst_object_name) * 3,712 base_text=dst_object_name)713 resp, _ = self.object_client.create_object(self.container_name,714 dst_object_name, dst_data)715 # copy source object to destination716 resp, _ = self.object_client.copy_object_2d_way(self.container_name,717 src_object_name,718 dst_object_name)719 self.assertHeaders(resp, 'Object', 'COPY')720 #Bug 1417469721 #self.assertEqual(722 # resp['x-copied-from'],723 # self.container_name + "/" + src_object_name)724 # check data725 self._check_copied_obj(dst_object_name, src_data)726 @test.idempotent_id('aa467252-44f3-472a-b5ae-5b57c3c9c147')727 def test_copy_object_across_containers(self):728 # create a container to use as asource container729 src_container_name = data_utils.rand_name(name='TestSourceContainer')730 self.container_client.create_container(src_container_name)731 self.containers.append(src_container_name)732 # create a container to use as a destination container733 dst_container_name = data_utils.rand_name(734 name='TestDestinationContainer')735 self.container_client.create_container(dst_container_name)736 self.containers.append(dst_container_name)737 # create object in source container738 object_name = data_utils.rand_name(name='Object')739 data = data_utils.arbitrary_string(size=len(object_name) * 2,740 base_text=object_name)741 resp, _ = self.object_client.create_object(src_container_name,742 object_name, data)743 # set object metadata744 meta_key = data_utils.rand_name(name='test')745 meta_value = data_utils.rand_name(name='MetaValue')746 orig_metadata = {meta_key: meta_value}747 resp, _ = self.object_client.update_object_metadata(src_container_name,748 object_name,749 orig_metadata)750 self.assertHeaders(resp, 'Object', 'POST')751 # copy object from source container to destination container752 resp, _ = self.object_client.copy_object_across_containers(753 src_container_name, object_name, dst_container_name,754 object_name)755 self.assertHeaders(resp, 'Object', 'PUT')756 # check if object is present in destination container757 resp, body = self.object_client.get_object(dst_container_name,758 object_name)759 self.assertEqual(body, data)760 actual_meta_key = 'x-object-meta-' + meta_key761 self.assertIn(actual_meta_key, resp)762 self.assertEqual(resp[actual_meta_key], meta_value)763 @test.idempotent_id('5a9e2cc6-85b6-46fc-916d-0cbb7a88e5fd')764 def test_copy_object_with_x_fresh_metadata(self):765 # create source object766 metadata = {'x-object-meta-src': 'src_value'}767 src_object_name, data = self._create_object(metadata)768 # copy source object with x_fresh_metadata header769 metadata = {'X-Fresh-Metadata': 'true'}770 dst_object_name, resp = self._copy_object_2d(src_object_name,771 metadata)772 self.assertHeaders(resp, 'Object', 'COPY')773 self.assertNotIn('x-object-meta-src', resp)774 #Bug = 1417469775 #self.assertEqual(resp['x-copied-from'],776 # self.container_name + "/" + src_object_name)777 # check that destination object does NOT have any object-meta778 #Bug = 1417489779 #self._check_copied_obj(dst_object_name, data, not_in_meta=["src"])780 self._check_copied_obj(dst_object_name, data, in_meta=["src"])781 @test.idempotent_id('a28a8b99-e701-4d7e-9d84-3b66f121460b')782 def test_copy_object_with_x_object_metakey(self):783 # create source object784 metadata = {'x-object-meta-src': 'src_value'}785 src_obj_name, data = self._create_object(metadata)786 # copy source object to destination with x-object-meta-key787 metadata = {'x-object-meta-test': ''}788 dst_obj_name, resp = self._copy_object_2d(src_obj_name, metadata)789 self.assertHeaders(resp, 'Object', 'COPY')790 #Bug = 1417469791 #expected = {'x-object-meta-test': '',792 # 'x-object-meta-src': 'src_value',793 # 'x-copied-from': self.container_name + "/" + src_obj_name}794 #for key, value in six.iteritems(expected):795 # self.assertIn(key, resp)796 # self.assertEqual(value, resp[key])797 # check destination object798 #Bug = 1417466799 #self._check_copied_obj(dst_obj_name, data, in_meta=["test", "src"])800 self._check_copied_obj(dst_obj_name, data, in_meta=["src"])801 @test.idempotent_id('edabedca-24c3-4322-9b70-d6d9f942a074')802 def test_copy_object_with_x_object_meta(self):803 # create source object804 metadata = {'x-object-meta-src': 'src_value'}805 src_obj_name, data = self._create_object(metadata)806 # copy source object to destination with object metadata807 metadata = {'x-object-meta-test': 'value'}808 dst_obj_name, resp = self._copy_object_2d(src_obj_name, metadata)809 self.assertHeaders(resp, 'Object', 'COPY')810 #Bug = 1417469811 #expected = {'x-object-meta-test': 'value',812 # 'x-object-meta-src': 'src_value',813 # 'x-copied-from': self.container_name + "/" + src_obj_name}814 #for key, value in six.iteritems(expected):815 # self.assertIn(key, resp)816 # self.assertEqual(value, resp[key])817 # check destination object818 #Bug = 1417466819 #self._check_copied_obj(dst_obj_name, data, in_meta=["test", "src"])820 self._check_copied_obj(dst_obj_name, data, in_meta=["src"])821 @test.idempotent_id('e3e6a64a-9f50-4955-b987-6ce6767c97fb')822 def test_object_upload_in_segments(self):823 # create object824 object_name = data_utils.rand_name(name='LObject')825 data = data_utils.arbitrary_string()826 segments = 10827 data_segments = [data + str(i) for i in six.moves.xrange(segments)]828 # uploading segments829 for i in six.moves.xrange(segments):830 resp, _ = self.object_client.create_object_segments(831 self.container_name, object_name, i, data_segments[i])832 # creating a manifest file833 metadata = {'X-Object-Manifest': '%s/%s/'834 % (self.container_name, object_name)}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful