-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: assertions.py, methods.py, constant.py
- Loading branch information
Showing
7 changed files
with
120 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
import pytest | ||
from faker import Faker | ||
|
||
faker = Faker('En') | ||
Faker.seed() | ||
|
||
|
||
class Constant: | ||
BASE_URL = 'https://reqres.in/api/users' | ||
|
||
CREATE_USER = {"name": faker.name(), "job": faker.job()} | ||
BASE_URL = 'https://reqres.in/' | ||
WRONG_URL = 'http://reqres.in/' | ||
|
||
|
||
class StatusCode: | ||
STATUS_CODE_200 = 200 | ||
STATUS_CODE_201 = 201 | ||
STATUS_CODE_404 = 404 | ||
|
||
|
||
class Data: | ||
CREATE_USER = {"name": faker.name(), "job": faker.job()} | ||
NAME_USER = {"name": faker.name()} | ||
JOB_USER = {"job": faker.job()} | ||
CREATE_USER_NAME_NONE ={"name": None, "job": faker.job()} | ||
CREATE_USER_JOB_NONE = {"name": faker.name(), "job": None} | ||
LIST_KEY = ['id', 'createdAt', pytest.param('name', marks=pytest.mark.xfail(reason='Bag')), | ||
pytest.param('job', marks=pytest.mark.xfail(reason='Bag'))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,80 @@ | ||
import allure | ||
import pytest | ||
|
||
from base.assertions import Assertions | ||
from data.constant import StatusCode, Constant | ||
from data.constant import StatusCode, Data, Constant | ||
from base.methods import BaseRequests | ||
|
||
|
||
@allure.epic("Create User") | ||
@allure.epic('Create User') | ||
class TestCreateUser: | ||
status = StatusCode | ||
data = Data | ||
constant = Constant | ||
|
||
@allure.title("POST Создать пользователя") | ||
@allure.title('POST Create user') | ||
def test_post_create_user(self): | ||
response = BaseRequests.post(url='', headers=self.constant.CREATE_USER) | ||
response = BaseRequests.post(url='api/users', headers=self.data.CREATE_USER) | ||
Assertions.assert_code_status(response, self.status.STATUS_CODE_201) | ||
|
||
@allure.title('Check format is json') | ||
def test_post_create_user_response_is_json(self): | ||
response = BaseRequests.post(url='api/users', headers=self.data.CREATE_USER) | ||
Assertions.assert_response_is_json(response) | ||
|
||
@pytest.mark.parametrize('key_name', data.LIST_KEY) | ||
@allure.title('Check response has key job') | ||
def test_post_create_user_key_name_is_in_response(self, key_name): | ||
headers = self.data.CREATE_USER | ||
response = BaseRequests.post(url='api/users', headers=headers) | ||
Assertions.assert_key_name_is_in_response(response, key_name) | ||
|
||
@pytest.mark.xfail(reason='Bag') | ||
@pytest.mark.parametrize('key_name', data.CREATE_USER) | ||
@allure.title('Check response has key job') | ||
def test_post_create_user_key_value_is_in_response(self, key_name): | ||
headers = self.data.CREATE_USER | ||
response = BaseRequests.post(url='api/users', headers=headers) | ||
Assertions.assert_key_value_is_in_response(response, headers, key_name) | ||
|
||
@allure.title('GET Send request get with body') | ||
def test_get_create_user(self): | ||
response = BaseRequests.get(url='api/users', headers=self.data.CREATE_USER) | ||
Assertions.assert_code_status(response, self.status.STATUS_CODE_200) | ||
|
||
@pytest.mark.xfail(reason='Bag') | ||
@allure.title('POST Создать пользователя без тела запроса') | ||
def test_post_create_user_without_body(self): | ||
response = BaseRequests.post(url='api/users') | ||
Assertions.assert_is_not_code_status(response, self.status.STATUS_CODE_201) | ||
|
||
@pytest.mark.xfail(reason='Bag') | ||
@allure.title('POST Create user without job') | ||
def test_post_create_user_without_job(self): | ||
response = BaseRequests.post(url='api/users', data=self.data.NAME_USER) | ||
print('cod', response.status_code) | ||
Assertions.assert_is_not_code_status(response, self.status.STATUS_CODE_201) | ||
|
||
@pytest.mark.xfail(reason='Bag') | ||
@allure.title('POST Create user without name') | ||
def test_post_create_user_without_name(self): | ||
response = BaseRequests.post(url='api/users', headers=self.data.JOB_USER) | ||
Assertions.assert_is_not_code_status(response, self.status.STATUS_CODE_201) | ||
|
||
@pytest.mark.xfail(reason='Bag') | ||
@allure.title('POST Create user with None job') | ||
def test_post_create_user_with_none_job(self): | ||
response = BaseRequests.post(url='api/users', headers=self.data.CREATE_USER_JOB_NONE) | ||
Assertions.assert_is_not_code_status(response, self.status.STATUS_CODE_201) | ||
|
||
@pytest.mark.xfail(reason='Bag') | ||
@allure.title('POST Create user with None name') | ||
def test_post_create_user_with_none_name(self): | ||
response = BaseRequests.post(url='api/users', headers=self.data.CREATE_USER) | ||
Assertions.assert_is_not_code_status(response, self.status.STATUS_CODE_201) | ||
|
||
@pytest.mark.xfail(reason='Bag') | ||
@allure.title('POST Create user as {}') | ||
def test_post_create_user_as_none(self): | ||
response = BaseRequests.post(url='api/users', headers={}) | ||
Assertions.assert_is_not_code_status(response, self.status.STATUS_CODE_201) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.