diff --git a/notify/mail.py b/notify/mail.py index cb88116..8142c2c 100644 --- a/notify/mail.py +++ b/notify/mail.py @@ -46,7 +46,7 @@ def __init__( e-mail address to add as cc bcc: str e-mail address to add as bcc - files: str, list + files: str, dict Path(s) to file(s) to add as attachment df: pd.DataFrame dataframe that needs to be added to the HTML message. @@ -59,7 +59,7 @@ def __init__( self.bcc = bcc.replace(";", ",") if bcc is not None else bcc self.subject = subject self.message = message - self.files = [files] if isinstance(files, str) else files + self.files = {files.split("/")[-1]: files} if isinstance(files, str) else files self.df = df self.graph = Graph() self.graph.ensure_graph_for_app_only_auth() diff --git a/notify/tests/test_email.py b/notify/tests/test_email.py index be48308..4a95233 100644 --- a/notify/tests/test_email.py +++ b/notify/tests/test_email.py @@ -78,6 +78,22 @@ def test_send_file(): assert response +def test_send_multiple_files(): + message = "This is a test from notify for multiple files" + subject = "Test Notify multiple files" + core_file_name = "2010 car efficiency" + file_name_1 = f"{core_file_name}_1.csv" + file_name_2 = f"{core_file_name}_2.csv" + file_path = os.path.join("notify", "tests", "data", f"{core_file_name}.csv") + response = NotifyMail( + to=f"{os.environ.get('TEST_EMAIL_1')}", + subject=subject, + message=message, + files={file_name_1: file_path, file_name_2: file_path}, + ).send_email() + assert response.status_code == 202 + + def test_send_file_from_storage(): message = "This is a test from notify" subject = "Test Notify file Azure Storage" diff --git a/setup.cfg b/setup.cfg index 1bb9612..f88fcda 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = zyppnotify -version = 1.0.1 +version = 1.1.0 author = Zypp author_email = hello@zypp.io description = Send users notifications through various platforms