Skip to content

Commit

Permalink
fixed tf-tests: TestAccRoute53Zone, TestAccRoute53ZoneDataSource (#5229)
Browse files Browse the repository at this point in the history
  • Loading branch information
macnev2013 committed Jun 15, 2022
1 parent 00f9b47 commit b66e04f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
3 changes: 1 addition & 2 deletions moto/route53/models.py
Expand Up @@ -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()},
}
Expand Down
6 changes: 3 additions & 3 deletions moto/route53/responses.py
Expand Up @@ -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)
Expand Down Expand Up @@ -825,7 +825,7 @@ def reusable_delegation_set(self, request, full_url, headers):
ASSOCIATE_VPC_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>
<AssociateVPCWithHostedZoneResponse>
<ChangeInfo>
<Comment>{{ comment }}</Comment>
<Comment>{{ comment or "" }}</Comment>
<Id>/change/a1b2c3d4</Id>
<Status>INSYNC</Status>
<SubmittedAt>2017-03-31T01:36:41.958Z</SubmittedAt>
Expand All @@ -836,7 +836,7 @@ def reusable_delegation_set(self, request, full_url, headers):
DISASSOCIATE_VPC_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>
<DisassociateVPCFromHostedZoneResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<ChangeInfo>
<Comment>{{ comment }}</Comment>
<Comment>{{ comment or "" }}</Comment>
<Id>/change/a1b2c3d4</Id>
<Status>INSYNC</Status>
<SubmittedAt>2017-03-31T01:36:41.958Z</SubmittedAt>
Expand Down
5 changes: 5 additions & 0 deletions tests/terraformtests/terraform-tests.success.txt
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions tests/test_route53/test_route53.py
Expand Up @@ -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"])


Expand Down Expand Up @@ -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"])

Expand Down

0 comments on commit b66e04f

Please sign in to comment.