Skip to content

Commit f16934c

Browse files
committed
Route53: update_health_check() should handle falsy values correctly
1 parent b4f8b78 commit f16934c

2 files changed

Lines changed: 23 additions & 20 deletions

File tree

moto/route53/models.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -848,31 +848,31 @@ def update_health_check(
848848
if not health_check:
849849
raise NoSuchHealthCheck(health_check_id)
850850

851-
if health_check_args.get("ip_address"):
851+
if health_check_args.get("ip_address") is not None:
852852
health_check.ip_address = health_check_args.get("ip_address")
853-
if health_check_args.get("port"):
853+
if health_check_args.get("port") is not None:
854854
health_check.port = health_check_args.get("port")
855-
if health_check_args.get("resource_path"):
855+
if health_check_args.get("resource_path") is not None:
856856
health_check.resource_path = health_check_args.get("resource_path")
857-
if health_check_args.get("fqdn"):
857+
if health_check_args.get("fqdn") is not None:
858858
health_check.fqdn = health_check_args.get("fqdn")
859-
if health_check_args.get("search_string"):
859+
if health_check_args.get("search_string") is not None:
860860
health_check.search_string = health_check_args.get("search_string")
861-
if health_check_args.get("request_interval"):
861+
if health_check_args.get("request_interval") is not None:
862862
health_check.request_interval = health_check_args.get("request_interval")
863-
if health_check_args.get("failure_threshold"):
863+
if health_check_args.get("failure_threshold") is not None:
864864
health_check.failure_threshold = health_check_args.get("failure_threshold")
865-
if health_check_args.get("health_threshold"):
865+
if health_check_args.get("health_threshold") is not None:
866866
health_check.health_threshold = health_check_args.get("health_threshold")
867-
if health_check_args.get("inverted"):
867+
if health_check_args.get("inverted") is not None:
868868
health_check.inverted = health_check_args.get("inverted")
869-
if health_check_args.get("disabled"):
869+
if health_check_args.get("disabled") is not None:
870870
health_check.disabled = health_check_args.get("disabled")
871-
if health_check_args.get("enable_sni"):
871+
if health_check_args.get("enable_sni") is not None:
872872
health_check.enable_sni = health_check_args.get("enable_sni")
873-
if health_check_args.get("children"):
873+
if health_check_args.get("children") is not None:
874874
health_check.set_children(health_check_args.get("children", []))
875-
if health_check_args.get("regions"):
875+
if health_check_args.get("regions") is not None:
876876
health_check.set_regions(health_check_args.get("regions", []))
877877

878878
return health_check

tests/test_route53/test_route53_healthchecks.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,16 @@ def test_delete_health_checks():
248248

249249

250250
@mock_aws
251-
def test_update_health_check():
251+
@pytest.mark.parametrize("original_value", [True, False])
252+
def test_update_health_check(original_value):
252253
client = boto3.client("route53", region_name="us-east-1")
253254

254255
hc_id = client.create_health_check(
255256
CallerReference="callref",
256257
HealthCheckConfig={
257258
"Type": "CALCULATED",
258-
"Inverted": False,
259-
"Disabled": False,
259+
"Inverted": original_value,
260+
"Disabled": original_value,
260261
"HealthThreshold": 1,
261262
},
262263
)["HealthCheck"]["Id"]
@@ -269,8 +270,9 @@ def test_update_health_check():
269270
FullyQualifiedDomainName="example.com",
270271
SearchString="search",
271272
FailureThreshold=123,
272-
Inverted=False,
273-
Disabled=False,
273+
Inverted=not original_value,
274+
Disabled=not original_value,
275+
EnableSNI=not original_value,
274276
HealthThreshold=13,
275277
ChildHealthChecks=["child"],
276278
Regions=["us-east-1", "us-east-2", "us-west-1"],
@@ -283,8 +285,9 @@ def test_update_health_check():
283285
assert config["ResourcePath"] == "rp"
284286
assert config["FullyQualifiedDomainName"] == "example.com"
285287
assert config["SearchString"] == "search"
286-
assert config["Inverted"] is False
287-
assert config["Disabled"] is False
288+
assert config["Inverted"] is not original_value
289+
assert config["Disabled"] is not original_value
290+
assert config["EnableSNI"] is not original_value
288291
assert config["ChildHealthChecks"] == ["child"]
289292
assert config["Regions"] == ["us-east-1", "us-east-2", "us-west-1"]
290293

0 commit comments

Comments
 (0)