Skip to content

Дипломная работа 2 - #1

Open
llorichT wants to merge 2 commits into
mainfrom
develop2
Open

Дипломная работа 2#1
llorichT wants to merge 2 commits into
mainfrom
develop2

Conversation

@llorichT

Copy link
Copy Markdown
Owner

No description provided.

@irisqul irisqul left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Сильные стороны:

  • Код запускается без ошибок
  • Написанные тесты атомарны, проверяется тело и код отчета, там где это необходимо
  • Тестовые данные создаются перед тестом и удаляются после того, как он выполнится

Comment thread tests/conftest.py Outdated
@pytest.fixture
def registered_user(client, user_payload):
response = client.register_user(user_payload)
assert response.status_code == 200, response.text

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно исправить: в фикстурах не проводим тестирование, это делает все тесты где используется фикстура неатомарными

Comment thread tests/conftest.py Outdated

@pytest.fixture
def user_payload() -> dict:
return unique_user()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно исправить: фикстуры не занимаются прокидыванием данных в тест и выполнением примитивной логики, они выполняют сложную логику предусловий и постусловий и вычислений. Этот метод необходимо напрямую вызывать в тестах и методах

Comment thread tests/conftest.py Outdated
@pytest.fixture
def ingredient_ids(client) -> list[str]:
response = client.get_ingredients()
assert response.status_code == 200, response.text

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

то же

@allure.title("Создать заказ с авторизацией")
def test_create_order_with_authorization_success(self, client, registered_user, ingredient_ids):
_, access_token = registered_user
response = client.create_order(ingredient_ids, access_token)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно исправить: Над каждым логическим методом (запрос через requests) нужно прописать декоратор allure.step

Comment thread tests/test_user_creation.py Outdated
def test_create_unique_user_success(self, client, user_payload):
response = client.register_user(user_payload)
body = response.json()
try:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно исправить: условий и try-except блоков в тестах быть не может, тест всегда однозначен. Если это не вписывается в параметризацию, значит ее быть не должно и это просто несколько отдельных тестовых методов

Comment thread tests/test_user_creation.py Outdated
assert body["refreshToken"]
finally:
if body.get("accessToken"):
client.delete_user(body["accessToken"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно лучше: супер что очищается БД, но делать это стоит в фикстуре, чтобы даже если в тесте что-то пошло не по плану, Бд всё же осталась в изначальном состоянии

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants