import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '../djagitit/mailing'))
import smtp
subject = 'Test email'
html = '
Test email
'
sender_good = 'matti.karjalainen@sonymusic.com'
sender_bad = 'matti'
cc = 'matti.karjalainen@sonymusic.com'
bcc = 'matti.karjalainen@sonymusic.com'
sender_alias = 'Data Team TEST'
reply_to = 'julien.comte@sonymusic.com'
filepath_attachment = os.path.abspath(__file__)
class TestSmtp:
@staticmethod
def test_send_good_email():
r = smtp.send_newsletter(subject, html, sender_good, cc=cc, bcc=bcc, sender_alias=sender_alias, reply_to=reply_to, attachments=filepath_attachment)
assert isinstance(r, dict), 'Function error, did not return a dict!'
assert r=={}, f'Mail sent, but an issue occured: {r}'
@staticmethod
def test_send_bad_email():
r = smtp.send_newsletter(subject, html, sender_bad, cc=cc)
assert isinstance(r, dict), 'Function error, did not return a dict!'
assert r!={}, 'No issue ocurred, even though expected!'