-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_user_test.py
More file actions
135 lines (99 loc) · 4.65 KB
/
create_user_test.py
File metadata and controls
135 lines (99 loc) · 4.65 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import sender_stand_request
import data
def get_user_body(first_name):
current_body = data.user_body.copy()
current_body["firstName"] = first_name
return current_body
def positive_assert(first_name):
user_body = get_user_body(first_name)
user_response = sender_stand_request.post_new_user(user_body)
print("Task 5: firstName: ", first_name)
assert user_response.status_code == 201
print("Task 5.1: ", user_response.status_code)
assert user_response.json()["authToken"] != ""
print("Task 5.2: ", user_response.json()["authToken"])
users_table_response = sender_stand_request.get_users_table()
str_user = user_body["firstName"] + "," + user_body["phone"] + "," + user_body["address"] + ",,," + \
user_response.json()["authToken"]
assert users_table_response.text.count(str_user) == 1
print("Task 5.3: ", users_table_response.text.count(str_user))
def negative_assert_symbol(first_name):
user_body = get_user_body(first_name)
response = sender_stand_request.post_new_user(user_body)
print("Task 5: firstName: ", first_name)
assert response.status_code == 400
print("Task 5.1: ", response.status_code)
assert response.json()["code"] == 400
print("Task 5.2: ", response.json()["code"])
print("Task 5.3: ", response.json()["message"]) == "Имя пользователя введено некорректно. " \
"Имя может содержать только русские или латинские буквы, " \
"длина должна быть не менее 2 и не более 15 символов"
def negative_assert_no_firstname(user_body):
response = sender_stand_request.post_new_user(user_body)
print("Task 5: firstName: no firstName")
assert response.status_code == 400
print("Task 5.1: ", response.status_code)
assert response.json()["code"] == 400
print("Task 5.2: ", response.json()["code"])
print("Task 5.3: ", response.json()["message"]) == "Не все необходимые параметры были переданы"
# definitions of positive tests
def test_create_user_2_letter_in_first_name_get_success_response():
print("1")
positive_assert("Aa")
def test_create_user_15_letter_in_first_name_get_success_response():
print("2")
positive_assert("Ааааааааааааааа")
def test_create_user_english_letter_in_first_name_get_success_response():
print("3")
positive_assert("QWErty")
def test_create_user_russian_letter_in_first_name_get_success_response():
print("4")
positive_assert("Мария")
# definitions of negative tests
def test_create_user_1_letter_in_first_name_get_error_response():
print("5")
negative_assert_symbol("A")
def test_create_user_16_letter_in_first_name_get_error_response():
print("6")
negative_assert_symbol("Аааааааааааааааa")
def test_create_user_has_space_in_first_name_get_error_response():
print("7")
negative_assert_symbol("Человек и КО")
def test_create_user_has_special_symbol_in_first_name_get_error_response():
print("8")
negative_assert_symbol("\"№%@\",")
def test_create_user_has_number_in_first_name_get_error_response():
print("9")
negative_assert_symbol("123")
def test_create_user_no_first_name_get_error_response():
print("10")
user_body = data.user_body.copy()
# Удаление параметра firstName из запроса
user_body.pop("firstName")
negative_assert_no_firstname(user_body)
def test_create_user_empty_first_name_get_error_response():
print("11")
user_body = get_user_body("")
negative_assert_no_firstname(user_body)
def test_create_user_number_type_first_name_get_error_response():
print("12")
user_body = get_user_body(12)
response = sender_stand_request.post_new_user(user_body)
print("Task 5: firstName: number type")
assert response.status_code == 400
print("Task 5.1: ", response.status_code)
# positive tests
# test_create_user_2_letter_in_first_name_get_success_response()
# test_create_user_15_letter_in_first_name_get_success_response()
# test_create_user_english_letter_in_first_name_get_success_response()
# test_create_user_russian_letter_in_first_name_get_success_response()
#
# # negative tests
# test_create_user_1_letter_in_first_name_get_error_response()
# test_create_user_16_letter_in_first_name_get_error_response()
# test_create_user_has_space_in_first_name_get_error_response()
# test_create_user_has_special_symbol_in_first_name_get_error_response()
# test_create_user_has_number_in_first_name_get_error_response()
# test_create_user_no_first_name_get_error_response()
# test_create_user_empty_first_name_get_error_response()
# test_create_user_number_type_first_name_get_error_response()