Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion smtpapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ def __init__(self):
def add_to(self, to):
if 'to' not in self.data:
self.data['to'] = []
self.data['to'].append(to)
if type(to) is list:
self.data['to'] += to
else:
self.data['to'].append(to)

def set_tos(self, tos):
self.data['to'] = tos
Expand Down
6 changes: 4 additions & 2 deletions test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
class TestSMTPAPI(unittest.TestCase):

def setUp(self):
self.validHeader = json.loads('''{"to":["[email protected]"],
self.validHeader = json.loads('''{"to":["[email protected]",
"[email protected]", "[email protected]"],
"sub":{"subKey":["subValue"]},
"section":{"testSection":"sectionValue"},
"category":["testCategory"],
Expand All @@ -21,6 +22,7 @@ def setUp(self):
def test_add(self):
header = SMTPAPIHeader()
header.add_to('[email protected]')
header.add_to(['[email protected]', '[email protected]'])
header.add_substitution('subKey', 'subValue')
header.add_section('testSection', 'sectionValue')
header.add_category('testCategory')
Expand All @@ -30,7 +32,7 @@ def test_add(self):

def test_set(self):
header = SMTPAPIHeader()
header.set_tos(["[email protected]"])
header.set_tos(["[email protected]", "[email protected]", "[email protected]"])
header.set_substitutions(json.loads('{"subKey":["subValue"]}'))
header.set_sections(json.loads('{"testSection":"sectionValue"}'))
header.set_categories(["testCategory"])
Expand Down