Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
lfir committed Nov 2, 2021
1 parent dc1121d commit efa3898
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/test_mail_error_notifs.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import io
import os
import unittest
from os import remove
from unittest.mock import Mock, patch

from dotenv import load_dotenv
from mail_error_notifs.mail_error_notifs import SendGridAPIClient, send_email


class TestScripts(unittest.TestCase):
testenvpath = "./tests/.testenv"

def test_when_env_file_present_environment_variables_can_be_read(self):
load_dotenv("./.env")
with open(TestScripts.testenvpath, "w") as fh:
fh.write("LOGDIR=/root")

load_dotenv(TestScripts.testenvpath)

self.assertIsNotNone(os.getenv("LOGDIR"))

@patch("sys.stdout", new_callable=io.StringIO)
Expand All @@ -33,3 +40,7 @@ def mockinit(self, apikey):
send_email("TestCase subject", "TestCase body")

self.assertIn(err_msg, " ".join(cm.output))

@classmethod
def tearDownClass(cls):
remove(TestScripts.testenvpath)

0 comments on commit efa3898

Please sign in to comment.