-
Notifications
You must be signed in to change notification settings - Fork 0
[4108] Сервис подписок: админка промокодов #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Conversation
ae7b5d2 to
bd0fb09
Compare
bd0fb09 to
6bf3c9c
Compare
taaylor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Оставил комменты, если будут вопросы - спрашивай и пингуй в дс
ByrDen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Выглядит неплохо :)
Старался подробно расписывать, если что-то не понятно, буду рад объяснить в треде таски
taaylor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кайф! У меня усе :)
ByrDen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Хорошо идём :)
42c024e to
6f05218
Compare
ByrDen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
чуть-чуть нашлось новенького)
ByrDen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
забыл моментик
57f39b9 to
4dc388c
Compare
ByrDen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Финишная прямая)
05fb9ab to
b513496
Compare
a612b74 to
09635bc
Compare
ByrDen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Один тест тебя подвёл, но больше вопросов у меня точно к тебе не будет:)
09635bc to
2866825
Compare
2866825 to
9c31fea
Compare
ByrDen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Со старыми коментами - всё супер. И парочка последних, которые я мог написать раньше, но не подумал (не заметил этого), сори)
Для консистентности с другими сервисами, есть предложение сделать фикстуру promocode - параметризованной, как это сделано с фикстурой file из сервиса storage_v2, чтобы не делать параметризацию для каждого теста, где у тебя используется promocode
dfaf1ae to
ee36b16
Compare
ByrDen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Всё круто, больше комментов нет)
niqzart
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Для начала так, после этих фиксов можно будет просмотреть и тесты
ee36b16 to
bec016a
Compare
51e5e18 to
6f3020f
Compare
6f3020f to
7eaed2d
Compare
59243bd to
c1a8ac5
Compare
c1a8ac5 to
6d72584
Compare
niqzart
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В тестах тоже много осталось
tests/subscriptions/conftest.py
Outdated
| @pytest.fixture() | ||
| def promocode_id(promocode: Promocode) -> int: | ||
| return promocode.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Неконсистентно с другими частями проекта, лишняя фикстура
tests/subscriptions/factories.py
Outdated
|
|
||
| class InvalidPromocodePeriodInputFactory(BaseModelFactory[PromocodeInputSchema]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
polish: "период с невалидный промокодом". Правильно: "промокод с невалидным периодом", т.е. InvalidPeriodPromocode, а не наоборот
| **PromocodeInputFactory.build_python(code=faker.pystr(max_chars=4 + i)) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: max_chars не гарантирует защиту от коллиции, т.к. может сгенерить и меньше, а там и совпасть просто
tests/subscriptions/factories.py
Outdated
|
|
||
| class PromocodeInputFactory(BaseModelFactory[PromocodeInputSchema]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
polish: не логично, что одна просто, другая — unlimited. Значит первая — limited
| @freeze_time() | ||
| async def test_promocode_requesting_exist_code( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: невалидный нейминг
issue: бесполезная заморозка времени
| async with active_session(): | ||
| existing_promocode: Promocode = await Promocode.create(**promocode_put_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: для такого существуют фикстуры
| @pytest.mark.parametrize( | ||
| ("method", "path", "body_factory"), | ||
| [ | ||
| pytest.param("POST", "", PromocodeInputFactory, id="create_promocode"), | ||
| pytest.param( | ||
| "POST", "", UnlimitedPromocodeInputFactory, id="create_unlimited_promocode" | ||
| ), | ||
| pytest.param( | ||
| "PUT", | ||
| lfc(lambda promocode_id: f"{promocode_id}/"), | ||
| PromocodeInputFactory, | ||
| id="update_promocode", | ||
| ), | ||
| pytest.param( | ||
| "PUT", | ||
| lfc(lambda promocode_id: f"{promocode_id}/"), | ||
| UnlimitedPromocodeInputFactory, | ||
| id="update_unlimited_promocode", | ||
| ), | ||
| ], | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: период никак не влияет на ошибку коллизии кода
issue: переусложнённая параметризация. Куда проще сделать два теста
| @pytest.mark.parametrize( | ||
| ("path", "deleted_field"), | ||
| [ | ||
| pytest.param("by-id", lf("deleted_promocode_id"), id="promocode_by_id"), | ||
| pytest.param("by-code", lf("deleted_promocode_code"), id="promocode_by_code"), | ||
| ], | ||
| ) | ||
| async def test_promocode_retrieving_not_finding( | ||
| mub_client: TestClient, path: str, deleted_field: str | ||
| ) -> None: | ||
| assert_response( | ||
| mub_client.get( | ||
| f"/mub/subscription-service/promocodes/{path}/{deleted_field}/", | ||
| ), | ||
| expected_code=status.HTTP_404_NOT_FOUND, | ||
| expected_json={"detail": "Promocode not found"}, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: невалидное название теста, некорректный нейминг
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: неконсистентный порядок тестов
6d72584 to
e783caf
Compare
e783caf to
1ee4ca9
Compare
ссылка на таск: https://github.com/xi-effect/xi.progress/issues/14