def test_s3_batch_delete_objects_using_requests(self):
    bucket_name = ('bucket-%s' % short_uid())
    object_key_1 = ('key-%s' % short_uid())
    object_key_2 = ('key-%s' % short_uid())
    self.s3_client.create_bucket(Bucket=bucket_name)
    self.s3_client.put_object(Bucket=bucket_name, Key=object_key_1, Body='This body document')
    self.s3_client.put_object(Bucket=bucket_name, Key=object_key_2, Body='This body document')
    base_url = '{}://{}:{}'.format(get_service_protocol(), config.LOCALSTACK_HOSTNAME, config.PORT_S3)
    url = '{}/{}?delete='.format(base_url, bucket_name)
    r = requests.post(url=url, data=(BATCH_DELETE_BODY % (object_key_1, object_key_2)))
    self.assertEqual(r.status_code, 200)
    s3_resource = aws_stack.connect_to_resource('s3')
    bucket = s3_resource.Bucket(bucket_name)
    total_keys = sum((1 for _ in bucket.objects.all()))
    self.assertEqual(total_keys, 0)
    self._delete_bucket(bucket_name, [])
def test_s3_batch_delete_objects_using_requests(self):
    bucket_name = ('bucket-%s' % short_uid())
    object_key_1 = ('key-%s' % short_uid())
    object_key_2 = ('key-%s' % short_uid())
    self.s3_client.create_bucket(Bucket=bucket_name)
    self.s3_client.put_object(Bucket=bucket_name, Key=object_key_1, Body='This body document')
    self.s3_client.put_object(Bucket=bucket_name, Key=object_key_2, Body='This body document')
    base_url = '{}://{}:{}'.format(get_service_protocol(), config.LOCALSTACK_HOSTNAME, config.PORT_S3)
    url = '{}/{}?delete='.format(base_url, bucket_name)
    r = requests.post(url=url, data=(BATCH_DELETE_BODY % (object_key_1, object_key_2)))
    self.assertEqual(r.status_code, 200)
    s3_resource = aws_stack.connect_to_resource('s3')
    bucket = s3_resource.Bucket(bucket_name)
    total_keys = sum((1 for _ in bucket.objects.all()))
    self.assertEqual(total_keys, 0)
    self._delete_bucket(bucket_name, [])