1- import unittest
2- import json
1+ import unittest , json , decimal
32from smtpapi import SMTPAPIHeader
43
5-
64class TestSMTPAPI (unittest .TestCase ):
75
86 def setUp (self ):
97 self .
validHeader = json .
loads (
'''{"to":["[email protected] ", 10811- "sub":{"subKey":["subValue"]},
9+ "sub":{"subKey":["subValue"],"decimalKey":[1.23456789] },
1210 "section":{"testSection":"sectionValue"},
1311 "category":["testCategory"],
1412 "unique_args":{"testUnique":"uniqueValue"},
@@ -19,7 +17,7 @@ def setUp(self):
1917 "filters":{"testFilter":{"settings":{"filter":"filterValue"}}}}''' )
2018
2119 self .dropsHeader = json .loads ('''{
22- "sub":{"subKey":["subValue"]},
20+ "sub":{"subKey":["subValue"],"decimalKey":[1.23456789] },
2321 "unique_args":{"testUnique":"uniqueValue"},
2422 "filters":{"testFilter":{"settings":{"filter":"filterValue"}}}}''' )
2523
@@ -28,6 +26,7 @@ def test_add(self):
2826 header .
add_to (
'[email protected] ' )
29273028 header .add_substitution ('subKey' , 'subValue' )
29+ header .add_substitution ('decimalKey' , decimal .Decimal ("1.23456789" ))
3130 header .add_section ('testSection' , 'sectionValue' )
3231 header .add_category ('testCategory' )
3332 header .add_unique_arg ('testUnique' , 'uniqueValue' )
@@ -42,7 +41,10 @@ def test_add(self):
4241 def test_set (self ):
4342 header = SMTPAPIHeader ()
444345- header .set_substitutions (json .loads ('{"subKey":["subValue"]}' ))
44+ header .set_substitutions ({
45+ "subKey" : ["subValue" ],
46+ "decimalKey" : [decimal .Decimal ("1.23456789" )]
47+ })
4648 header .set_sections (json .loads ('{"testSection":"sectionValue"}' ))
4749 header .set_categories (["testCategory" ])
4850 header .set_unique_args (json .loads ('{"testUnique":"uniqueValue"}' ))
@@ -56,7 +58,10 @@ def test_set(self):
5658 def test_drop_empty (self ):
5759 header = SMTPAPIHeader ()
5860 header .set_tos ([])
59- header .set_substitutions (json .loads ('{"subKey":["subValue"]}' ))
61+ header .set_substitutions ({
62+ "subKey" : ["subValue" ],
63+ "decimalKey" : [decimal .Decimal ("1.23456789" )]
64+ })
6065 header .set_sections (json .loads ('{}' ))
6166 header .set_categories ([])
6267 header .set_unique_args (json .loads ('{"testUnique":"uniqueValue"}' ))
0 commit comments