Skip to content

Commit f2d0d46

Browse files
author
Arnaud Breton
committed
Populating all data required for test_get_with_action
1 parent b6ea2a2 commit f2d0d46

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

test.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,36 @@ def test_get_with_data(self):
3333
self.failUnless(result.status_code == 200)
3434

3535
def test_get_with_action(self):
36-
result_contact = self.client.contactslist.get(filters={'limit': 1}).json()
37-
38-
if result_contact['Count'] != 0:
39-
contact_id = result_contact['Data'][0]['ID']
36+
get_contact = self.client.contact.get(filters={'limit': 1}).json()
37+
if get_contact['Count'] != 0:
38+
contact_id = get_contact['Data'][0]['ID']
4039
else:
4140
contact_random_email = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10)) + '@mailjet.com'
4241
post_contact = self.client.contact.create(data={'Email': contact_random_email})
4342
self.failUnless(post_contact.status_code == 201)
4443
contact_id = post_contact.json()['Data'][0]['ID']
4544

45+
get_contact_list = self.client.contactslist.get(filters={'limit': 1}).json()
46+
if get_contact_list['Count'] != 0:
47+
list_id = get_contact_list['Data'][0]['ID']
48+
else:
49+
contact_list_random_name = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10)) + '@mailjet.com'
50+
post_contact_list = self.client.contactslist.create(data={'Name': contact_list_random_name})
51+
self.failUnless(post_contact_list.status_code == 201)
52+
list_id = post_contact_list.json()['Data'][0]['ID']
53+
54+
data = {
55+
'ContactsLists': [
56+
{
57+
"ListID": list_id,
58+
"Action": "addnoforce"
59+
}
60+
]
61+
}
62+
result_add_list = self.client.contact_managecontactslists.create(id=contact_id, data=data)
63+
self.failUnless(result_add_list.status_code == 201)
64+
4665
result = self.client.contact_getcontactslists.get(contact_id).json()
47-
print result
4866
self.failUnless('Count' in result)
4967

5068
def test_get_with_id_filter(self):

0 commit comments

Comments
 (0)