Skip to content

Commit

Permalink
Improve code coverage with a domain that returns NOANSWER instead of …
Browse files Browse the repository at this point in the history
…NXDOMAIN
  • Loading branch information
JoshData committed Nov 22, 2023
1 parent 6e825bf commit 044039d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
24 changes: 24 additions & 0 deletions tests/mocked-dns-answers.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,30 @@
"\"v=spf1 -all\""
]
},
{
"query": {
"name": "justtxt.joshdata.me",
"type": "MX",
"class": "IN"
},
"answer": []
},
{
"query": {
"name": "justtxt.joshdata.me",
"type": "A",
"class": "IN"
},
"answer": []
},
{
"query": {
"name": "justtxt.joshdata.me",
"type": "AAAA",
"class": "IN"
},
"answer": []
},
{
"query": {
"name": "mail.example",
Expand Down
7 changes: 6 additions & 1 deletion tests/test_deliverability.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_deliverability_found():


def test_deliverability_fails():
# No MX record.
# Domain does not exist.
domain = 'xkxufoekjvjfjeodlfmdfjcu.com'
with pytest.raises(EmailUndeliverableError, match=f'The domain name {domain} does not exist'):
validate_email_deliverability(domain, domain, dns_resolver=RESOLVER)
Expand All @@ -36,6 +36,11 @@ def test_deliverability_fails():
with pytest.raises(EmailUndeliverableError, match=f'The domain name {domain} does not send email'):
validate_email_deliverability(domain, domain, dns_resolver=RESOLVER)

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

@pytest.mark.parametrize(
'email_input',
Expand Down

0 comments on commit 044039d

Please sign in to comment.