-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_kit_name_kit_test.py
94 lines (63 loc) · 3.86 KB
/
create_kit_name_kit_test.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
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
import data
import sender_stand_request
# Long variables for the tests
symbol511 = "AbcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdAbcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabC"
symbol512 = "AbcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdAbcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcD"
# Getting an updated kit_body for the tests
def get_kit_body(name):
current_kit_body = data.kit_body.copy()
current_kit_body["name"] = name
return current_kit_body
# Positive assertion
def positive_assertion(name):
kit_body_positive = get_kit_body(name)
kit_response_positive = sender_stand_request.post_new_client_kit(kit_body_positive)
assert kit_response_positive.json()["name"] == name
assert kit_response_positive.status_code == 201
# Negative assertion with a name-field in a kit_body
def negative_assertion(name):
kit_body_negative = get_kit_body(name)
kit_response_negative = sender_stand_request.post_new_client_kit(kit_body_negative)
assert kit_response_negative.status_code == 400
# Negative assertion without a name-field in a kit_body
def negative_assertion_no_name(kit_body):
kit_response_negative_no_name = sender_stand_request.post_new_client_kit(kit_body)
assert kit_response_negative_no_name.status_code == 400
# Positive tests
# Name-field in a kit_body consists of one symbol
def test_create_kit_1_symbol_in_name_get_success_response():
positive_assertion("a")
# Name-field in a kit_body consists of 511 symbols
def test_create_kit_511_symbols_in_name_get_success_response():
positive_assertion(symbol511)
# Name-field in a kit_body contains an english letter
def test_create_kit_english_letters_in_name_get_success_response():
positive_assertion("QWErty")
# Name-field in a kit_body contains a russian letter
def test_create_kit_russian_letters_in_name_get_success_response():
positive_assertion("Мария")
# Name-field in a kit_body contains a special symbol
def test_create_kit_has_special_symbols_in_name_get_success_response():
positive_assertion("\"№%@\",")
# Name-field in a kit_body contains a space symbol
def test_create_kit_has_space_in_name_get_success_response():
positive_assertion("Человек и КО")
# Name-field in a kit_body contains a numeric symbol
def test_create_kit_has_number_in_name_get_success_response():
positive_assertion("123")
# Negative tests
# Name-field in a kit_body contains an empty string
def test_create_kit_empty_name_get_error_response():
negative_assertion("")
# Name-field in a kit_body contains 512 symbols
def test_create_kit_512_symbols_in_name_get_error_response():
negative_assertion(symbol512)
# Kit_body doesn't contain any name-field
def test_create_kit_no_name_get_error_response():
current_kit_body_negative_no_name = data.kit_body.copy()
# Deleting a name-field from a query
current_kit_body_negative_no_name.pop("name")
negative_assertion_no_name(current_kit_body_negative_no_name)
# Name-field in a kit_body is a number
def test_create_kit_numeric_type_name_get_error_response():
negative_assertion(123)