|
| 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) |
0 commit comments