mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
![]() |
import unittest
|
||
|
import json
|
||
|
import jc.parsers.email_address
|
||
|
|
||
|
|
||
|
class MyTests(unittest.TestCase):
|
||
|
def test_email_address_nodata(self):
|
||
|
"""
|
||
|
Test 'email_address' with no data
|
||
|
"""
|
||
|
self.assertEqual(jc.parsers.email_address.parse('', quiet=True), {})
|
||
|
|
||
|
|
||
|
def test_simple_email(self):
|
||
|
"""
|
||
|
Test simple email address
|
||
|
"""
|
||
|
data = r'fred@example.com'
|
||
|
expected = json.loads(r'''{"domain":"example.com","local":"fred","local_plus_prefix":null,"local_plus_suffix":null}''')
|
||
|
self.assertEqual(jc.parsers.email_address.parse(data, quiet=True), expected)
|
||
|
|
||
|
|
||
|
def test_plus_email(self):
|
||
|
"""
|
||
|
Test email address with plus syntax
|
||
|
"""
|
||
|
data = r'fred+spam@example.com'
|
||
|
expected = json.loads(r'''{"domain":"example.com","local":"fred+spam","local_plus_prefix":"fred","local_plus_suffix":"spam"}''')
|
||
|
self.assertEqual(jc.parsers.email_address.parse(data, quiet=True), expected)
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
unittest.main()
|