Обновлена ​​обработка статуса медиагрупп и улучшены интеграционные тесты

- Реализовано обновление статуса медиагрупп в `PostPublishService` при отклонении медиагрупп.

- Добавлены интеграционные тесты для обновления статусов постов и медиагрупп в `test_post_repository_integration.py

- Улучшен фиктивный репозиторий в `conftest_post_repository.py` для поддержки новых методов обновления статуса.

- Обновлены существующие тесты для проверки корректной обработки статуса постов и медиагрупп.
This commit is contained in:
2026-01-22 23:52:48 +03:00
parent 09e894e48f
commit 03ed2bcf4e
4 changed files with 113 additions and 8 deletions

View File

@@ -495,3 +495,52 @@ class TestPostRepositoryIntegration:
expected_message_ids = [11111, 22222, 33333, 44444]
for expected_id in expected_message_ids:
assert expected_id in post_ids
@pytest.mark.asyncio
async def test_update_status_by_message_id_integration(self, post_repository, sample_post):
"""Интеграционный тест обновления статуса одиночного поста."""
await self._setup_test_database(post_repository)
await post_repository.add_post(sample_post)
await post_repository.update_status_by_message_id(sample_post.message_id, "approved")
rows = await post_repository._execute_query_with_result(
"SELECT status FROM post_from_telegram_suggest WHERE message_id = ?",
(sample_post.message_id,),
)
assert len(rows) == 1
assert rows[0][0] == "approved"
@pytest.mark.asyncio
async def test_update_status_for_media_group_by_helper_id_integration(
self, post_repository, sample_post_with_helper
):
"""Интеграционный тест обновления статуса медиагруппы по helper_message_id."""
await self._setup_test_database(post_repository)
await post_repository.add_post(sample_post_with_helper)
helper_message_id = 99999
helper_post = TelegramPost(
message_id=helper_message_id,
text="^",
author_id=67890,
helper_text_message_id=sample_post_with_helper.message_id,
created_at=int(datetime.now().timestamp()),
status="suggest",
)
await post_repository.add_post(helper_post)
await post_repository.update_helper_message(
sample_post_with_helper.message_id, helper_message_id
)
await post_repository.update_status_for_media_group_by_helper_id(
helper_message_id, "declined"
)
rows = await post_repository._execute_query_with_result(
"SELECT status FROM post_from_telegram_suggest "
"WHERE message_id = ? OR helper_text_message_id = ?",
(helper_message_id, helper_message_id),
)
assert len(rows) == 2
for row in rows:
assert row[0] == "declined"