-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_client.py
More file actions
66 lines (56 loc) · 2.3 KB
/
test_client.py
File metadata and controls
66 lines (56 loc) · 2.3 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
from unittest import TestCase
import emailable
import time
class TestClient(TestCase):
def setUp(self):
self.client = emailable.Client('test_7aff7fc0142c65f86a00')
time.sleep(0.5)
def test_verify_returns_response(self):
response = self.client.verify('johndoe+tag@emailable.com')
self.assertIsInstance(response, emailable.Response)
def test_verification_role(self):
response = self.client.verify('role@example.com')
self.assertTrue(response.role)
def test_verification_deliverable(self):
response = self.client.verify('deliverable@example.com')
self.assertEqual(response.state, 'deliverable')
def test_verification_tag(self):
response = self.client.verify('johndoe+tag@emailable.com')
self.assertEqual(response.tag, 'tag')
def test_verification_name_and_gender(self):
response = self.client.verify('johndoe+tag@emailable.com')
# name and gender checks only get run for certain verification states
if response.state in ['deliverable', 'risky', 'unknown']:
self.assertEqual(response.first_name, 'John')
self.assertEqual(response.last_name, 'Doe')
self.assertEqual(response.full_name, 'John Doe')
self.assertEqual(response.gender, 'male')
else:
self.assertIsNone(response.first_name)
self.assertIsNone(response.last_name)
self.assertIsNone(response.full_name)
self.assertIsNone(response.gender)
def test_batch_creation(self):
response = self.client.batch(
['evan@emailable.com', 'jarrett@emailable.com']
)
self.assertIsNotNone(response.id)
def test_batch_creation_with_params(self):
with self.assertRaises(emailable.error.ClientError):
self.client.batch(
['evan@emailable.com', 'jarrett@emailable.com'],
{'url': 'test@example.org', 'simulate': 'generic_error'}
)
def test_batch_status(self):
response = self.client.batch(
['evan@emailable.com', 'jarrett@emailable.com']
)
response = self.client.batch_status(response.id)
self.assertIsNotNone(response.emails)
self.assertIsNotNone(response.id)
self.assertIsNotNone(response.reason_counts)
self.assertIsNotNone(response.total_counts)
def test_account(self):
response = self.client.account()
self.assertIsNotNone(response.owner_email)
self.assertIsNotNone(response.available_credits)