-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.sh
70 lines (65 loc) · 1.96 KB
/
tests.sh
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
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# script for running automatic tests with curl
# run these lines in a different terminal before running this
# rm note.db
# flask run
today=$(date '+%Y-%m-%d')
# create notes
curl -H 'Content-Type: application/json' \
-d '{"title":"my note"}' \
-X POST \
http://127.0.0.1:5000/notes
curl -H 'Content-Type: application/json' \
-d '{"title": "your note",
"content": "Today in class we will..."}' \
-X POST \
http://127.0.0.1:5000/notes
# tags create
curl -H 'Content-Type: application/json' \
-d '{"title": "your note",
"tag": ["fun"]}' \
-X POST \
http://127.0.0.1:5000/tags
curl -H 'Content-Type: application/json' \
-d '{"title": "my note",
"tag": ["boring", "fun"]}' \
-X POST \
http://127.0.0.1:5000/tags
# notes search
# return content and search by title
curl -H 'Content-Type: application/json' \
-d '{"search_field":"title",
"query":"your note",
"return_fields":["content"]}' \
-X GET \
http://127.0.0.1:5000/notes/search
# return created date and search by created date
curl -H 'Content-Type: application/json' \
-d '{"search_field":"created_date",
"query":"'"$today"'",
"return_fields":["created_date"]}' \
-X GET \
http://127.0.0.1:5000/notes/search
# return modified date and title search by modified date
curl -H 'Content-Type: application/json' \
-d '{"search_field":"modified_date",
"query":"'"$today"'",
"return_fields":["modified_date", "title"]}' \
-X GET \
http://127.0.0.1:5000/notes/search
# tag list
curl -H 'Content-Type: application/json' \
-d '{}' \
-X GET \
http://127.0.0.1:5000/tags/list
# tags search
# >1 match
curl -H 'Content-Type: application/json' \
-d '{"query": "boring"}' \
-X GET \
http://127.0.0.1:5000/tags/search
# ==1 match
curl -H 'Content-Type: application/json' \
-d '{"query": "fun"}' \
-X GET \
http://127.0.0.1:5000/tags/search