diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..ceeea23 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include VERSION diff --git a/README.md b/README.md index b2b8989..6cc333f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/VERSION b/VERSION index 7ec1d6d..4a36342 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.1.0 +3.0.0 diff --git a/emailable/client.py b/emailable/client.py index b8bf656..d73b79c 100644 --- a/emailable/client.py +++ b/emailable/client.py @@ -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 diff --git a/tests/test_client.py b/tests/test_client.py index 1b0e348..f0b1c3a 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -5,8 +5,7 @@ class TestClient(TestCase): def setUp(self): self.client = emailable.Client('test_7aff7fc0142c65f86a00') - self.response = self.client.verify('johndoe+tag@emailable.com') - time.sleep(0.25) + time.sleep(0.5) def test_invalid_api_key(self): client = emailable.Client('test_7aff7fc0141c65f86a00') @@ -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('johndoe+tag@emailable.com') + self.assertIsInstance(response, emailable.Response) def test_verification_role(self): response = self.client.verify('role@example.com') @@ -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('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 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( ['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'], + {'callback_url': 'test@example.org', 'simulate': 'generic_error'} + ) def test_batch_status(self): response = self.client.batch(