import mock
import botocore.session
from tests import BaseSessionTest
class TestRDSPresign(BaseSessionTest):
def test_inject_presigned_url(self):
client = self.session.create_client('rds', 'us-west-2')
params = {
'SourceDBSnapshotIdentifier': 'source-db',
'TargetDBSnapshotIdentifier': 'target-db',
'SourceRegion': 'us-east-1'
}
with mock.patch('botocore.endpoint.Session.send') as _send:
_send.return_value = mock.Mock(
status_code=200, headers={}, content=(
b'<CopyDBSnapshotResponse>'
b'<CopyDBSnapshotResult></CopyDBSnapshotResult>'
b'</CopyDBSnapshotResponse>'
))
client.copy_db_snapshot(**params)
sent_request = _send.call_args[0][0]
self.assertIn('PreSignedUrl', sent_request.body)
self.assertNotIn('SourceRegion', sent_request.body)