Skip to content

Commit 5cde236

Browse files
author
Guillaume Badi
committed
prepare testing and deployment
1 parent 3722f2b commit 5cde236

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: python
2+
3+
python:
4+
- "2.6"
5+
- "2.7"
6+
- "3.2"
7+
- "3.3"
8+
- "3.4"
9+
- "3.5"
10+
- "3.5-dev" # 3.5 development branch
11+
- "nightly" # currently points to 3.6-dev
12+
13+
install: "pip install -r requirements.txt"
14+
script: python test.py

mailjet/client.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ def get(self, id=None, filters=None, action_id=None, **kwargs):
4848
def create(self, data, filters=None, id=None, action_id=None, **kwargs):
4949
return api_call(self._auth, 'post', self._url, headers=self.headers, resource_id=id, data=data, action=self.action, action_id=action_id, filters=filters, **kwargs)
5050

51-
new = create
52-
post = create
53-
5451
def update(self, id, data, filters=None, action_id=None, **kwargs):
5552
return api_call(self._auth, 'put', self._url, resource_id=id, headers=self.headers, data=data, action=self.action, action_id=action_id, filters=filters, **kwargs)
5653

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
requests
2+
logging

test.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import unittest
2+
from mailjet import Client
3+
import os
4+
5+
API_KEY = os.environ['MJ_APIKEY_PUBLIC']
6+
API_SECRET = os.environ['MJ_APIKEY_PRIVATE']
7+
8+
mailjet = Client(auth=(API_KEY, API_SECRET))
9+
10+
class TestSuite(unittest.TestCase):
11+
12+
def test_get_no_param(self):
13+
result = mailjet.contact.get().json()
14+
self.failUnless(('Data' in result and 'Count' in result))
15+
16+
def test_get_valid_params(self):
17+
result = mailjet.contact.get(filters={'limit': 2}).json()
18+
self.failUnless('Count' in result and result['Count'] is 2)
19+
20+
def test_get_invalid_parameters(self):
21+
# invalid parameters are ignored
22+
result = mailjet.contact.get(filters={'invalid': 'false'}).json()
23+
self.failUnless('Count' in result)
24+
25+
def test_get_with_data(self):
26+
# it shouldn't use data
27+
result = mailjet.contact.get(data={'name': 'guillaume'}).json()
28+
self.failUnless('Count' in result)
29+
30+
def test_get_with_action(self):
31+
result = mailjet.contact_getcontactslists.get(id=2).json()
32+
self.failUnless('Count' in result)
33+
34+
def test_get_with_id_filter(self):
35+
result = mailjet.contact.get(filter={'id': 2}).json()
36+
self.failUnless('Count' in result)
37+
38+
def test_post_with_no_param(self):
39+
result = mailjet.sender.create(data={}).json()
40+
self.failUnless('StatusCode' in result and result['StatusCode'] is not 400)
41+
42+
43+
if __name__ == '__main__':
44+
unittest.main()

0 commit comments

Comments
 (0)