-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapi_add_delete_email.py
52 lines (40 loc) · 1.26 KB
/
api_add_delete_email.py
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
import api_tests
import pprint
import names
import random
import time
import os
import sys
import logging
script = os.path.basename(sys.argv[0])
logging.basicConfig(filename='./files/test_logs/%s.log' % script, format='%(asctime)s %(message)s', level=logging.INFO)
logger = logging.getLogger('test')
def add_emails():
count = 0
while True:
# generate unique name
domain = r'@domain.com'
user = str(names.get_first_name()) + '.' + str(names.get_last_name()) + '%s' % domain
typemail = int(random.randint(1, 3))
print user
t1 = time.time()
api_tests.add_email_address(user, typemail)
t2 = time.time()
print ('Email took %s seconds to add' % (t2 - t1))
count = count + 1
if count > 100:
break
def delete_emails():
response = api_tests.get_email_types_with_recipients()
r = response.json()
pprint.pprint(r)
for recip in r['data'][0]['recipients']:
# print recip['id']
# print recip['type_id']
api_tests.delete_email_addr(str(recip['type_id']), str(recip['id']))
# Set login tokens as global variables.
api_tests.set_access()
# Add 101 emails in notifications UI
add_emails()
# Delete all emails in the notifications UI
delete_emails()