Skip to content

Commit

Permalink
Merge branch 'release/3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
eberquist committed Mar 16, 2022
2 parents e23b187 + 5296ce9 commit a00b2f0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include VERSION
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ response.id

# you can optionally pass in a callback url that we'll POST to when the
# batch is complete.
response = client.batch(emails, callback_url='https://emailable.com/')
response = client.batch(emails, {'callback_url': 'https://emailable.com/'})
```

#### Get the status / results of a batch
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
3.0.0
7 changes: 3 additions & 4 deletions emailable/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ def verify(self, email, smtp=True, accept_all=False, timeout=None):
url = self.base_url + 'verify'
return self.__request('get', url, options)

def batch(self, emails, callback_url=None, simulate=None):
def batch(self, emails, params={}):
options = {
'params': {
'api_key': self.api_key,
'url': callback_url,
'simulate': simulate
**{'api_key': self.api_key},
**params
},
'json': {
'emails': emails
Expand Down
35 changes: 22 additions & 13 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
class TestClient(TestCase):
def setUp(self):
self.client = emailable.Client('test_7aff7fc0142c65f86a00')
self.response = self.client.verify('[email protected]')
time.sleep(0.25)
time.sleep(0.5)

def test_invalid_api_key(self):
client = emailable.Client('test_7aff7fc0141c65f86a00')
Expand All @@ -25,7 +24,8 @@ def test_missing_api_key(self):
)

def test_verify_returns_response(self):
self.assertIsInstance(self.response, emailable.Response)
response = self.client.verify('[email protected]')
self.assertIsInstance(response, emailable.Response)

def test_verification_role(self):
response = self.client.verify('[email protected]')
Expand All @@ -36,26 +36,35 @@ def test_verification_deliverable(self):
self.assertEqual(response.state, 'deliverable')

def test_verification_tag(self):
self.assertEqual(self.response.tag, 'tag')
response = self.client.verify('[email protected]')
self.assertEqual(response.tag, 'tag')

def test_verification_name_and_gender(self):
response = self.client.verify('[email protected]')
# name and gender checks only get run for certain verification states
if self.response.state in ['deliverable', 'risky', 'unknown']:
self.assertEqual(self.response.first_name, 'John')
self.assertEqual(self.response.last_name, 'Doe')
self.assertEqual(self.response.full_name, 'John Doe')
self.assertEqual(self.response.gender, 'male')
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(self.response.first_name)
self.assertIsNone(self.response.last_name)
self.assertIsNone(self.response.full_name)
self.assertIsNone(self.response.gender)
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(
['[email protected]', '[email protected]']
)
self.assertIsNotNone(response.id)

def test_batch_creation_with_params(self):
with self.assertRaises(emailable.error.ClientError):
self.client.batch(
['[email protected]', '[email protected]'],
{'callback_url': '[email protected]', 'simulate': 'generic_error'}
)

def test_batch_status(self):
response = self.client.batch(
Expand Down

0 comments on commit a00b2f0

Please sign in to comment.