-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsender_stand_request.py
More file actions
38 lines (32 loc) · 1.92 KB
/
sender_stand_request.py
File metadata and controls
38 lines (32 loc) · 1.92 KB
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
import configuration
import data
import requests
def post_new_client(body): # con esta funcion se crea el nuevo usuario
return requests.post(
configuration.URL_SERVICE + configuration.CREATE_USER_PATH,
json=body, # Inserta el cuerpo de solicitud
headers=data.headers # Inserta los encabezados
)
def post_new_client_kit(kit_user_body): # con esta funcion se crea el nuevo kit del nuevo cliente
token = authtoken_new_kit()
headers = data.headers.copy() #aplícale la función copy(). Es mejor no hacer ningún cambio en el diccionario de origen, ya que esto puede generar errores.
headers["Authorization"] = f"Bearer {token}"
return requests.post(
configuration.URL_SERVICE + configuration.KITS_PATH,
json=kit_user_body,
headers=headers
)
def positive_assert(kit_body): # assert positivo
response = post_new_client_kit(kit_body)
assert response.status_code == 201, \
f"Expected status code 201, but got {response.status_code}"
assert response.json()["name"] == kit_body["name"]
def negative_assert_code_400(kit_body): # assert negativo
response = post_new_client_kit(kit_body)
assert response.status_code == 400, \
f"Expected status code 400, but got {response.status_code}"
def authtoken_new_kit():
response = post_new_client(data.user_body) #el authtoken del nuevo kit
return response.json()["authToken"]
#print(response.json()) Elimine este print por solicitid de la revision ya que con Pytest genera los logs necesarios.
#print(response.status_code) Elimine este print por solicitid de la revision ya que con Pytest genera los logs necesarios.