Skip to content

Commit 3363e01

Browse files
committed
Add unit tests for spam check
1 parent 0b68316 commit 3363e01

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/test_spam_check.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from sendgrid.helpers.mail.spam_check import SpamCheck
2+
3+
try:
4+
import unittest2 as unittest
5+
except ImportError:
6+
import unittest
7+
8+
9+
class UnitTests(unittest.TestCase):
10+
11+
def test_spam_all_values(self):
12+
expected = {'enable': True, 'threshold': 5, 'post_to_url': 'https://www.test.com'}
13+
spam_check = SpamCheck(enable=True, threshold=5, post_to_url='https://www.test.com')
14+
self.assertEqual(spam_check.get(), expected)
15+
16+
def test_spam_no_url(self):
17+
expected = {'enable': True, 'threshold': 10}
18+
spam_check = SpamCheck(enable=True, threshold=10)
19+
self.assertEqual(spam_check.get(), expected)
20+
21+
def test_spam_no_threshold(self):
22+
expected = {'enable': True}
23+
spam_check = SpamCheck(enable=True)
24+
self.assertEqual(spam_check.get(), expected)
25+
26+
def test_has_values_but_not_enabled(self):
27+
expected = {'enable': False, 'threshold': 1, 'post_to_url': 'https://www.test.com'}
28+
spam_check = SpamCheck(enable=False, threshold=1, post_to_url='https://www.test.com')
29+
self.assertEqual(spam_check.get(), expected)
30+
31+
def test_spam_change_properties(self):
32+
expected = {'enable': False, 'threshold': 10, 'post_to_url': 'https://www.testing.com'}
33+
spam_check = SpamCheck(enable=True, threshold=5, post_to_url='https://www.test.com')
34+
spam_check.enable = False
35+
spam_check.threshold = 10
36+
spam_check.post_to_url = 'https://www.testing.com'
37+
self.assertEqual(spam_check.get(), expected)
38+

0 commit comments

Comments
 (0)