-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimulation_interactions.py
65 lines (49 loc) · 1.59 KB
/
simulation_interactions.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
59
60
61
62
63
64
65
"""
This snippet of code acts a simulation for using the endpoints created through the Fast API server.
"""
import requests
#Creating the headers section for all the following requests.
headers = {
'Content-type':'application/json',
'Accept':'application/json'
}
""" Endpoint that gets the datetime according to a boolean.
Parameters
------------
boolean: idem
Return
-----------
response : Json
It contains:
* timestamp.
* status.
* message.
* mimetype.
"""
def test_retrieve_date(boolean):
response = requests.post('http://127.0.0.1:80/get_date?boolean=' + str(boolean), headers=headers)
return response.json()
""" Endpoint that gets the current endpoints count.
Return
-----------
response : Json
It contains:
* count.
* status.
* message.
* mimetype.
"""
def test_get_count():
response = requests.get('http://127.0.0.1:80/get_count', headers=headers)
return response.json()
"""
This is the section related to the tests.
"""
print(test_retrieve_date(True))
print(test_retrieve_date(False))
print(test_retrieve_date("x"))
print(test_get_count())
#docker build --tag docker_fast_api .
#docker run -d --name fast_api_final -p 80:80 docker_fast_api
#http://127.0.0.1/get_count
#http://127.0.0.1:80/get_date?boolean=False