RDS - Fix KeyError on describe_db_clusters for non-existent cluster (#5321)
This commit is contained in:
parent
004c971a27
commit
42b11bbe14
@ -1801,6 +1801,8 @@ class RDSBackend(BaseBackend):
|
||||
|
||||
def describe_db_clusters(self, cluster_identifier):
|
||||
if cluster_identifier:
|
||||
if cluster_identifier not in self.clusters:
|
||||
raise DBClusterNotFoundError(cluster_identifier)
|
||||
return [self.clusters[cluster_identifier]]
|
||||
return self.clusters.values()
|
||||
|
||||
|
@ -15,6 +15,19 @@ def test_describe_db_cluster_initial():
|
||||
resp.should.have.key("DBClusters").should.have.length_of(0)
|
||||
|
||||
|
||||
@mock_rds
|
||||
def test_describe_db_cluster_fails_for_non_existent_cluster():
|
||||
client = boto3.client("rds", region_name="eu-north-1")
|
||||
|
||||
resp = client.describe_db_clusters()
|
||||
resp.should.have.key("DBClusters").should.have.length_of(0)
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.describe_db_clusters(DBClusterIdentifier="cluster-id")
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("DBClusterNotFoundFault")
|
||||
err["Message"].should.equal("DBCluster cluster-id not found.")
|
||||
|
||||
|
||||
@mock_rds
|
||||
def test_create_db_cluster_needs_master_username():
|
||||
client = boto3.client("rds", region_name="eu-north-1")
|
||||
|
Loading…
Reference in New Issue
Block a user