-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_emailer.py
57 lines (44 loc) · 1.47 KB
/
test_emailer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from pyhousehunter import emailer
import pandas as pd
from pytest import raises
# Toy data for tests
toy_data = pd.read_csv("tests/toy.csv")
empty_data = pd.DataFrame()
# Tests on input
def test_invalid_email_type():
"""
Test to confirm that ValueError is raised when wrong email address is provided.
"""
with raises(TypeError):
emailer.send_email(123, toy_data)
def test_invalid_email_value():
"""
Test to confirm that ValueError is raised when wrong email address is provided.
"""
with raises(ValueError):
emailer.send_email("ela.com", toy_data)
emailer.send_email("ela", toy_data)
def test_invalid_subject_type():
"""
Test to confirm that TypeError is raised when wrong type if provided for subject.
"""
with raises(TypeError):
emailer.send_email("elabandari@gmail.com", 123)
def test_invalid_dataframe():
"""
Test to confirm that TypeError is raised when dataframe is the wrong object type.
"""
with raises(TypeError):
emailer.send_email("elabandari@gmail.com", 123)
def test_dataframe_empty():
"""
Test to confirm that ValueError is raised when dataframe is empty.
"""
with raises(ValueError):
emailer.send_email("elabandari@gmail.com", empty_data)
# Tests on output
def test_email_sent_return_none():
"""
Test to confirm that email has been sent and function returns None.
"""
assert emailer.send_email("elabandari@gmail.com", toy_data) is None