test_delete.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"). You
  4. # may not use this file except in compliance with the License. A copy of
  5. # the License is located at
  6. #
  7. # http://aws.amazon.com/apache2.0/
  8. #
  9. # or in the "license" file accompanying this file. This file is
  10. # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  11. # ANY KIND, either express or implied. See the License for the specific
  12. # language governing permissions and limitations under the License.
  13. from __tests__ import BaseGeneralInterfaceTest
  14. from s3transfer.manager import TransferManager
  15. class TestDeleteObject(BaseGeneralInterfaceTest):
  16. __test__ = True
  17. def setUp(self):
  18. super(TestDeleteObject, self).setUp()
  19. self.bucket = 'mybucket'
  20. self.key = 'mykey'
  21. self.manager = TransferManager(self.client)
  22. @property
  23. def method(self):
  24. """The transfer manager method to invoke i.e. upload()"""
  25. return self.manager.delete
  26. def create_call_kwargs(self):
  27. """The kwargs to be passed to the transfer manager method"""
  28. return {
  29. 'bucket': self.bucket,
  30. 'key': self.key,
  31. }
  32. def create_invalid_extra_args(self):
  33. return {
  34. 'BadKwargs': True,
  35. }
  36. def create_stubbed_responses(self):
  37. """A list of stubbed responses that will cause the request to succeed
  38. The elements of this list is a dictionary that will be used as key
  39. word arguments to botocore.Stubber.add_response(). For example::
  40. [{'method': 'put_object', 'service_response': {}}]
  41. """
  42. return [{
  43. 'method': 'delete_object',
  44. 'service_response': {},
  45. 'expected_params': {'Bucket': self.bucket, 'Key': self.key},
  46. }]
  47. def create_expected_progress_callback_info(self):
  48. return []
  49. def test_known_allowed_args_in_input_shape(self):
  50. op_model = self.client.meta.service_model.operation_model(
  51. 'DeleteObject')
  52. for allowed_arg in self.manager.ALLOWED_DELETE_ARGS:
  53. self.assertIn(allowed_arg, op_model.input_shape.members)
  54. def test_raise_exception_on_s3_object_lambda_resource(self):
  55. s3_object_lambda_arn = (
  56. 'arn:aws:s3-object-lambda:us-west-2:123456789012:'
  57. 'accesspoint:my-accesspoint'
  58. )
  59. with self.assertRaisesRegexp(ValueError, 'methods do not support'):
  60. self.manager.delete(s3_object_lambda_arn, self.key)