How to use _copy_object_2d method in tempest

Best Python code snippet using tempest_python

test_object_services.py

Source:test_object_services.py Github

copy

Full Screen

...53 for i in six.moves.xrange(segments):54 resp, _ = self.object_client.create_object_segments(55 self.container_name, object_name, i, data_segments[i])56 return object_name, data_segments57 def _copy_object_2d(self, src_object_name, metadata=None):58 dst_object_name = data_utils.rand_name(name='TestObject')59 resp, _ = self.object_client.copy_object_2d_way(self.container_name,60 src_object_name,61 dst_object_name,62 metadata=metadata)63 return dst_object_name, resp64 def _check_copied_obj(self, dst_object_name, src_body,65 in_meta=None, not_in_meta=None):66 resp, dest_body = self.object_client.get_object(self.container_name,67 dst_object_name)68 self.assertEqual(src_body, dest_body)69 if in_meta:70 for meta_key in in_meta:71 self.assertIn('x-object-meta-' + meta_key, resp)72 if not_in_meta:73 for meta_key in not_in_meta:74 self.assertNotIn('x-object-meta-' + meta_key, resp)75 @test.attr(type='smoke')76 @test.idempotent_id('5b4ce26f-3545-46c9-a2ba-5754358a4c62')77 def test_create_object(self):78 # create object79 object_name = data_utils.rand_name(name='TestObject')80 data = data_utils.arbitrary_string()81 resp, _ = self.object_client.create_object(self.container_name,82 object_name, data)83 # create another object84 object_name = data_utils.rand_name(name='TestObject')85 data = data_utils.arbitrary_string()86 resp, _ = self.object_client.create_object(self.container_name,87 object_name, data)88 self.assertHeaders(resp, 'Object', 'PUT')89 # check uploaded content90 _, body = self.object_client.get_object(self.container_name,91 object_name)92 self.assertEqual(data, body)93 @test.idempotent_id('5daebb1d-f0d5-4dc9-b541-69672eff00b0')94 def test_create_object_with_content_disposition(self):95 # create object with content_disposition96 object_name = data_utils.rand_name(name='TestObject')97 data = data_utils.arbitrary_string()98 metadata = {}99 metadata['content-disposition'] = 'inline'100 resp, _ = self.object_client.create_object(101 self.container_name,102 object_name,103 data,104 metadata=metadata)105 self.assertHeaders(resp, 'Object', 'PUT')106 resp, body = self.object_client.get_object(107 self.container_name,108 object_name,109 metadata=None)110 self.assertIn('content-disposition', resp)111 self.assertEqual(resp['content-disposition'], 'inline')112 self.assertEqual(body, data)113 @test.idempotent_id('605f8317-f945-4bee-ae91-013f1da8f0a0')114 def test_create_object_with_content_encoding(self):115 # create object with content_encoding116 object_name = data_utils.rand_name(name='TestObject')117 # put compressed string118 data_before = 'x' * 2000119 data = zlib.compress(data_before)120 metadata = {}121 metadata['content-encoding'] = 'deflate'122 resp, _ = self.object_client.create_object(123 self.container_name,124 object_name,125 data,126 metadata=metadata)127 self.assertHeaders(resp, 'Object', 'PUT')128 # download compressed object129 metadata = {}130 metadata['accept-encoding'] = 'deflate'131 resp, body = self.object_client.get_object(132 self.container_name,133 object_name,134 metadata=metadata)135 self.assertEqual(body, data_before)136 @test.idempotent_id('73820093-0503-40b1-a478-edf0e69c7d1f')137 def test_create_object_with_etag(self):138 # create object with etag139 object_name = data_utils.rand_name(name='TestObject')140 data = data_utils.arbitrary_string()141 md5 = hashlib.md5(data).hexdigest()142 metadata = {'Etag': md5}143 resp, _ = self.object_client.create_object(144 self.container_name,145 object_name,146 data,147 metadata=metadata)148 self.assertHeaders(resp, 'Object', 'PUT')149 # check uploaded content150 _, body = self.object_client.get_object(self.container_name,151 object_name)152 self.assertEqual(data, body)153 @test.idempotent_id('84dafe57-9666-4f6d-84c8-0814d37923b8')154 def test_create_object_with_expect_continue(self):155 # create object with expect_continue156 object_name = data_utils.rand_name(name='TestObject')157 data = data_utils.arbitrary_string()158 metadata = {'Expect': '100-continue'}159 resp = self.object_client.create_object_continue(160 self.container_name,161 object_name,162 data,163 metadata=metadata)164 self.assertIn('status', resp)165 self.assertEqual(resp['status'], '100')166 self.object_client.create_object_continue(167 self.container_name,168 object_name,169 data,170 metadata=None)171 # check uploaded content172 _, body = self.object_client.get_object(self.container_name,173 object_name)174 self.assertEqual(data, body)175 @test.idempotent_id('4f84422a-e2f2-4403-b601-726a4220b54e')176 def test_create_object_with_transfer_encoding(self):177 # create object with transfer_encoding178 object_name = data_utils.rand_name(name='TestObject')179 data = data_utils.arbitrary_string(1024)180 status, _, resp_headers = self.object_client.put_object_with_chunk(181 container=self.container_name,182 name=object_name,183 contents=moves.cStringIO(data),184 chunk_size=512)185 self.assertHeaders(resp_headers, 'Object', 'PUT')186 # check uploaded content187 _, body = self.object_client.get_object(self.container_name,188 object_name)189 self.assertEqual(data, body)190 @test.idempotent_id('0f3d62a6-47e3-4554-b0e5-1a5dc372d501')191 def test_create_object_with_x_fresh_metadata(self):192 # create object with x_fresh_metadata193 object_name_base = data_utils.rand_name(name='TestObject')194 data = data_utils.arbitrary_string()195 metadata_1 = {'X-Object-Meta-test-meta': 'Meta'}196 self.object_client.create_object(self.container_name,197 object_name_base,198 data,199 metadata=metadata_1)200 object_name = data_utils.rand_name(name='TestObject')201 metadata_2 = {'X-Copy-From': '%s/%s' % (self.container_name,202 object_name_base),203 'X-Fresh-Metadata': 'true'}204 resp, _ = self.object_client.create_object(205 self.container_name,206 object_name,207 '',208 metadata=metadata_2)209 self.assertHeaders(resp, 'Object', 'PUT')210 resp, body = self.object_client.get_object(self.container_name,211 object_name)212 self.assertNotIn('x-object-meta-test-meta', resp)213 self.assertEqual(data, body)214 @test.idempotent_id('1c7ed3e4-2099-406b-b843-5301d4811baf')215 def test_create_object_with_x_object_meta(self):216 # create object with object_meta217 object_name = data_utils.rand_name(name='TestObject')218 data = data_utils.arbitrary_string()219 metadata = {'X-Object-Meta-test-meta': 'Meta'}220 resp, _ = self.object_client.create_object(221 self.container_name,222 object_name,223 data,224 metadata=metadata)225 self.assertHeaders(resp, 'Object', 'PUT')226 resp, body = self.object_client.get_object(self.container_name,227 object_name)228 self.assertIn('x-object-meta-test-meta', resp)229 self.assertEqual(resp['x-object-meta-test-meta'], 'Meta')230 self.assertEqual(data, body)231 @test.idempotent_id('e4183917-33db-4153-85cc-4dacbb938865')232 def test_create_object_with_x_object_metakey(self):233 # create object with the blank value of metadata234 object_name = data_utils.rand_name(name='TestObject')235 data = data_utils.arbitrary_string()236 metadata = {'X-Object-Meta-test-meta': ''}237 resp, _ = self.object_client.create_object(238 self.container_name,239 object_name,240 data,241 metadata=metadata)242 self.assertHeaders(resp, 'Object', 'PUT')243 resp, body = self.object_client.get_object(self.container_name,244 object_name)245 self.assertIn('x-object-meta-test-meta', resp)246 self.assertEqual(resp['x-object-meta-test-meta'], '')247 self.assertEqual(data, body)248 @test.idempotent_id('ce798afc-b278-45de-a5ce-2ea124b98b99')249 def test_create_object_with_x_remove_object_meta(self):250 # create object with x_remove_object_meta251 object_name = data_utils.rand_name(name='TestObject')252 data = data_utils.arbitrary_string()253 metadata_add = {'X-Object-Meta-test-meta': 'Meta'}254 self.object_client.create_object(self.container_name,255 object_name,256 data,257 metadata=metadata_add)258 metadata_remove = {'X-Remove-Object-Meta-test-meta': 'Meta'}259 resp, _ = self.object_client.create_object(260 self.container_name,261 object_name,262 data,263 metadata=metadata_remove)264 self.assertHeaders(resp, 'Object', 'PUT')265 resp, body = self.object_client.get_object(self.container_name,266 object_name)267 self.assertNotIn('x-object-meta-test-meta', resp)268 self.assertEqual(data, body)269 @test.idempotent_id('ad21e342-7916-4f9e-ab62-a1f885f2aaf9')270 def test_create_object_with_x_remove_object_metakey(self):271 # create object with the blank value of remove metadata272 object_name = data_utils.rand_name(name='TestObject')273 data = data_utils.arbitrary_string()274 metadata_add = {'X-Object-Meta-test-meta': 'Meta'}275 self.object_client.create_object(self.container_name,276 object_name,277 data,278 metadata=metadata_add)279 metadata_remove = {'X-Remove-Object-Meta-test-meta': ''}280 resp, _ = self.object_client.create_object(281 self.container_name,282 object_name,283 data,284 metadata=metadata_remove)285 self.assertHeaders(resp, 'Object', 'PUT')286 resp, body = self.object_client.get_object(self.container_name,287 object_name)288 self.assertNotIn('x-object-meta-test-meta', resp)289 self.assertEqual(data, body)290 @test.idempotent_id('17738d45-03bd-4d45-9e0b-7b2f58f98687')291 def test_delete_object(self):292 # create object293 object_name = data_utils.rand_name(name='TestObject')294 data = data_utils.arbitrary_string()295 resp, _ = self.object_client.create_object(self.container_name,296 object_name, data)297 # delete object298 resp, _ = self.object_client.delete_object(self.container_name,299 object_name)300 self.assertHeaders(resp, 'Object', 'DELETE')301 @test.attr(type='smoke')302 @test.idempotent_id('7a94c25d-66e6-434c-9c38-97d4e2c29945')303 def test_update_object_metadata(self):304 # update object metadata305 object_name, data = self._create_object()306 metadata = {'X-Object-Meta-test-meta': 'Meta'}307 resp, _ = self.object_client.update_object_metadata(308 self.container_name,309 object_name,310 metadata,311 metadata_prefix='')312 self.assertHeaders(resp, 'Object', 'POST')313 resp, _ = self.object_client.list_object_metadata(314 self.container_name,315 object_name)316 self.assertIn('x-object-meta-test-meta', resp)317 self.assertEqual(resp['x-object-meta-test-meta'], 'Meta')318 @test.idempotent_id('48650ed0-c189-4e1e-ad6b-1d4770c6e134')319 def test_update_object_metadata_with_remove_metadata(self):320 # update object metadata with remove metadata321 object_name = data_utils.rand_name(name='TestObject')322 data = data_utils.arbitrary_string()323 create_metadata = {'X-Object-Meta-test-meta1': 'Meta1'}324 self.object_client.create_object(self.container_name,325 object_name,326 data,327 metadata=create_metadata)328 update_metadata = {'X-Remove-Object-Meta-test-meta1': 'Meta1'}329 resp, _ = self.object_client.update_object_metadata(330 self.container_name,331 object_name,332 update_metadata,333 metadata_prefix='')334 self.assertHeaders(resp, 'Object', 'POST')335 resp, _ = self.object_client.list_object_metadata(336 self.container_name,337 object_name)338 self.assertNotIn('x-object-meta-test-meta1', resp)339 @test.idempotent_id('f726174b-2ded-4708-bff7-729d12ce1f84')340 def test_update_object_metadata_with_create_and_remove_metadata(self):341 # creation and deletion of metadata with one request342 object_name = data_utils.rand_name(name='TestObject')343 data = data_utils.arbitrary_string()344 create_metadata = {'X-Object-Meta-test-meta1': 'Meta1'}345 self.object_client.create_object(self.container_name,346 object_name,347 data,348 metadata=create_metadata)349 update_metadata = {'X-Object-Meta-test-meta2': 'Meta2',350 'X-Remove-Object-Meta-test-meta1': 'Meta1'}351 resp, _ = self.object_client.update_object_metadata(352 self.container_name,353 object_name,354 update_metadata,355 metadata_prefix='')356 self.assertHeaders(resp, 'Object', 'POST')357 resp, _ = self.object_client.list_object_metadata(358 self.container_name,359 object_name)360 self.assertNotIn('x-object-meta-test-meta1', resp)361 self.assertIn('x-object-meta-test-meta2', resp)362 self.assertEqual(resp['x-object-meta-test-meta2'], 'Meta2')363 @test.idempotent_id('08854588-6449-4bb7-8cca-f2e1040f5e6f')364 def test_update_object_metadata_with_x_object_manifest(self):365 # update object metadata with x_object_manifest366 # uploading segments367 object_name, data_segments = self._upload_segments()368 # creating a manifest file369 data_empty = ''370 self.object_client.create_object(self.container_name,371 object_name,372 data_empty,373 metadata=None)374 object_prefix = '%s/%s' % (self.container_name, object_name)375 update_metadata = {'X-Object-Manifest': object_prefix}376 resp, _ = self.object_client.update_object_metadata(377 self.container_name,378 object_name,379 update_metadata,380 metadata_prefix='')381 self.assertHeaders(resp, 'Object', 'POST')382 resp, _ = self.object_client.list_object_metadata(383 self.container_name,384 object_name)385 self.assertIn('x-object-manifest', resp)386 self.assertNotEqual(len(resp['x-object-manifest']), 0)387 @test.idempotent_id('0dbbe89c-6811-4d84-a2df-eca2bdd40c0e')388 def test_update_object_metadata_with_x_object_metakey(self):389 # update object metadata with a blenk value of metadata390 object_name, data = self._create_object()391 update_metadata = {'X-Object-Meta-test-meta': ''}392 resp, _ = self.object_client.update_object_metadata(393 self.container_name,394 object_name,395 update_metadata,396 metadata_prefix='')397 self.assertHeaders(resp, 'Object', 'POST')398 resp, _ = self.object_client.list_object_metadata(399 self.container_name,400 object_name)401 self.assertIn('x-object-meta-test-meta', resp)402 self.assertEqual(resp['x-object-meta-test-meta'], '')403 @test.idempotent_id('9a88dca4-b684-425b-806f-306cd0e57e42')404 def test_update_object_metadata_with_x_remove_object_metakey(self):405 # update object metadata with a blank value of remove metadata406 object_name = data_utils.rand_name(name='TestObject')407 data = data_utils.arbitrary_string()408 create_metadata = {'X-Object-Meta-test-meta': 'Meta'}409 self.object_client.create_object(self.container_name,410 object_name,411 data,412 metadata=create_metadata)413 update_metadata = {'X-Remove-Object-Meta-test-meta': ''}414 resp, _ = self.object_client.update_object_metadata(415 self.container_name,416 object_name,417 update_metadata,418 metadata_prefix='')419 self.assertHeaders(resp, 'Object', 'POST')420 resp, _ = self.object_client.list_object_metadata(421 self.container_name,422 object_name)423 self.assertNotIn('x-object-meta-test-meta', resp)424 @test.attr(type='smoke')425 @test.idempotent_id('9a447cf6-de06-48de-8226-a8c6ed31caf2')426 def test_list_object_metadata(self):427 # get object metadata428 object_name = data_utils.rand_name(name='TestObject')429 data = data_utils.arbitrary_string()430 metadata = {'X-Object-Meta-test-meta': 'Meta'}431 self.object_client.create_object(self.container_name,432 object_name,433 data,434 metadata=metadata)435 resp, _ = self.object_client.list_object_metadata(436 self.container_name,437 object_name)438 self.assertHeaders(resp, 'Object', 'HEAD')439 self.assertIn('x-object-meta-test-meta', resp)440 self.assertEqual(resp['x-object-meta-test-meta'], 'Meta')441 @test.idempotent_id('170fb90e-f5c3-4b1f-ae1b-a18810821172')442 def test_list_no_object_metadata(self):443 # get empty list of object metadata444 object_name, data = self._create_object()445 resp, _ = self.object_client.list_object_metadata(446 self.container_name,447 object_name)448 self.assertHeaders(resp, 'Object', 'HEAD')449 self.assertNotIn('x-object-meta-', str(resp))450 @test.idempotent_id('23a3674c-d6de-46c3-86af-ff92bfc8a3da')451 def test_list_object_metadata_with_x_object_manifest(self):452 # get object metadata with x_object_manifest453 # uploading segments454 object_name, data_segments = self._upload_segments()455 # creating a manifest file456 object_prefix = '%s/%s' % (self.container_name, object_name)457 metadata = {'X-Object-Manifest': object_prefix}458 data_empty = ''459 resp, _ = self.object_client.create_object(460 self.container_name,461 object_name,462 data_empty,463 metadata=metadata)464 resp, _ = self.object_client.list_object_metadata(465 self.container_name,466 object_name)467 # Check only the existence of common headers with custom matcher468 self.assertThat(resp, custom_matchers.ExistsAllResponseHeaders(469 'Object', 'HEAD'))470 self.assertIn('x-object-manifest', resp)471 # Etag value of a large object is enclosed in double-quotations.472 # This is a special case, therefore the formats of response headers473 # are checked without a custom matcher.474 self.assertTrue(resp['etag'].startswith('\"'))475 self.assertTrue(resp['etag'].endswith('\"'))476 self.assertTrue(resp['etag'].strip('\"').isalnum())477 self.assertTrue(re.match("^\d+\.?\d*\Z", resp['x-timestamp']))478 self.assertNotEqual(len(resp['content-type']), 0)479 self.assertTrue(re.match("^tx[0-9a-f]{21}-[0-9a-f]{10}.*",480 resp['x-trans-id']))481 self.assertNotEqual(len(resp['date']), 0)482 self.assertEqual(resp['accept-ranges'], 'bytes')483 self.assertEqual(resp['x-object-manifest'],484 '%s/%s' % (self.container_name, object_name))485 @test.attr(type='smoke')486 @test.idempotent_id('02610ba7-86b7-4272-9ed8-aa8d417cb3cd')487 def test_get_object(self):488 # retrieve object's data (in response body)489 # create object490 object_name, data = self._create_object()491 # get object492 resp, body = self.object_client.get_object(self.container_name,493 object_name)494 self.assertHeaders(resp, 'Object', 'GET')495 self.assertEqual(body, data)496 @test.idempotent_id('005f9bf6-e06d-41ec-968e-96c78e0b1d82')497 def test_get_object_with_metadata(self):498 # get object with metadata499 object_name = data_utils.rand_name(name='TestObject')500 data = data_utils.arbitrary_string()501 metadata = {'X-Object-Meta-test-meta': 'Meta'}502 self.object_client.create_object(self.container_name,503 object_name,504 data,505 metadata=metadata)506 resp, body = self.object_client.get_object(507 self.container_name,508 object_name,509 metadata=None)510 self.assertHeaders(resp, 'Object', 'GET')511 self.assertIn('x-object-meta-test-meta', resp)512 self.assertEqual(resp['x-object-meta-test-meta'], 'Meta')513 self.assertEqual(body, data)514 @test.idempotent_id('05a1890e-7db9-4a6c-90a8-ce998a2bddfa')515 def test_get_object_with_range(self):516 # get object with range517 object_name = data_utils.rand_name(name='TestObject')518 data = data_utils.arbitrary_string(100)519 self.object_client.create_object(self.container_name,520 object_name,521 data,522 metadata=None)523 rand_num = random.randint(3, len(data) - 1)524 metadata = {'Range': 'bytes=%s-%s' % (rand_num - 3, rand_num - 1)}525 resp, body = self.object_client.get_object(526 self.container_name,527 object_name,528 metadata=metadata)529 self.assertHeaders(resp, 'Object', 'GET')530 self.assertEqual(body, data[rand_num - 3: rand_num])531 @test.idempotent_id('11b4515b-7ba7-4ca8-8838-357ded86fc10')532 def test_get_object_with_x_object_manifest(self):533 # get object with x_object_manifest534 # uploading segments535 object_name, data_segments = self._upload_segments()536 # creating a manifest file537 object_prefix = '%s/%s' % (self.container_name, object_name)538 metadata = {'X-Object-Manifest': object_prefix}539 data_empty = ''540 resp, body = self.object_client.create_object(541 self.container_name,542 object_name,543 data_empty,544 metadata=metadata)545 resp, body = self.object_client.get_object(546 self.container_name,547 object_name,548 metadata=None)549 # Check only the existence of common headers with custom matcher550 self.assertThat(resp, custom_matchers.ExistsAllResponseHeaders(551 'Object', 'GET'))552 self.assertIn('x-object-manifest', resp)553 # Etag value of a large object is enclosed in double-quotations.554 # This is a special case, therefore the formats of response headers555 # are checked without a custom matcher.556 self.assertTrue(resp['etag'].startswith('\"'))557 self.assertTrue(resp['etag'].endswith('\"'))558 self.assertTrue(resp['etag'].strip('\"').isalnum())559 self.assertTrue(re.match("^\d+\.?\d*\Z", resp['x-timestamp']))560 self.assertNotEqual(len(resp['content-type']), 0)561 self.assertTrue(re.match("^tx[0-9a-f]{21}-[0-9a-f]{10}.*",562 resp['x-trans-id']))563 self.assertNotEqual(len(resp['date']), 0)564 self.assertEqual(resp['accept-ranges'], 'bytes')565 self.assertEqual(resp['x-object-manifest'],566 '%s/%s' % (self.container_name, object_name))567 self.assertEqual(''.join(data_segments), body)568 @test.idempotent_id('c05b4013-e4de-47af-be84-e598062b16fc')569 def test_get_object_with_if_match(self):570 # get object with if_match571 object_name = data_utils.rand_name(name='TestObject')572 data = data_utils.arbitrary_string(10)573 create_md5 = hashlib.md5(data).hexdigest()574 create_metadata = {'Etag': create_md5}575 self.object_client.create_object(self.container_name,576 object_name,577 data,578 metadata=create_metadata)579 list_metadata = {'If-Match': create_md5}580 resp, body = self.object_client.get_object(581 self.container_name,582 object_name,583 metadata=list_metadata)584 self.assertHeaders(resp, 'Object', 'GET')585 self.assertEqual(body, data)586 @test.idempotent_id('be133639-e5d2-4313-9b1f-2d59fc054a16')587 def test_get_object_with_if_modified_since(self):588 # get object with if_modified_since589 object_name = data_utils.rand_name(name='TestObject')590 data = data_utils.arbitrary_string()591 time_now = time.time()592 self.object_client.create_object(self.container_name,593 object_name,594 data,595 metadata=None)596 http_date = time.ctime(time_now - 86400)597 list_metadata = {'If-Modified-Since': http_date}598 resp, body = self.object_client.get_object(599 self.container_name,600 object_name,601 metadata=list_metadata)602 self.assertHeaders(resp, 'Object', 'GET')603 self.assertEqual(body, data)604 @test.idempotent_id('641500d5-1612-4042-a04d-01fc4528bc30')605 def test_get_object_with_if_none_match(self):606 # get object with if_none_match607 object_name = data_utils.rand_name(name='TestObject')608 data = data_utils.arbitrary_string(10)609 create_md5 = hashlib.md5(data).hexdigest()610 create_metadata = {'Etag': create_md5}611 self.object_client.create_object(self.container_name,612 object_name,613 data,614 metadata=create_metadata)615 list_data = data_utils.arbitrary_string(15)616 list_md5 = hashlib.md5(list_data).hexdigest()617 list_metadata = {'If-None-Match': list_md5}618 resp, body = self.object_client.get_object(619 self.container_name,620 object_name,621 metadata=list_metadata)622 self.assertHeaders(resp, 'Object', 'GET')623 self.assertEqual(body, data)624 @test.idempotent_id('0aa1201c-10aa-467a-bee7-63cbdd463152')625 def test_get_object_with_if_unmodified_since(self):626 # get object with if_unmodified_since627 object_name, data = self._create_object()628 time_now = time.time()629 http_date = time.ctime(time_now + 86400)630 list_metadata = {'If-Unmodified-Since': http_date}631 resp, body = self.object_client.get_object(632 self.container_name,633 object_name,634 metadata=list_metadata)635 self.assertHeaders(resp, 'Object', 'GET')636 self.assertEqual(body, data)637 @test.idempotent_id('94587078-475f-48f9-a40f-389c246e31cd')638 def test_get_object_with_x_newest(self):639 # get object with x_newest640 object_name, data = self._create_object()641 list_metadata = {'X-Newest': 'true'}642 resp, body = self.object_client.get_object(643 self.container_name,644 object_name,645 metadata=list_metadata)646 self.assertHeaders(resp, 'Object', 'GET')647 self.assertEqual(body, data)648 @test.idempotent_id('1a9ab572-1b66-4981-8c21-416e2a5e6011')649 def test_copy_object_in_same_container(self):650 # create source object651 src_object_name = data_utils.rand_name(name='SrcObject')652 src_data = data_utils.arbitrary_string(size=len(src_object_name) * 2,653 base_text=src_object_name)654 resp, _ = self.object_client.create_object(self.container_name,655 src_object_name,656 src_data)657 # create destination object658 dst_object_name = data_utils.rand_name(name='DstObject')659 dst_data = data_utils.arbitrary_string(size=len(dst_object_name) * 3,660 base_text=dst_object_name)661 resp, _ = self.object_client.create_object(self.container_name,662 dst_object_name,663 dst_data)664 # copy source object to destination665 resp, _ = self.object_client.copy_object_in_same_container(666 self.container_name, src_object_name, dst_object_name)667 self.assertHeaders(resp, 'Object', 'PUT')668 # check data669 resp, body = self.object_client.get_object(self.container_name,670 dst_object_name)671 self.assertEqual(body, src_data)672 @test.idempotent_id('2248abba-415d-410b-9c30-22dff9cd6e67')673 def test_copy_object_to_itself(self):674 # change the content type of an existing object675 # create object676 object_name, data = self._create_object()677 # get the old content type678 resp_tmp, _ = self.object_client.list_object_metadata(679 self.container_name, object_name)680 # change the content type of the object681 metadata = {'content-type': 'text/plain; charset=UTF-8'}682 self.assertNotEqual(resp_tmp['content-type'], metadata['content-type'])683 resp, _ = self.object_client.copy_object_in_same_container(684 self.container_name, object_name, object_name, metadata)685 self.assertHeaders(resp, 'Object', 'PUT')686 # check the content type687 resp, _ = self.object_client.list_object_metadata(self.container_name,688 object_name)689 self.assertEqual(resp['content-type'], metadata['content-type'])690 @test.idempotent_id('06f90388-2d0e-40aa-934c-e9a8833e958a')691 def test_copy_object_2d_way(self):692 # create source object693 src_object_name = data_utils.rand_name(name='SrcObject')694 src_data = data_utils.arbitrary_string(size=len(src_object_name) * 2,695 base_text=src_object_name)696 resp, _ = self.object_client.create_object(self.container_name,697 src_object_name, src_data)698 # create destination object699 dst_object_name = data_utils.rand_name(name='DstObject')700 dst_data = data_utils.arbitrary_string(size=len(dst_object_name) * 3,701 base_text=dst_object_name)702 resp, _ = self.object_client.create_object(self.container_name,703 dst_object_name, dst_data)704 # copy source object to destination705 resp, _ = self.object_client.copy_object_2d_way(self.container_name,706 src_object_name,707 dst_object_name)708 self.assertHeaders(resp, 'Object', 'COPY')709 self.assertEqual(710 resp['x-copied-from'],711 self.container_name + "/" + src_object_name)712 # check data713 self._check_copied_obj(dst_object_name, src_data)714 @test.idempotent_id('aa467252-44f3-472a-b5ae-5b57c3c9c147')715 def test_copy_object_across_containers(self):716 # create a container to use as a source container717 src_container_name = data_utils.rand_name(name='TestSourceContainer')718 self.container_client.create_container(src_container_name)719 self.containers.append(src_container_name)720 # create a container to use as a destination container721 dst_container_name = data_utils.rand_name(722 name='TestDestinationContainer')723 self.container_client.create_container(dst_container_name)724 self.containers.append(dst_container_name)725 # create object in source container726 object_name = data_utils.rand_name(name='Object')727 data = data_utils.arbitrary_string(size=len(object_name) * 2,728 base_text=object_name)729 resp, _ = self.object_client.create_object(src_container_name,730 object_name, data)731 # set object metadata732 meta_key = data_utils.rand_name(name='test')733 meta_value = data_utils.rand_name(name='MetaValue')734 orig_metadata = {meta_key: meta_value}735 resp, _ = self.object_client.update_object_metadata(src_container_name,736 object_name,737 orig_metadata)738 self.assertHeaders(resp, 'Object', 'POST')739 # copy object from source container to destination container740 resp, _ = self.object_client.copy_object_across_containers(741 src_container_name, object_name, dst_container_name,742 object_name)743 self.assertHeaders(resp, 'Object', 'PUT')744 # check if object is present in destination container745 resp, body = self.object_client.get_object(dst_container_name,746 object_name)747 self.assertEqual(body, data)748 actual_meta_key = 'x-object-meta-' + meta_key749 self.assertIn(actual_meta_key, resp)750 self.assertEqual(resp[actual_meta_key], meta_value)751 @test.idempotent_id('5a9e2cc6-85b6-46fc-916d-0cbb7a88e5fd')752 def test_copy_object_with_x_fresh_metadata(self):753 # create source object754 metadata = {'x-object-meta-src': 'src_value'}755 src_object_name, data = self._create_object(metadata)756 # copy source object with x_fresh_metadata header757 metadata = {'X-Fresh-Metadata': 'true'}758 dst_object_name, resp = self._copy_object_2d(src_object_name,759 metadata)760 self.assertHeaders(resp, 'Object', 'COPY')761 self.assertNotIn('x-object-meta-src', resp)762 self.assertEqual(resp['x-copied-from'],763 self.container_name + "/" + src_object_name)764 # check that destination object does NOT have any object-meta765 self._check_copied_obj(dst_object_name, data, not_in_meta=["src"])766 @test.idempotent_id('a28a8b99-e701-4d7e-9d84-3b66f121460b')767 def test_copy_object_with_x_object_metakey(self):768 # create source object769 metadata = {'x-object-meta-src': 'src_value'}770 src_obj_name, data = self._create_object(metadata)771 # copy source object to destination with x-object-meta-key772 metadata = {'x-object-meta-test': ''}773 dst_obj_name, resp = self._copy_object_2d(src_obj_name, metadata)774 self.assertHeaders(resp, 'Object', 'COPY')775 expected = {'x-object-meta-test': '',776 'x-object-meta-src': 'src_value',777 'x-copied-from': self.container_name + "/" + src_obj_name}778 for key, value in six.iteritems(expected):779 self.assertIn(key, resp)780 self.assertEqual(value, resp[key])781 # check destination object782 self._check_copied_obj(dst_obj_name, data, in_meta=["test", "src"])783 @test.idempotent_id('edabedca-24c3-4322-9b70-d6d9f942a074')784 def test_copy_object_with_x_object_meta(self):785 # create source object786 metadata = {'x-object-meta-src': 'src_value'}787 src_obj_name, data = self._create_object(metadata)788 # copy source object to destination with object metadata789 metadata = {'x-object-meta-test': 'value'}790 dst_obj_name, resp = self._copy_object_2d(src_obj_name, metadata)791 self.assertHeaders(resp, 'Object', 'COPY')792 expected = {'x-object-meta-test': 'value',793 'x-object-meta-src': 'src_value',794 'x-copied-from': self.container_name + "/" + src_obj_name}795 for key, value in six.iteritems(expected):796 self.assertIn(key, resp)797 self.assertEqual(value, resp[key])798 # check destination object799 self._check_copied_obj(dst_obj_name, data, in_meta=["test", "src"])800 @test.idempotent_id('e3e6a64a-9f50-4955-b987-6ce6767c97fb')801 def test_object_upload_in_segments(self):802 # create object803 object_name = data_utils.rand_name(name='LObject')804 data = data_utils.arbitrary_string()...

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