Skip to content

Comments

diplom 2#5

Open
ShamilovR wants to merge 1 commit intomasterfrom
diplom_2
Open

diplom 2#5
ShamilovR wants to merge 1 commit intomasterfrom
diplom_2

Conversation

@ShamilovR
Copy link
Owner

No description provided.

payload = {
"ingredients": random_ingredients
}
headers = {"Authorization": user['accessToken']} if need_auth else {}
Copy link
Owner Author

@ShamilovR ShamilovR Jan 12, 2025

Choose a reason for hiding this comment

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

Нужно исправить: if, else в тестовых сценариях недопустимы, т.к. условия предполагают разные варианты исхода. А значит это должны быть два отдельных тестовых метода

}
response = requests.post(CREATE_USER_URL, data=payload)
body = response.json()
return {
Copy link
Owner Author

Choose a reason for hiding this comment

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

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

}
response = requests.post(CREATE_ORDER_URL, data=payload, headers={"Authorization": user['accessToken']})

assert response.status_code == 500
Copy link
Owner Author

Choose a reason for hiding this comment

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

Нужно исправить: проверки лишь статуса кода недостаточно. Необходимо также парсить ответ.


class TestCreateUser:

payload = [
Copy link
Owner Author

@ShamilovR ShamilovR Jan 12, 2025

Choose a reason for hiding this comment

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

Можно лучше: здесь и далее: тестовые данные стоит хранить отдельно в data модуле, так поддерживать и переиспользовать будет проще


class TestUpdateUserData:

fake = Faker("ru_RU")
Copy link
Owner Author

Choose a reason for hiding this comment

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

Можно лучше: объект фейкера создается уже не первый раз. По хорошему можно создать хелпер для генерации ланных.

Comment on lines +10 to +15
fake = Faker("ru_RU")
payload = {
"email": fake.email(),
"password": fake.password(),
"name": fake.name()
}

Choose a reason for hiding this comment

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

Можно лучше: этот участок кода повторяется в 3 местах в проекте. СОздавать объект данных лучше в отдельном модуле по типу helpers, откуда просто импортировать по необходимости

import pytest


MESSAGE_NO_INGREDIENTS = "Ingredient ids must be provided"

Choose a reason for hiding this comment

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

Можно лучше: тексты ответов стоит хранить снаружи в data модулях для поддержания и актуализации, а тут вызывать переменные в которые они записаны

}
response = requests.post(CREATE_ORDER_URL, data=payload, headers={"Authorization": user['accessToken']})

assert response.status_code == 500

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