Add check for UnknownSnapshotCopyRegionFault error

This commit is contained in:
Brian Pandola 2020-11-21 23:43:38 -08:00 committed by Bert Blommers
parent b4d7d183ab
commit cf7869d0e2
3 changed files with 21 additions and 0 deletions

View File

@ -150,3 +150,10 @@ class InvalidParameterCombinationError(RedshiftClientError):
super(InvalidParameterCombinationError, self).__init__(
"InvalidParameterCombination", message
)
class UnknownSnapshotCopyRegionFaultError(RedshiftClientError):
def __init__(self, message):
super(UnknownSnapshotCopyRegionFaultError, self).__init__(
"UnknownSnapshotCopyRegionFault", message
)

View File

@ -26,6 +26,7 @@ from .exceptions import (
SnapshotCopyDisabledFaultError,
SnapshotCopyGrantAlreadyExistsFaultError,
SnapshotCopyGrantNotFoundFaultError,
UnknownSnapshotCopyRegionFaultError,
)
@ -577,6 +578,10 @@ class RedshiftBackend(BaseBackend):
raise InvalidParameterValueError(
"SnapshotCopyGrantName is required for Snapshot Copy on KMS encrypted clusters."
)
if kwargs["destination_region"] == self.region:
raise UnknownSnapshotCopyRegionFaultError(
"Invalid region {}".format(self.region)
)
status = {
"DestinationRegion": kwargs["destination_region"],
"RetentionPeriod": kwargs["retention_period"],

View File

@ -1268,6 +1268,15 @@ def test_enable_snapshot_copy():
ex.value.response["Error"]["Message"].should.contain(
"SnapshotCopyGrantName is required for Snapshot Copy on KMS encrypted clusters."
)
with pytest.raises(ClientError) as ex:
client.enable_snapshot_copy(
ClusterIdentifier="test",
DestinationRegion="us-east-1",
RetentionPeriod=3,
SnapshotCopyGrantName="invalid-us-east-1-to-us-east-1",
)
ex.value.response["Error"]["Code"].should.equal("UnknownSnapshotCopyRegionFault")
ex.value.response["Error"]["Message"].should.contain("Invalid region us-east-1")
client.enable_snapshot_copy(
ClusterIdentifier="test",
DestinationRegion="us-west-2",