Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.

Commit a8a7214

Browse files
committed
Increase test coverage on senza domains
1 parent 71baafb commit a8a7214

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

tests/fixtures.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ def boto_client(monkeypatch):
122122
'TTL': 20,
123123
'Type': 'CNAME',
124124
'Weight': 20},
125+
{'Name': 'test-2.example.org.',
126+
'AliasTarget': {'DNSName': 'test-2-123.myregion.elb.amazonaws.com'},
127+
'TTL': 20,
128+
'Type': 'A'},
125129
]}
126130

127131
def my_client(rtype, *args, **kwargs):
@@ -157,6 +161,27 @@ def my_client(rtype, *args, **kwargs):
157161
@pytest.fixture
158162
def boto_resource(monkeypatch):
159163
def my_resource(rtype, *args):
164+
if rtype == 'cloudformation':
165+
res = MagicMock()
166+
res.resource_type = 'AWS::Route53::RecordSet'
167+
res.physical_resource_id = 'test-1.example.org'
168+
res.logical_id = 'VersionDomain'
169+
res.last_updated_timestamp = datetime.now()
170+
res2 = MagicMock()
171+
res2.resource_type = 'AWS::Route53::RecordSet'
172+
res2.physical_resource_id = 'mydomain.example.org'
173+
res2.logical_id = 'MainDomain'
174+
res2.last_updated_timestamp = datetime.now()
175+
res3 = MagicMock()
176+
res3.resource_type = 'AWS::Route53::RecordSet'
177+
res3.physical_resource_id = 'test-2.example.org'
178+
res3.logical_id = 'VersionDomain'
179+
res3.last_updated_timestamp = datetime.now()
180+
stack = MagicMock()
181+
stack.resource_summaries.all.return_value = [res, res2, res3]
182+
cf = MagicMock()
183+
cf.Stack.return_value = stack
184+
return cf
160185
if rtype == 'ec2':
161186
ec2 = MagicMock()
162187
ec2.security_groups.filter.return_value = [

tests/test_cli.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -795,33 +795,12 @@ def my_client(rtype, *args):
795795
assert 'Resource Type' in result.output
796796

797797

798-
def test_domains(monkeypatch, boto_client):
798+
def test_domains(monkeypatch, boto_resource, boto_client):
799799
senza.traffic.DNS_ZONE_CACHE = {}
800800
senza.traffic.DNS_RR_CACHE = {}
801801

802-
def my_resource(rtype, *args):
803-
if rtype == 'cloudformation':
804-
res = MagicMock()
805-
res.resource_type = 'AWS::Route53::RecordSet'
806-
res.physical_resource_id = 'test-1.example.org'
807-
res.logical_id = 'VersionDomain'
808-
res.last_updated_timestamp = datetime.datetime.now()
809-
res2 = MagicMock()
810-
res2.resource_type = 'AWS::Route53::RecordSet'
811-
res2.physical_resource_id = 'mydomain.example.org'
812-
res2.logical_id = 'MainDomain'
813-
res2.last_updated_timestamp = datetime.datetime.now()
814-
stack = MagicMock()
815-
stack.resource_summaries.all.return_value = [res, res2]
816-
cf = MagicMock()
817-
cf.Stack.return_value = stack
818-
return cf
819-
return MagicMock()
820-
821802
boto_client['route53'].list_hosted_zones.return_value = {'HostedZones': [HOSTED_ZONE_EXAMPLE_ORG]}
822803

823-
monkeypatch.setattr('boto3.resource', my_resource)
824-
825804
runner = CliRunner()
826805

827806
data = {'SenzaInfo': {'StackName': 'test',
@@ -834,6 +813,7 @@ def my_resource(rtype, *args):
834813
catch_exceptions=False)
835814
assert 'mydomain.example.org' in result.output
836815
assert 'VersionDomain test-1.example.org CNAME test-1-123.myregion.elb.amazonaws.com' in result.output
816+
assert 'VersionDomain test-2.example.org A test-2-123.myregion.elb.amazonaws.com' in result.output
837817
assert 'MainDomain mydomain.example.org 20 CNAME test-1.example.org' in result.output
838818

839819

0 commit comments

Comments
 (0)