-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathemails_tests.py
53 lines (43 loc) · 1.6 KB
/
emails_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# tests.emails_tests
# Testing for the emails module in Tribe
#
# Author: Benjamin Bengfort <[email protected]>
# Created: Thu Nov 13 15:20:41 2014 -0500
#
# Copyright (C) 2014 District Data Labs
# For license information, see LICENSE.txt
#
# ID: emails_tests.py [5232e54] [email protected] $
"""
Testing for the utilities library in Tribe
"""
##########################################################################
## Imports
##########################################################################
import unittest
from tribe.emails import *
from builtins import str as text
##########################################################################
## EmailAddress Tests
##########################################################################
class EmailAddressTests(unittest.TestCase):
def test_full_email_parse(self):
"""
Assert a full email is parsed correctly
"""
data = "Benjamin Bengfort <[email protected]>"
email = EmailAddress(data)
self.assertEqual(email.name, "Benjamin Bengfort")
self.assertEqual(email.email, "[email protected]")
self.assertEqual(email.domain, "bengfort.com")
self.assertEqual(text(email), data)
def test_partial_email_parse(self):
"""
Assert a standalone email is parsed correctly
"""
data = "[email protected]"
email = EmailAddress(data)
self.assertEqual(email.name, "")
self.assertEqual(email.email, "[email protected]")
self.assertEqual(email.domain, "bengfort.com")
self.assertEqual(text(email), data)