fix(subscription): show expiry clock time (MSK) when under a day
- subscription_time_left: replace floor-div '23 ч.'/'мин.' branches with the concrete expiry timestamp when less than a full day remains - add MSK_TIMEZONE (UTC+3) as display default; label time as '(МСК)' - add shared subscription_status_text helper, use it in status menu, post-payment reply and dev confirmation instead of floor-rounded days - tests: cover under-a-day clock format; fix stale to_thread mock
This commit is contained in:
1 parent
140f2f7263
commit
87f22fb249
6 files changed
+52
-17
No files matched your search
@@ -250,6 +250,18 @@ class ModeRoutingTests(unittest.IsolatedAsyncioTestCase):
|
||||
self.assertIn("Подписка активна", message.answers[0][0])
|
||||
self.assertIsNotNone(markup)
|
||||
|
||||
async def test_subscription_status_shows_clock_time_when_under_a_day(self):
|
||||
message = _StubMessage()
|
||||
sub = {"last_paid_at": "2026-01-01T00:00:00", "is_active": 1}
|
||||
with patch.object(
|
||||
bot.user_store, "subscription_time_left", return_value=(True, "31.10.2026 12:51 (МСК)", "")
|
||||
):
|
||||
await bot._show_subscription_info(cast(Any, message), cast(Any, sub))
|
||||
text = message.answers[0][0]
|
||||
self.assertIn("Подписка активна", text)
|
||||
self.assertIn("Закончится в 31.10.2026 12:51 (МСК)", text)
|
||||
self.assertNotIn("ч.", text)
|
||||
|
||||
async def test_subscription_action_button_shows_inline_plan_choices(self):
|
||||
message = _StubMessage(keyboards.BUY_SUBSCRIPTION_BUTTON)
|
||||
with patch.object(bot, "notify_development_deploy", new=AsyncMock()):
|
||||
|
||||
@@ -287,7 +287,7 @@ class SubscribeCommandTests(unittest.IsolatedAsyncioTestCase):
|
||||
with (
|
||||
patch.object(bot, "DEPLOY_ENV", "development"),
|
||||
patch.dict(os.environ, {"BOT_DB_PATH": db}),
|
||||
patch.object(bot.asyncio, "to_thread", new=AsyncMock(return_value=32)) as to_thread,
|
||||
patch.object(bot.asyncio, "to_thread", new=_direct_thread_mock()) as to_thread,
|
||||
):
|
||||
await bot.confirm_development_payment(callback)
|
||||
db_row = user_store.subscription_row(42, db)
|
||||
|
||||
Reference in new issue
Block a user