From 555be78f6e1636b4f94e225c0e78fe8adcde95d0 Mon Sep 17 00:00:00 2001 From: Brian Pandola Date: Sat, 21 Nov 2020 23:13:04 -0800 Subject: [PATCH] Fix: redshift:DescribeClusterSnapshots should not raise ClusterNotFoundError Real AWS backend returns an empty array instead of raising an error. --- moto/redshift/models.py | 1 - tests/test_redshift/test_redshift.py | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/moto/redshift/models.py b/moto/redshift/models.py index 625796f8a..5bbe348bc 100644 --- a/moto/redshift/models.py +++ b/moto/redshift/models.py @@ -777,7 +777,6 @@ class RedshiftBackend(BaseBackend): cluster_snapshots.append(snapshot) if cluster_snapshots: return cluster_snapshots - raise ClusterNotFoundError(cluster_identifier) if snapshot_identifier: if snapshot_identifier in self.snapshots: diff --git a/tests/test_redshift/test_redshift.py b/tests/test_redshift/test_redshift.py index 8272cea82..f7c8b872c 100644 --- a/tests/test_redshift/test_redshift.py +++ b/tests/test_redshift/test_redshift.py @@ -826,12 +826,11 @@ def test_describe_cluster_snapshots(): @mock_redshift def test_describe_cluster_snapshots_not_found_error(): client = boto3.client("redshift", region_name="us-east-1") - cluster_identifier = "my_cluster" - snapshot_identifier = "my_snapshot" + cluster_identifier = "non-existent-cluster-id" + snapshot_identifier = "non-existent-snapshot-id" - client.describe_cluster_snapshots.when.called_with( - ClusterIdentifier=cluster_identifier - ).should.throw(ClientError, "Cluster {} not found.".format(cluster_identifier)) + resp = client.describe_cluster_snapshots(ClusterIdentifier=cluster_identifier) + resp["Snapshots"].should.have.length_of(0) client.describe_cluster_snapshots.when.called_with( SnapshotIdentifier=snapshot_identifier