Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests for spam check #692

Merged
merged 2 commits into from
Oct 22, 2018
Merged
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
40 changes: 40 additions & 0 deletions test/test_spam_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from sendgrid.helpers.mail.spam_check import SpamCheck

try:
import unittest2 as unittest
except ImportError:
import unittest


class UnitTests(unittest.TestCase):

def test_spam_all_values(self):
expected = {'enable': True, 'threshold': 5, 'post_to_url': 'https://www.test.com'}
spam_check = SpamCheck(enable=True, threshold=5, post_to_url='https://www.test.com')
self.assertEqual(spam_check.get(), expected)

def test_spam_no_url(self):
expected = {'enable': True, 'threshold': 10}
spam_check = SpamCheck(enable=True, threshold=10)
self.assertEqual(spam_check.get(), expected)

def test_spam_no_threshold(self):
expected = {'enable': True}
spam_check = SpamCheck(enable=True)
self.assertEqual(spam_check.get(), expected)

def test_has_values_but_not_enabled(self):
expected = {'enable': False, 'threshold': 1, 'post_to_url': 'https://www.test.com'}
spam_check = SpamCheck(enable=False, threshold=1, post_to_url='https://www.test.com')
self.assertEqual(spam_check.get(), expected)

def test_spam_change_properties(self):
"""Tests changing the properties of the spam check class"""

expected = {'enable': False, 'threshold': 10, 'post_to_url': 'https://www.testing.com'}
spam_check = SpamCheck(enable=True, threshold=5, post_to_url='https://www.test.com')
spam_check.enable = False
spam_check.threshold = 10
spam_check.post_to_url = 'https://www.testing.com'
self.assertEqual(spam_check.get(), expected)