Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test case to test verify mailto:// parsing #991

Merged
merged 1 commit into from
Nov 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions test/test_plugin_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -1584,3 +1584,38 @@ def test_plugin_email_plus_in_toemail(mock_smtp, mock_smtp_ssl):
assert len(_to) == 1
assert _to[0] == '[email protected]'
assert _msg.split('\n')[-3] == 'test'


@mock.patch('smtplib.SMTP_SSL')
@mock.patch('smtplib.SMTP')
def test_plugin_email_formatting_990(mock_smtp, mock_smtp_ssl):
"""
NotifyEmail() GitHub Issue 990
https://github.com/caronc/apprise/issues/990
Email formatting not working correctly

"""

response = mock.Mock()
mock_smtp_ssl.return_value = response
mock_smtp.return_value = response

results = NotifyEmail.parse_url(
'mailtos://mydomain.com?smtp=mail.local.mydomain.com'
'&[email protected]&pass=mypassword'
'&[email protected]&[email protected]&mode=ssl&port=465')

assert isinstance(results, dict)
assert '[email protected]' == results['user']
assert 'mydomain.com' == results['host']
assert 'mail.local.mydomain.com' == results['smtp_host']
assert 'mypassword' == results['password']
assert 'ssl' == results['secure_mode']
assert '465' == results['port']
assert '[email protected]' in results['targets']

obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True

assert len(obj.targets) == 1
assert (False, '[email protected]') in obj.targets