From b66e04ffd52b4cfdd95d22cd7253bc78dd70f595 Mon Sep 17 00:00:00 2001 From: Macwan Nevil Date: Thu, 16 Jun 2022 01:31:11 +0530 Subject: [PATCH] fixed tf-tests: TestAccRoute53Zone, TestAccRoute53ZoneDataSource (#5229) --- moto/route53/models.py | 3 +-- moto/route53/responses.py | 6 +++--- tests/terraformtests/terraform-tests.success.txt | 5 +++++ tests/test_route53/test_route53.py | 6 ++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/moto/route53/models.py b/moto/route53/models.py index b232eb2e1ca..e420b1c8abb 100644 --- a/moto/route53/models.py +++ b/moto/route53/models.py @@ -575,10 +575,9 @@ def list_hosted_zones_by_vpc(self, vpc_id): this_zone = self.get_hosted_zone(zone.id) for vpc in this_zone.vpcs: if vpc["vpc_id"] == vpc_id: - this_id = f"/hostedzone/{zone.id}" zone_list.append( { - "HostedZoneId": this_id, + "HostedZoneId": zone.id, "Name": zone.name, "Owner": {"OwningAccount": get_account_id()}, } diff --git a/moto/route53/responses.py b/moto/route53/responses.py index 0bff963b2a1..81bae77e17f 100644 --- a/moto/route53/responses.py +++ b/moto/route53/responses.py @@ -172,7 +172,7 @@ def disassociate_vpc_response(self, request, full_url, headers): route53_backend.disassociate_vpc(zoneid, vpcid) template = Template(DISASSOCIATE_VPC_RESPONSE) - return 200, headers, template.render(comment) + return 200, headers, template.render(comment=comment) def rrset_response(self, request, full_url, headers): self.setup_class(request, full_url, headers) @@ -825,7 +825,7 @@ def reusable_delegation_set(self, request, full_url, headers): ASSOCIATE_VPC_RESPONSE = """ - {{ comment }} + {{ comment or "" }} /change/a1b2c3d4 INSYNC 2017-03-31T01:36:41.958Z @@ -836,7 +836,7 @@ def reusable_delegation_set(self, request, full_url, headers): DISASSOCIATE_VPC_RESPONSE = """ - {{ comment }} + {{ comment or "" }} /change/a1b2c3d4 INSYNC 2017-03-31T01:36:41.958Z diff --git a/tests/terraformtests/terraform-tests.success.txt b/tests/terraformtests/terraform-tests.success.txt index 247b1c76a7e..45fa316af54 100644 --- a/tests/terraformtests/terraform-tests.success.txt +++ b/tests/terraformtests/terraform-tests.success.txt @@ -174,6 +174,11 @@ route53: - TestAccRoute53Zone_VPC_single - TestAccRoute53Zone_VPC_multiple - TestAccRoute53Zone_VPC_updates + - TestAccRoute53ZoneAssociation + - TestAccRoute53ZoneDataSource_id + - TestAccRoute53ZoneDataSource_name + - TestAccRoute53ZoneDataSource_tags + - TestAccRoute53ZoneDataSource_vpc s3: - TestAccS3BucketPolicy - TestAccS3BucketPublicAccessBlock diff --git a/tests/test_route53/test_route53.py b/tests/test_route53/test_route53.py index 695110b1d85..6a17b9ed057 100644 --- a/tests/test_route53/test_route53.py +++ b/tests/test_route53/test_route53.py @@ -752,13 +752,14 @@ def test_list_hosted_zones_by_vpc(): HostedZoneConfig=dict(PrivateZone=True, Comment="test com"), VPC={"VPCRegion": region, "VPCId": vpc_id}, ) + zone_id = zone_b["HostedZone"]["Id"].split("/")[2] response = conn.list_hosted_zones_by_vpc(VPCId=vpc_id, VPCRegion=region) response.should.have.key("ResponseMetadata") response.should.have.key("HostedZoneSummaries") response["HostedZoneSummaries"].should.have.length_of(1) response["HostedZoneSummaries"][0].should.have.key("HostedZoneId") retured_zone = response["HostedZoneSummaries"][0] - retured_zone["HostedZoneId"].should.equal(zone_b["HostedZone"]["Id"]) + retured_zone["HostedZoneId"].should.equal(zone_id) retured_zone["Name"].should.equal(zone_b["HostedZone"]["Name"]) @@ -792,8 +793,9 @@ def test_list_hosted_zones_by_vpc_with_multiple_vpcs(): for summary in response["HostedZoneSummaries"]: # use the zone name as the index index = summary["Name"].split(".")[1] + zone_id = zones[index]["HostedZone"]["Id"].split("/")[2] summary.should.have.key("HostedZoneId") - summary["HostedZoneId"].should.equal(zones[index]["HostedZone"]["Id"]) + summary["HostedZoneId"].should.equal(zone_id) summary.should.have.key("Name") summary["Name"].should.equal(zones[index]["HostedZone"]["Name"])