@@ -2088,3 +2088,102 @@ def test_remove_tags_from_resource():
20882088 assert len (resp ["TagList" ]) == 1
20892089 assert resp ["TagList" ][0 ]["Key" ] == "common-key"
20902090 assert resp ["TagList" ][0 ]["Value" ] == "common-tag"
2091+
2092+
2093+ @mock_aws
2094+ def test_modify_replication_group ():
2095+ client = boto3 .client ("elasticache" , region_name = "us-east-2" )
2096+
2097+ replication_group_id = "test-cluster-disabled"
2098+
2099+ resp = client .create_replication_group (
2100+ ReplicationGroupId = replication_group_id ,
2101+ ReplicationGroupDescription = "test replication group" ,
2102+ Engine = "redis" ,
2103+ CacheNodeType = "cache.t4g.micro" ,
2104+ AutomaticFailoverEnabled = False ,
2105+ MultiAZEnabled = False ,
2106+ SnapshotRetentionLimit = 0 ,
2107+ )
2108+ replication_group = resp ["ReplicationGroup" ]
2109+ assert replication_group ["Description" ] == "test replication group"
2110+ assert replication_group ["Engine" ] == "redis"
2111+ assert replication_group ["CacheNodeType" ] == "cache.t4g.micro"
2112+ assert replication_group ["AutomaticFailover" ] == "disabled"
2113+ assert replication_group ["MultiAZ" ] == "disabled"
2114+ assert replication_group ["SnapshotRetentionLimit" ] == 0
2115+
2116+ client .modify_replication_group (
2117+ ReplicationGroupId = replication_group_id ,
2118+ ReplicationGroupDescription = "test_modify_replication_group" ,
2119+ Engine = "test" ,
2120+ CacheNodeType = "cache.t4g.small" ,
2121+ AutomaticFailoverEnabled = True ,
2122+ MultiAZEnabled = True ,
2123+ SnapshotRetentionLimit = 1 ,
2124+ )
2125+ describe_resp = client .describe_replication_groups (
2126+ ReplicationGroupId = replication_group_id
2127+ )
2128+ replication_group = describe_resp ["ReplicationGroups" ][0 ]
2129+ assert replication_group ["Description" ] == "test_modify_replication_group"
2130+ assert replication_group ["Engine" ] == "test"
2131+ assert replication_group ["CacheNodeType" ] == "cache.t4g.small"
2132+ assert replication_group ["AutomaticFailover" ] == "enabled"
2133+ assert replication_group ["MultiAZ" ] == "enabled"
2134+ assert replication_group ["SnapshotRetentionLimit" ] == 1
2135+
2136+
2137+ @mock_aws
2138+ def test_modify_replication_group_only_description ():
2139+ client = boto3 .client ("elasticache" , region_name = "us-east-2" )
2140+
2141+ replication_group_id = "test-cluster-disabled"
2142+
2143+ resp = client .create_replication_group (
2144+ ReplicationGroupId = replication_group_id ,
2145+ ReplicationGroupDescription = "test replication group" ,
2146+ Engine = "redis" ,
2147+ CacheNodeType = "cache.t4g.micro" ,
2148+ AutomaticFailoverEnabled = False ,
2149+ MultiAZEnabled = False ,
2150+ SnapshotRetentionLimit = 0 ,
2151+ )
2152+ replication_group = resp ["ReplicationGroup" ]
2153+ assert replication_group ["Description" ] == "test replication group"
2154+ assert replication_group ["Engine" ] == "redis"
2155+ assert replication_group ["CacheNodeType" ] == "cache.t4g.micro"
2156+ assert replication_group ["AutomaticFailover" ] == "disabled"
2157+ assert replication_group ["MultiAZ" ] == "disabled"
2158+ assert replication_group ["SnapshotRetentionLimit" ] == 0
2159+
2160+ client .modify_replication_group (
2161+ ReplicationGroupId = replication_group_id ,
2162+ ReplicationGroupDescription = "test_modify_replication_group" ,
2163+ )
2164+ describe_resp = client .describe_replication_groups (
2165+ ReplicationGroupId = replication_group_id
2166+ )
2167+ replication_group = describe_resp ["ReplicationGroups" ][0 ]
2168+ assert replication_group ["Description" ] == "test_modify_replication_group"
2169+ assert replication_group ["Engine" ] == "redis"
2170+ assert replication_group ["CacheNodeType" ] == "cache.t4g.micro"
2171+ assert replication_group ["AutomaticFailover" ] == "disabled"
2172+ assert replication_group ["MultiAZ" ] == "disabled"
2173+ assert replication_group ["SnapshotRetentionLimit" ] == 0
2174+
2175+
2176+ @mock_aws
2177+ def test_modify_replication_group_not_found ():
2178+ client = boto3 .client ("elasticache" , region_name = "us-east-2" )
2179+
2180+ replication_group_id = "test-cluster-not-found"
2181+ with pytest .raises (ClientError ) as exc :
2182+ client .modify_replication_group (
2183+ ReplicationGroupId = replication_group_id ,
2184+ MultiAZEnabled = False ,
2185+ )
2186+ err = exc .value .response ["Error" ]
2187+
2188+ assert err ["Code" ] == "ReplicationGroupNotFoundFault"
2189+ assert err ["Message" ] == f"Replication group { replication_group_id } not found."
0 commit comments