-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_script.py
58 lines (42 loc) · 1.39 KB
/
test_script.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
53
54
55
56
57
58
# encoding=utf-8
__author__ = "Quazi Nafiul Islam"
import os
import json
from pprint import pprint
import requests
username = 'gamesbrainiac'
password = 'islam'
name = 'nafiul'
def jsonify(obj):
return json.dumps(obj)
try:
# Creating a user
data = requests.put('http://localhost:5000/user/',
data=jsonify({
'name': name,
'username': username,
'password': password}))
pprint(data.text)
# Getting token
data = requests.post('http://localhost:5000/user/',
data=jsonify({
"username": username,
"password": password
}))
pprint(data.text)
# Getting token
token = json.loads(data.text)['token']
for var in 'cake sandwich computer laptop mouse plane'.split():
data = requests.put('http://localhost:5000/',
data=jsonify({
'token': token,
'data': "Make a {}".format(var),
'tags': ['hello', 'world']
}))
pprint(data.text)
data = requests.get('http://localhost:5000/', data=jsonify({
"token": token
}))
pprint(data.text)
except KeyboardInterrupt:
os.remove('todo_api.db')