Skip to content

Commit 8aa9223

Browse files
committed
Improve code coverage with a domain that returns NOANSWER instead of NXDOMAIN
1 parent 6e825bf commit 8aa9223

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

tests/mocked-dns-answers.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,30 @@
6060
"\"v=spf1 -all\""
6161
]
6262
},
63+
{
64+
"query": {
65+
"name": "justtxt.joshdata.me",
66+
"type": "MX",
67+
"class": "IN"
68+
},
69+
"answer": []
70+
},
71+
{
72+
"query": {
73+
"name": "justtxt.joshdata.me",
74+
"type": "A",
75+
"class": "IN"
76+
},
77+
"answer": []
78+
},
79+
{
80+
"query": {
81+
"name": "justtxt.joshdata.me",
82+
"type": "AAAA",
83+
"class": "IN"
84+
},
85+
"answer": []
86+
},
6387
{
6488
"query": {
6589
"name": "mail.example",

tests/test_deliverability.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_deliverability_found():
2121

2222

2323
def test_deliverability_fails():
24-
# No MX record.
24+
# Domain does not exist.
2525
domain = 'xkxufoekjvjfjeodlfmdfjcu.com'
2626
with pytest.raises(EmailUndeliverableError, match=f'The domain name {domain} does not exist'):
2727
validate_email_deliverability(domain, domain, dns_resolver=RESOLVER)
@@ -36,6 +36,12 @@ def test_deliverability_fails():
3636
with pytest.raises(EmailUndeliverableError, match=f'The domain name {domain} does not send email'):
3737
validate_email_deliverability(domain, domain, dns_resolver=RESOLVER)
3838

39+
# No MX or A/AAAA records, but some other DNS records must
40+
# exist such that the response is NOANSWER instead of NXDOMAIN.
41+
domain = 'justtxt.joshdata.me'
42+
with pytest.raises(EmailUndeliverableError, match=f'The domain name {domain} does not accept email'):
43+
validate_email_deliverability(domain, domain, dns_resolver=RESOLVER)
44+
3945

4046
@pytest.mark.parametrize(
4147
'email_input',

0 commit comments

Comments
 (0)