Skip to content

Commit 22c5b05

Browse files
Merge pull request #692 from pyasi/add-tests-for-spam-check
Add unit tests for spam check
2 parents 0b68316 + 0f7e836 commit 22c5b05

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/test_spam_check.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
"""Tests changing the properties of the spam check class"""
33+
34+
expected = {'enable': False, 'threshold': 10, 'post_to_url': 'https://www.testing.com'}
35+
spam_check = SpamCheck(enable=True, threshold=5, post_to_url='https://www.test.com')
36+
spam_check.enable = False
37+
spam_check.threshold = 10
38+
spam_check.post_to_url = 'https://www.testing.com'
39+
self.assertEqual(spam_check.get(), expected)
40+

0 commit comments

Comments
 (0)