Skip to content

Commit 1297cbf

Browse files
committed
OBL-408 added test_db suite
1 parent 583ff40 commit 1297cbf

4 files changed

Lines changed: 107 additions & 23 deletions

File tree

tests_api/test_bd.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ def test_tos(self):
6767
allure.attach.file(attach, name=f"Report {datetime.today()}", attachment_type=allure.attachment_type.HTML)
6868
Checking.check_status_code(response, 200)
6969

70-
@allure.title('GET profile information.')
71-
def test_get_profile(self):
72-
response = API.get_profile(token=TestGET.token)
73-
Checking.check_status_code(response, 200)
74-
7570
@allure.title('GET list list_dbtypes.')
7671
def test_get_list_db_types(self):
7772
response = API.get_list_db_types()
@@ -97,11 +92,6 @@ def test_get_with_bad_request(self):
9792
response = API.get_bad_request()
9893
Checking.check_status_code(response, 404)
9994

100-
@allure.title('GET profile status.')
101-
def test_get_status(self):
102-
response = API.get_status(token=TestGET.token)
103-
Checking.check_status_code(response, 200)
104-
10595

10696
@allure.suite('POST')
10797
class TestPOST:
@@ -116,6 +106,11 @@ def test_get_token_and_body(self, get_token):
116106
TestPOST.token, TestPOST.body, TestPOST.new_password, TestPOST.old_password, TestPOST.email = get_token[0], \
117107
get_token[1], get_token[2], get_token[3], get_token[4]
118108

109+
@allure.title('POST check profile')
110+
def test_get_status(self):
111+
response = API.get_profile(token=TestPOST.token)
112+
Checking.check_status_code(response, 200)
113+
119114
@allure.title('POST registration for English language.')
120115
def test_post_registration_for_english_language(self):
121116
response = API.post_registration_variety_email(

tests_api/test_db.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import json
2+
import random
3+
import time
4+
from datetime import datetime
5+
6+
import allure
7+
import pytest
8+
9+
from .loading_report_dir.loading_report_path import LOADING_REPORT_DIR
10+
from .utils.checking import Checking
11+
from .utils.request import API
12+
13+
14+
@allure.suite('smoke_databases')
15+
class TestPOST:
16+
token = None
17+
body = None
18+
new_password = None
19+
old_password = None
20+
email = None
21+
22+
@allure.title('POST get token and other params.')
23+
def test_get_token_and_body(self, get_token):
24+
TestPOST.token, TestPOST.body, TestPOST.new_password, TestPOST.old_password, TestPOST.email = get_token[0], \
25+
get_token[1], get_token[2], get_token[3], get_token[4]
26+
27+
28+
@allure.title('POST db_create')
29+
def test_post_db_create(self, get_token):
30+
TestPOST.token, TestPOST.body = get_token[0], get_token[1]
31+
response_login = API.post_login(body=TestPOST.body)
32+
Checking.check_status_code(response_login, 200)
33+
response = API.post_db_create(token=TestPOST.token)
34+
print(response.text)
35+
Checking.check_status_code(response, 201)
36+
37+
@allure.title('POST db_create_with_wrong_db_type.')
38+
def test_post_db_create_with_wrong_values_dbtype(self):
39+
response_db_list = API.post_db_create_wrong_value_db_type(token=TestPOST.token)
40+
Checking.check_status_code(response_db_list, 400)
41+
Checking.check_json_search_word_in_value(
42+
response_db_list, "content",
43+
"error: DB type isn't found or isn't available for order")
44+
45+
@allure.title('POST db_create_with_wrong_db_version.')
46+
def test_post_db_create_with_wrong_values_db_version(self):
47+
response_db_list = API.post_db_create_wrong_value_db_version(token=TestPOST.token)
48+
Checking.check_status_code(response_db_list, 400)
49+
Checking.check_json_search_word_in_value(
50+
response_db_list, "content",
51+
"error: DB version isn't found or isn't available for order")
52+
53+
@allure.title('POST db_create_with_wrong_env.')
54+
def test_post_db_create_with_wrong_values_env(self):
55+
response_db_list = API.post_db_create_wrong_value_env(token=TestPOST.token)
56+
Checking.check_status_code(response_db_list, 400)
57+
Checking.check_json_search_word_in_value(
58+
response_db_list, "content",
59+
"error: DB environment isn't found or isn't available for order")
60+
61+
@allure.title('POST db_create_with_wrong_region.')
62+
def test_post_db_create_with_wrong_values_region(self):
63+
response_db_list = API.post_db_create_wrong_value_region(token=TestPOST.token)
64+
Checking.check_status_code(response_db_list, 400)
65+
Checking.check_json_search_word_in_value(
66+
response_db_list, "content",
67+
"error: region isn't found or isn't available for order")
68+
69+
@allure.title('POST db_list')
70+
def test_post_db_list(self):
71+
response_db_list = API.post_db_list(token=TestPOST.token)
72+
Checking.check_status_code(response_db_list, 200)
73+
74+
75+
@allure.title('POST db_list_with_filter')
76+
def test_post_db_list_with_filter(self):
77+
time.sleep(15)
78+
list_db = API.post_db_list(token=TestPOST.token)
79+
json_list_db = json.loads(list_db.text)
80+
first_db_uuid = list(json_list_db['data'])[-1]
81+
print(f"first_db_uuid is {first_db_uuid}")
82+
response_db_list =API.post_db_list_with_filter(
83+
token=TestPOST.token,
84+
db_uuid=first_db_uuid)
85+
Checking.check_status_code(response_db_list, 200)
86+
87+
88+
@allure.title('POST delete_db')
89+
def test_delete_db(self):
90+
time.sleep(60)
91+
list_db = API.post_db_list(token=TestPOST.token)
92+
json_list_db = json.loads(list_db.text)
93+
first_db_uuid = list(json_list_db['data'])[-1]
94+
print(f"first_db_uuid is {first_db_uuid}")
95+
response_db_deleted =API.post_db_delete(
96+
token=TestPOST.token,
97+
db_uuid=first_db_uuid)
98+
Checking.check_status_code(response_db_deleted, 200)

tests_api/test_get.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
from .utils.request import API
1212

1313

14-
@allure.epic('Connection DB')
15-
@allure.suite('Test Connection DB')
16-
@allure.severity(allure.severity_level.CRITICAL)
17-
1814
@allure.suite('GET')
1915
class TestGET:
2016
token = None
@@ -32,11 +28,6 @@ def test_tos(self):
3228
allure.attach.file(attach, name=f"Report {datetime.today()}", attachment_type=allure.attachment_type.HTML)
3329
Checking.check_status_code(response, 200)
3430

35-
# @allure.title('GET profile information.')
36-
# def test_get_profile(self):
37-
# response = API.get_profile(token=TestGET.token)
38-
# Checking.check_status_code(response, 200)
39-
4031
@allure.title('GET list list_dbtypes.')
4132
def test_get_list_db_types(self):
4233
response = API.get_list_db_types()

tests_api/utils/request.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ def get_tos(token: str):
3737
return response
3838

3939
@staticmethod
40-
def get_profile(token: str):
40+
def get_profile(token):
4141
"""
4242
Get profile information.
4343
:param token:
4444
:return: Response
4545
"""
46-
response = HttpMethods.get(
46+
response = HttpMethods.post(
4747
endpoint='/get_profile',
4848
token=token)
4949
auth_header = {"Authorization": f"{token}"}
@@ -784,7 +784,7 @@ def post_delete_docker_container(token, list_index: int):
784784
return response
785785

786786
@staticmethod
787-
def delete_db(db_uuid, token):
787+
def post_db_delete(db_uuid, token):
788788
"""
789789
:param db_uuid:
790790
:param token:
@@ -794,7 +794,7 @@ def delete_db(db_uuid, token):
794794
db_uuid = {"db_uuid": f"{db_uuid}"}
795795
json_db_uuid = db_uuid
796796
response = HttpMethods.post(
797-
endpoint='/',
797+
endpoint='/db_delete',
798798
body=json_db_uuid,
799799
token=token)
800800
with allure.step('Endpoint: /db_delete'):

0 commit comments

Comments
 (0)