docs: подробная документация (UX + код), фикс дублей, /help без подписки, v0.1.0+19

This commit is contained in:
admin committed 2026-10-06 18:31:44 +02:00
1 parent f5d6fa95bd
commit a2927052f4
5 files changed
+243 -123

No files matched your search

+29 -18
View File
@@ -324,23 +324,34 @@ class ScreenshotToneWorkflowTests(unittest.IsolatedAsyncioTestCase):
async def test_clear_command_resets_only_calling_user_profile_and_samples(self):
message = SimpleNamespace(
from_user=SimpleNamespace(id=25),
answer=AsyncMock(),
)
import tempfile
from pathlib import Path
async def run_in_thread(function, *args):
return function(*args)
with tempfile.TemporaryDirectory() as temp_dir:
db = str(Path(temp_dir) / "clear.sqlite3")
env = patch.dict("os.environ", {"BOT_DB_PATH": db}, clear=False)
env.start()
self.addCleanup(env.stop)
user_store.init_db(db)
user_store.ensure_subscription(25, db)
with (
patch.object(bot, "clear_user_data") as clear_data,
patch.object(bot.asyncio, "to_thread", side_effect=run_in_thread),
):
await bot.clear_command(message)
clear_data.assert_called_once_with(25)
answer = message.answer.await_args.args[0]
self.assertIn("API-логи", answer)
self.assertIn("скриншоты", answer)
message = SimpleNamespace(
from_user=SimpleNamespace(id=25),
answer=AsyncMock(),
)
async def run_in_thread(function, *args, **kwargs):
return function(*args, **kwargs)
with (
patch.object(bot, "clear_user_data") as clear_data,
patch.object(bot.asyncio, "to_thread", side_effect=run_in_thread),
):
await bot.clear_command(message)
clear_data.assert_called_once_with(25)
msg_calls = [c.args[0] for c in message.answer.call_args_list]
self.assertTrue(any("API-логи" in m for m in msg_calls))
self.assertTrue(any("скриншоты" in m for m in msg_calls))
class StorageTests(unittest.TestCase):
@@ -527,8 +538,8 @@ class SubscriptionTests(unittest.IsolatedAsyncioTestCase):
await bot.subscribe_command(message)
msg_calls = [c.args[0] for c in message.answer.call_args_list]
self.assertIn("Активирую подписку на 30 дней", msg_calls)
self.assertIn("Подписка активирована на 30 дн. Спасибо за оплату", msg_calls)
self.assertTrue(any("Активирую подписку на 30 дней" in m for m in msg_calls))
self.assertTrue(any("Подписка активирована на 30 дн." in m for m in msg_calls))
sub = user_store.subscription_row(102, self.db_path)
self.assertIsNotNone(sub["last_paid_at"])
self.assertEqual(sub["is_active"], 1)
@@ -566,7 +577,7 @@ class SubscriptionTests(unittest.IsolatedAsyncioTestCase):
# ответ должен быть о блокировке, а не о генерации
msg_calls = [c.args[0] for c in message.answer.call_args_list]
self.assertTrue(any("истёк" in msg for msg in msg_calls))
self.assertEqual(len(msg_calls), 1)
self.assertTrue(any("звёзд" in msg for msg in msg_calls))
async def test_clear_deactivates_subscription(self):
user_store.ensure_subscription(105, self.db_path)