-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_user_tests.py
More file actions
106 lines (79 loc) · 3.66 KB
/
Copy pathcreate_user_tests.py
File metadata and controls
106 lines (79 loc) · 3.66 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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import sender_stand_request
import data
# Funciones
def get_kit_body(name):
current_body = data.kit_body.copy()
current_body["name"] = name
return current_body
def get_new_user_token():
user_response = sender_stand_request.post_new_user(data.user_body)
return user_response.json()["authToken"]
def positive_assert(name):
kit_body = get_kit_body(name)
token = get_new_user_token()
response = sender_stand_request.post_new_client_kit(kit_body, token)
assert response.status_code == 201
assert response.json()["name"] == name
def negative_assert_code_400(name):
kit_body = get_kit_body(name)
token = get_new_user_token()
response = sender_stand_request.post_new_client_kit(kit_body, token)
assert response.status_code == 400
# --- CASOS DE PRUEBA ---
# Prueba 1: Mínimo (1 carácter) PASSED
def test_create_kit_1_letter_in_name_get_success_response():
positive_assert("a")
# Prueba 2: Máximo (511 caracteres) PASSED
def test_create_kit_511_letter_in_name_get_success_response():
name = ("Abcdabcdabcdabcdabcdabcdabcdabcdabcdabc/"
"dabcdabcdabcdabcdabcdabcdabcdabcdabcdab/"
"cdabcdabcdabcdabcdabcdabcdabcdabcdabcda/"
"bcdabcdabcdabcdabcdabcdabcdabcdabcdabcd/"
"abcdabcdabcdabcdabcdabcdabcdabcdabcdabc/"
"dabcdabcdabcdabcdabcdabcdabcdabcdabcdab/"
"cdabcdabcdabcdabcdabcdAbcdabcdabcdabcda/"
"bcdabcdabcdabcdabcdabcdabcdabcdabcdabcd/"
"abcdabcdabcdabcdabcdabcdabcdabcdabcdabc/"
"dabcdabcdabcdabcdabcdabcdabcdabcdabcdab/"
"cdabcdabcdabcdabcdabcdabcdabcdabcdabcda/"
"bcdabcdabcdabcdabcdabcdabcdabcdabcdabcd/"
"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabC")
positive_assert(name)
# Prueba 3: Menor al mínimo (0 caracteres) ERROR 1
def test_create_kit_empty_name_get_error_response():
negative_assert_code_400("")
# Prueba 4. Mayor al máximo (512 caracteres) ERROR 2
def test_create_kit_512_letter_in_name_get_error_response():
name = ("Abcdabcdabcdabcdabcdabcdabcdabcdabcda/"
"bcdabcdabcdabcdabcdabcdabcdabcdabcdab/"
"cdabcdabcdabcdabcdabcdabcdabcdabcdabc/"
"dabcdabcdabcdabcdabcdabcdabcdabcdabcd/"
"abcdabcdabcdabcdabcdabcdabcdabcdabcdab/"
"cdabcdabcdabcdabcdabcdabcdabcdabcdabcd/"
"abcdabcdabcdabcdabcdabcdabcdabcdAbcdabc/"
"dabcdabcdabcdabcdabcdabcdabcdabcdabcdabc/"
"dabcdabcdabcdabcdabcdabcdabcdabcdabcdabc/"
"dabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd/"
"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdab/"
"cdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc/"
"dabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcD")
negative_assert_code_400(name)
# Prueba 5. Caracteres especiales PASSED
def test_create_kit_special_symbol_in_name_get_success_response():
positive_assert("№%@,")
# Prueba 6. Espacios permitidos PASSED
def test_create_kit_has_spaces_in_name_get_success_response():
positive_assert(" A Aaa ")
# Prueba 7. Números como string PASSED
def test_create_kit_has_number_in_name_get_success_response():
positive_assert("123")
# Prueba 8. Parámetro ausente (Caso especial: no enviamos el campo name) ERROR 3
def test_create_kit_no_name_get_error_response():
kit_body = data.kit_body.copy()
kit_body.pop("name") # Eliminamos el campo name
token = get_new_user_token()
response = sender_stand_request.post_new_client_kit(kit_body, token)
assert response.status_code == 400
# Prueba 9. Tipo de dato incorrecto (Número en lugar de String) ERROR 4
def test_create_kit_int_type_name_get_error_response():
negative_assert_code_400(123)