chore: verify formatting checks
This commit is contained in:
@@ -11,6 +11,7 @@ from bot.services.locale_override_service import (
|
|||||||
update_locale_overrides,
|
update_locale_overrides,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _locale_languages(
|
def _locale_languages(
|
||||||
i18n: JsonI18n,
|
i18n: JsonI18n,
|
||||||
overrides: Optional[List[Dict[str, Any]]] = None,
|
overrides: Optional[List[Dict[str, Any]]] = None,
|
||||||
|
|||||||
@@ -76,9 +76,7 @@ WEBAPP_DEFAULT_LOGO_FILE = WEBAPP_DEFAULT_BRAND_DIR / "default-logo.webp"
|
|||||||
WEBAPP_DEFAULT_LOGO_PATH = "/webapp-default-logo.webp"
|
WEBAPP_DEFAULT_LOGO_PATH = "/webapp-default-logo.webp"
|
||||||
WEBAPP_DEFAULT_FAVICON_DIGEST = "19b2a242e5b7bc2d"
|
WEBAPP_DEFAULT_FAVICON_DIGEST = "19b2a242e5b7bc2d"
|
||||||
WEBAPP_DEFAULT_FAVICON_DIR = WEBAPP_DEFAULT_BRAND_DIR / "favicons" / WEBAPP_DEFAULT_FAVICON_DIGEST
|
WEBAPP_DEFAULT_FAVICON_DIR = WEBAPP_DEFAULT_BRAND_DIR / "favicons" / WEBAPP_DEFAULT_FAVICON_DIGEST
|
||||||
WEBAPP_DEFAULT_FAVICON_URL = (
|
WEBAPP_DEFAULT_FAVICON_URL = f"{WEBAPP_FAVICON_PATH}/{WEBAPP_DEFAULT_FAVICON_DIGEST}/icon-180.png"
|
||||||
f"{WEBAPP_FAVICON_PATH}/{WEBAPP_DEFAULT_FAVICON_DIGEST}/icon-180.png"
|
|
||||||
)
|
|
||||||
WEBAPP_EMOJI_CACHE_DIR = APP_ROOT / "data" / "webapp-emoji"
|
WEBAPP_EMOJI_CACHE_DIR = APP_ROOT / "data" / "webapp-emoji"
|
||||||
WEBAPP_CONFIG_PLACEHOLDER = "<!-- WEBAPP_CONFIG_SCRIPT -->"
|
WEBAPP_CONFIG_PLACEHOLDER = "<!-- WEBAPP_CONFIG_SCRIPT -->"
|
||||||
WEBAPP_I18N_PLACEHOLDER = "<!-- WEBAPP_I18N_SCRIPT -->"
|
WEBAPP_I18N_PLACEHOLDER = "<!-- WEBAPP_I18N_SCRIPT -->"
|
||||||
|
|||||||
@@ -636,15 +636,11 @@ async def device_topup_options_route(request: web.Request) -> web.Response:
|
|||||||
)
|
)
|
||||||
tariff = config.require(sub.tariff_key)
|
tariff = config.require(sub.tariff_key)
|
||||||
if tariff.billing_model != "period":
|
if tariff.billing_model != "period":
|
||||||
return _json_error(
|
return _json_error(400, "device_topup_unavailable", "Device top-up is not available")
|
||||||
400, "device_topup_unavailable", "Device top-up is not available"
|
|
||||||
)
|
|
||||||
lang = db_user.language_code or settings.DEFAULT_LANGUAGE
|
lang = db_user.language_code or settings.DEFAULT_LANGUAGE
|
||||||
active = await subscription_service.get_active_subscription_details(session, user_id)
|
active = await subscription_service.get_active_subscription_details(session, user_id)
|
||||||
renewal_available = bool(active and active.get("device_topup_renewal_available"))
|
renewal_available = bool(active and active.get("device_topup_renewal_available"))
|
||||||
extra_hwid_valid_until = (
|
extra_hwid_valid_until = active.get("extra_hwid_devices_valid_until") if active else None
|
||||||
active.get("extra_hwid_devices_valid_until") if active else None
|
|
||||||
)
|
|
||||||
extra_hwid_valid_until_text = (
|
extra_hwid_valid_until_text = (
|
||||||
active.get("extra_hwid_devices_valid_until_text") if active else None
|
active.get("extra_hwid_devices_valid_until_text") if active else None
|
||||||
) or _billing_datetime_text(extra_hwid_valid_until)
|
) or _billing_datetime_text(extra_hwid_valid_until)
|
||||||
@@ -716,9 +712,7 @@ async def device_topup_options_route(request: web.Request) -> web.Response:
|
|||||||
"extra_hwid_devices": int(active.get("extra_hwid_devices") or 0)
|
"extra_hwid_devices": int(active.get("extra_hwid_devices") or 0)
|
||||||
if active
|
if active
|
||||||
else int(sub.extra_hwid_devices or 0),
|
else int(sub.extra_hwid_devices or 0),
|
||||||
"extra_hwid_devices_valid_until": _billing_iso_datetime(
|
"extra_hwid_devices_valid_until": _billing_iso_datetime(extra_hwid_valid_until),
|
||||||
extra_hwid_valid_until
|
|
||||||
),
|
|
||||||
"extra_hwid_devices_valid_until_text": extra_hwid_valid_until_text,
|
"extra_hwid_devices_valid_until_text": extra_hwid_valid_until_text,
|
||||||
"renewal_available": renewal_available,
|
"renewal_available": renewal_available,
|
||||||
"renewal_recommended_count": int(active.get("extra_hwid_devices") or 0)
|
"renewal_recommended_count": int(active.get("extra_hwid_devices") or 0)
|
||||||
@@ -978,9 +972,7 @@ async def _create_subscription_payment(
|
|||||||
hwid_pricing_period_months=hwid_quote.get("pricing_period_months")
|
hwid_pricing_period_months=hwid_quote.get("pricing_period_months")
|
||||||
if hwid_quote
|
if hwid_quote
|
||||||
else None,
|
else None,
|
||||||
hwid_proration_ratio=hwid_quote.get("proration_ratio")
|
hwid_proration_ratio=hwid_quote.get("proration_ratio") if hwid_quote else None,
|
||||||
if hwid_quote
|
|
||||||
else None,
|
|
||||||
hwid_full_price=hwid_quote.get("full_price") if hwid_quote else None,
|
hwid_full_price=hwid_quote.get("full_price") if hwid_quote else None,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -611,14 +611,12 @@ def _serialize_tariff_change_target(
|
|||||||
"mode": "recalc_days",
|
"mode": "recalc_days",
|
||||||
"kind": "free",
|
"kind": "free",
|
||||||
"title": "recalc_days",
|
"title": "recalc_days",
|
||||||
"days_after": int(options.get("recalc_days") or 0),
|
"days_after": int(options.get("recalc_days") or 0),
|
||||||
"remaining_days": int(options.get("remaining_days") or 0),
|
"remaining_days": int(options.get("remaining_days") or 0),
|
||||||
"converted_hwid_value_rub": float(
|
"converted_hwid_value_rub": float(options.get("converted_hwid_value_rub") or 0),
|
||||||
options.get("converted_hwid_value_rub") or 0
|
"converted_hwid_days": int(options.get("converted_hwid_days") or 0),
|
||||||
),
|
}
|
||||||
"converted_hwid_days": int(options.get("converted_hwid_days") or 0),
|
)
|
||||||
}
|
|
||||||
)
|
|
||||||
paid_diff = float(options.get("paid_diff_rub") or 0)
|
paid_diff = float(options.get("paid_diff_rub") or 0)
|
||||||
if paid_diff > 0:
|
if paid_diff > 0:
|
||||||
actions.append(
|
actions.append(
|
||||||
@@ -638,9 +636,7 @@ def _serialize_tariff_change_target(
|
|||||||
"title": "convert_days_to_gb",
|
"title": "convert_days_to_gb",
|
||||||
"converted_gb": float(options.get("converted_gb") or 0),
|
"converted_gb": float(options.get("converted_gb") or 0),
|
||||||
"remaining_days": int(options.get("remaining_days") or 0),
|
"remaining_days": int(options.get("remaining_days") or 0),
|
||||||
"converted_hwid_value_rub": float(
|
"converted_hwid_value_rub": float(options.get("converted_hwid_value_rub") or 0),
|
||||||
options.get("converted_hwid_value_rub") or 0
|
|
||||||
),
|
|
||||||
"converted_hwid_gb": float(options.get("converted_hwid_gb") or 0),
|
"converted_hwid_gb": float(options.get("converted_hwid_gb") or 0),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1203,15 +1203,13 @@ async def _perform_sync_impl(
|
|||||||
merge_panel_patches = int(merge_result.get("panel_patches", 0))
|
merge_panel_patches = int(merge_result.get("panel_patches", 0))
|
||||||
if merge_panel_patches:
|
if merge_panel_patches:
|
||||||
panel_patch_count += merge_panel_patches
|
panel_patch_count += merge_panel_patches
|
||||||
panel_patch_reason_counts[
|
panel_patch_reason_counts["duplicate_panel_merge_extend"] += (
|
||||||
"duplicate_panel_merge_extend"
|
merge_panel_patches
|
||||||
] += merge_panel_patches
|
)
|
||||||
if merge_result["resolved"]:
|
if merge_result["resolved"]:
|
||||||
users_updated += 1
|
users_updated += 1
|
||||||
users_uuid_updated += 1
|
users_uuid_updated += 1
|
||||||
local_update_reason_counts.update(
|
local_update_reason_counts.update(["duplicate_panel_identity_resolved"])
|
||||||
["duplicate_panel_identity_resolved"]
|
|
||||||
)
|
|
||||||
panel_uuids_by_telegram_id.get(telegram_id_from_panel, set()).discard(
|
panel_uuids_by_telegram_id.get(telegram_id_from_panel, set()).discard(
|
||||||
str(panel_uuid)
|
str(panel_uuid)
|
||||||
)
|
)
|
||||||
@@ -1322,9 +1320,7 @@ async def _perform_sync_impl(
|
|||||||
current_panel_user=panel_user_for_identity,
|
current_panel_user=panel_user_for_identity,
|
||||||
reasons=panel_reasons,
|
reasons=panel_reasons,
|
||||||
panel_view=(
|
panel_view=(
|
||||||
"list"
|
"list" if missing_identity_fields_match else "full_fetch"
|
||||||
if missing_identity_fields_match
|
|
||||||
else "full_fetch"
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
panel_patch_count += 1
|
panel_patch_count += 1
|
||||||
|
|||||||
@@ -543,9 +543,7 @@ async def hwid_devices_list_callback(
|
|||||||
renewal=renewal_available,
|
renewal=renewal_available,
|
||||||
)
|
)
|
||||||
text_key = (
|
text_key = (
|
||||||
"select_hwid_device_renewal_package"
|
"select_hwid_device_renewal_package" if renewal_available else "select_hwid_device_package"
|
||||||
if renewal_available
|
|
||||||
else "select_hwid_device_package"
|
|
||||||
)
|
)
|
||||||
await callback.message.edit_text(
|
await callback.message.edit_text(
|
||||||
get_text(
|
get_text(
|
||||||
|
|||||||
@@ -160,10 +160,7 @@ def locale_language_flag(code: object) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def sort_locale_language_codes(codes: Iterable[object]) -> List[str]:
|
def sort_locale_language_codes(codes: Iterable[object]) -> List[str]:
|
||||||
normalized = {
|
normalized = {normalize_locale_language_code(code, prefer_known_base=False) for code in codes}
|
||||||
normalize_locale_language_code(code, prefer_known_base=False)
|
|
||||||
for code in codes
|
|
||||||
}
|
|
||||||
normalized = {code for code in normalized if code and is_valid_locale_language_code(code)}
|
normalized = {code for code in normalized if code and is_valid_locale_language_code(code)}
|
||||||
preferred = [code for code in DEFAULT_LANGUAGE_ORDER if code in normalized]
|
preferred = [code for code in DEFAULT_LANGUAGE_ORDER if code in normalized]
|
||||||
rest = sorted(code for code in normalized if code not in DEFAULT_LANGUAGE_ORDER)
|
rest = sorted(code for code in normalized if code not in DEFAULT_LANGUAGE_ORDER)
|
||||||
|
|||||||
@@ -169,9 +169,7 @@ class YooKassaService:
|
|||||||
@property
|
@property
|
||||||
def configured(self) -> bool:
|
def configured(self) -> bool:
|
||||||
if not (
|
if not (
|
||||||
provider_runtime_enabled(self.config)
|
provider_runtime_enabled(self.config) and self.config.SHOP_ID and self.config.SECRET_KEY
|
||||||
and self.config.SHOP_ID
|
|
||||||
and self.config.SECRET_KEY
|
|
||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
self._ensure_sdk_configured()
|
self._ensure_sdk_configured()
|
||||||
@@ -1327,9 +1325,7 @@ async def _initiate_yk_payment(
|
|||||||
"purchased_gb": float(months)
|
"purchased_gb": float(months)
|
||||||
if sale_base in {"traffic", "traffic_package", "topup", "premium_topup"}
|
if sale_base in {"traffic", "traffic_package", "topup", "premium_topup"}
|
||||||
else None,
|
else None,
|
||||||
"purchased_hwid_devices": int(months)
|
"purchased_hwid_devices": int(months) if sale_base in HWID_DEVICE_SALE_BASES else None,
|
||||||
if sale_base in HWID_DEVICE_SALE_BASES
|
|
||||||
else None,
|
|
||||||
"hwid_valid_from": hwid_quote.get("valid_from") if hwid_quote else None,
|
"hwid_valid_from": hwid_quote.get("valid_from") if hwid_quote else None,
|
||||||
"hwid_valid_until": hwid_quote.get("valid_until") if hwid_quote else None,
|
"hwid_valid_until": hwid_quote.get("valid_until") if hwid_quote else None,
|
||||||
"hwid_pricing_period_months": hwid_quote.get("pricing_period_months")
|
"hwid_pricing_period_months": hwid_quote.get("pricing_period_months")
|
||||||
|
|||||||
@@ -213,9 +213,7 @@ class BackupWorker:
|
|||||||
if not archive_path.exists():
|
if not archive_path.exists():
|
||||||
return archive_path
|
return archive_path
|
||||||
for index in range(2, 1000):
|
for index in range(2, 1000):
|
||||||
candidate = archive_path.with_name(
|
candidate = archive_path.with_name(f"{archive_path.stem}-{index}{archive_path.suffix}")
|
||||||
f"{archive_path.stem}-{index}{archive_path.suffix}"
|
|
||||||
)
|
|
||||||
if not candidate.exists():
|
if not candidate.exists():
|
||||||
return candidate
|
return candidate
|
||||||
raise RuntimeError("Could not allocate a unique backup archive filename")
|
raise RuntimeError("Could not allocate a unique backup archive filename")
|
||||||
|
|||||||
@@ -68,9 +68,7 @@ class PanelWebhookService:
|
|||||||
text = _(message_key, **kwargs)
|
text = _(message_key, **kwargs)
|
||||||
if extra_text:
|
if extra_text:
|
||||||
text = f"{text}\n\n{extra_text}"
|
text = f"{text}\n\n{extra_text}"
|
||||||
await self.bot.send_message(
|
await self.bot.send_message(user_id, text, reply_markup=reply_markup)
|
||||||
user_id, text, reply_markup=reply_markup
|
|
||||||
)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception("Failed to send notification to %s", user_id)
|
logging.exception("Failed to send notification to %s", user_id)
|
||||||
|
|
||||||
|
|||||||
@@ -416,9 +416,7 @@ class SubscriptionLifecycleMixin:
|
|||||||
"Failed to recalculate active HWID devices for renewal of user %s",
|
"Failed to recalculate active HWID devices for renewal of user %s",
|
||||||
user_id,
|
user_id,
|
||||||
)
|
)
|
||||||
extra_hwid_devices = int(
|
extra_hwid_devices = int(getattr(current_active_sub, "extra_hwid_devices", 0) or 0)
|
||||||
getattr(current_active_sub, "extra_hwid_devices", 0) or 0
|
|
||||||
)
|
|
||||||
premium_topup_balance_bytes = int(
|
premium_topup_balance_bytes = int(
|
||||||
getattr(current_active_sub, "premium_topup_balance_bytes", 0) or 0
|
getattr(current_active_sub, "premium_topup_balance_bytes", 0) or 0
|
||||||
)
|
)
|
||||||
@@ -813,9 +811,7 @@ class SubscriptionLifecycleMixin:
|
|||||||
subscription_id=local_active_sub.subscription_id,
|
subscription_id=local_active_sub.subscription_id,
|
||||||
at=datetime.now(timezone.utc),
|
at=datetime.now(timezone.utc),
|
||||||
)
|
)
|
||||||
active_extra_hwid_devices = int(
|
active_extra_hwid_devices = int(hwid_entitlement_summary.get("active_devices") or 0)
|
||||||
hwid_entitlement_summary.get("active_devices") or 0
|
|
||||||
)
|
|
||||||
if active_extra_hwid_devices != int(local_active_sub.extra_hwid_devices or 0):
|
if active_extra_hwid_devices != int(local_active_sub.extra_hwid_devices or 0):
|
||||||
await subscription_dal.update_subscription(
|
await subscription_dal.update_subscription(
|
||||||
session,
|
session,
|
||||||
@@ -901,9 +897,7 @@ class SubscriptionLifecycleMixin:
|
|||||||
else None,
|
else None,
|
||||||
"extra_hwid_devices": active_extra_hwid_devices,
|
"extra_hwid_devices": active_extra_hwid_devices,
|
||||||
"extra_hwid_devices_valid_until": hwid_entitlement_summary.get("active_until"),
|
"extra_hwid_devices_valid_until": hwid_entitlement_summary.get("active_until"),
|
||||||
"extra_hwid_devices_next_valid_from": hwid_entitlement_summary.get(
|
"extra_hwid_devices_next_valid_from": hwid_entitlement_summary.get("next_valid_from"),
|
||||||
"next_valid_from"
|
|
||||||
),
|
|
||||||
"user_bot_username": db_user.username,
|
"user_bot_username": db_user.username,
|
||||||
"is_panel_data": True,
|
"is_panel_data": True,
|
||||||
"max_devices": hwid_limit,
|
"max_devices": hwid_limit,
|
||||||
|
|||||||
@@ -441,9 +441,7 @@ class TariffMixin:
|
|||||||
|
|
||||||
if options.get("mode") == "period_to_period":
|
if options.get("mode") == "period_to_period":
|
||||||
target_monthly = float(options.get("target_monthly_rub") or 0)
|
target_monthly = float(options.get("target_monthly_rub") or 0)
|
||||||
hwid_days = (
|
hwid_days = math.floor((value_rub / target_monthly) * 30) if target_monthly > 0 else 0
|
||||||
math.floor((value_rub / target_monthly) * 30) if target_monthly > 0 else 0
|
|
||||||
)
|
|
||||||
options["converted_hwid_days"] = max(0, hwid_days)
|
options["converted_hwid_days"] = max(0, hwid_days)
|
||||||
options["recalc_days"] = int(options.get("recalc_days") or 0) + max(0, hwid_days)
|
options["recalc_days"] = int(options.get("recalc_days") or 0) + max(0, hwid_days)
|
||||||
options["paid_diff_rub"] = max(
|
options["paid_diff_rub"] = max(
|
||||||
|
|||||||
@@ -54,9 +54,7 @@ class TrafficMixin:
|
|||||||
|
|
||||||
purchase_bytes = self.gb_to_bytes(traffic_gb)
|
purchase_bytes = self.gb_to_bytes(traffic_gb)
|
||||||
extra_hwid_devices = (
|
extra_hwid_devices = (
|
||||||
await self._active_hwid_extra_devices_for_sub(session, active_sub)
|
await self._active_hwid_extra_devices_for_sub(session, active_sub) if active_sub else 0
|
||||||
if active_sub
|
|
||||||
else 0
|
|
||||||
)
|
)
|
||||||
base_hwid_limit = self._base_hwid_limit_for_tariff(tariff)
|
base_hwid_limit = self._base_hwid_limit_for_tariff(tariff)
|
||||||
effective_hwid_limit = self._effective_hwid_limit(base_hwid_limit, extra_hwid_devices)
|
effective_hwid_limit = self._effective_hwid_limit(base_hwid_limit, extra_hwid_devices)
|
||||||
|
|||||||
@@ -795,8 +795,7 @@ class TariffTrafficWorker:
|
|||||||
if not cached_at:
|
if not cached_at:
|
||||||
return False
|
return False
|
||||||
return (
|
return (
|
||||||
time.monotonic() - float(cached_at)
|
time.monotonic() - float(cached_at) < TARIFF_WORKER_SQUAD_CONFIRMATION_CACHE_TTL_SECONDS
|
||||||
< TARIFF_WORKER_SQUAD_CONFIRMATION_CACHE_TTL_SECONDS
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def _remember_premium_squad_match(self, cache_key: tuple[str, tuple[str, ...]]) -> None:
|
def _remember_premium_squad_match(self, cache_key: tuple[str, tuple[str, ...]]) -> None:
|
||||||
|
|||||||
@@ -41,9 +41,7 @@ async def sum_traffic_topups(
|
|||||||
if created_at_gte is not None:
|
if created_at_gte is not None:
|
||||||
conditions.append(TrafficTopup.created_at >= created_at_gte)
|
conditions.append(TrafficTopup.created_at >= created_at_gte)
|
||||||
result = await session.execute(
|
result = await session.execute(
|
||||||
select(func.coalesce(func.sum(TrafficTopup.purchased_bytes), 0)).where(
|
select(func.coalesce(func.sum(TrafficTopup.purchased_bytes), 0)).where(and_(*conditions))
|
||||||
and_(*conditions)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
return int(result.scalar() or 0)
|
return int(result.scalar() or 0)
|
||||||
|
|
||||||
|
|||||||
@@ -925,9 +925,7 @@ def _migration_0029_add_hwid_device_purchase_validity(connection: Connection) ->
|
|||||||
if "hwid_device_purchases" not in table_names or "subscriptions" not in table_names:
|
if "hwid_device_purchases" not in table_names or "subscriptions" not in table_names:
|
||||||
return
|
return
|
||||||
|
|
||||||
columns: Set[str] = {
|
columns: Set[str] = {col["name"] for col in inspector.get_columns("hwid_device_purchases")}
|
||||||
col["name"] for col in inspector.get_columns("hwid_device_purchases")
|
|
||||||
}
|
|
||||||
if "valid_from" not in columns:
|
if "valid_from" not in columns:
|
||||||
connection.execute(
|
connection.execute(
|
||||||
text("ALTER TABLE hwid_device_purchases ADD COLUMN valid_from TIMESTAMPTZ")
|
text("ALTER TABLE hwid_device_purchases ADD COLUMN valid_from TIMESTAMPTZ")
|
||||||
@@ -1002,9 +1000,7 @@ def _migration_0030_add_hwid_pricing_metadata(connection: Connection) -> None:
|
|||||||
connection.execute(text(f"ALTER TABLE payments ADD COLUMN {column} {ddl_type}"))
|
connection.execute(text(f"ALTER TABLE payments ADD COLUMN {column} {ddl_type}"))
|
||||||
|
|
||||||
if "tariff_changes" in table_names:
|
if "tariff_changes" in table_names:
|
||||||
change_columns: Set[str] = {
|
change_columns: Set[str] = {col["name"] for col in inspector.get_columns("tariff_changes")}
|
||||||
col["name"] for col in inspector.get_columns("tariff_changes")
|
|
||||||
}
|
|
||||||
change_additions = {
|
change_additions = {
|
||||||
"converted_hwid_value_rub": "NUMERIC",
|
"converted_hwid_value_rub": "NUMERIC",
|
||||||
"converted_hwid_days": "INTEGER",
|
"converted_hwid_days": "INTEGER",
|
||||||
|
|||||||
@@ -42,9 +42,7 @@ class _Service:
|
|||||||
|
|
||||||
class HwidDeviceWorkerTests(unittest.IsolatedAsyncioTestCase):
|
class HwidDeviceWorkerTests(unittest.IsolatedAsyncioTestCase):
|
||||||
async def test_worker_resets_expired_hwid_entitlement_on_panel(self):
|
async def test_worker_resets_expired_hwid_entitlement_on_panel(self):
|
||||||
panel = SimpleNamespace(
|
panel = SimpleNamespace(update_user_details_on_panel=AsyncMock(return_value={"ok": True}))
|
||||||
update_user_details_on_panel=AsyncMock(return_value={"ok": True})
|
|
||||||
)
|
|
||||||
worker = TariffTrafficWorker(
|
worker = TariffTrafficWorker(
|
||||||
settings=SimpleNamespace(),
|
settings=SimpleNamespace(),
|
||||||
session_factory=None,
|
session_factory=None,
|
||||||
|
|||||||
@@ -66,9 +66,7 @@ def _source_files(*roots: str) -> list[Path]:
|
|||||||
result.append(path)
|
result.append(path)
|
||||||
else:
|
else:
|
||||||
result.extend(
|
result.extend(
|
||||||
child
|
child for child in path.rglob("*") if child.suffix in {".py", ".js", ".svelte"}
|
||||||
for child in path.rglob("*")
|
|
||||||
if child.suffix in {".py", ".js", ".svelte"}
|
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -321,9 +319,7 @@ def test_admin_locale_keys_are_split_into_smaller_internal_groups():
|
|||||||
"admin_themes_catalog_title": "admin_appearance",
|
"admin_themes_catalog_title": "admin_appearance",
|
||||||
"appearance_logo_uploaded_pending": "admin_appearance",
|
"appearance_logo_uploaded_pending": "admin_appearance",
|
||||||
"admin_settings_field_yookassa_enabled_label": "admin_settings_payments",
|
"admin_settings_field_yookassa_enabled_label": "admin_settings_payments",
|
||||||
"admin_settings_field_subscription_guides_enabled_label": (
|
"admin_settings_field_subscription_guides_enabled_label": ("admin_settings_subscriptions"),
|
||||||
"admin_settings_subscriptions"
|
|
||||||
),
|
|
||||||
"admin_settings_field_log_level_label": "admin_settings_notifications",
|
"admin_settings_field_log_level_label": "admin_settings_notifications",
|
||||||
"back_to_admin_panel_button": "admin_navigation",
|
"back_to_admin_panel_button": "admin_navigation",
|
||||||
"admin_translations_languages_title": "admin_translations",
|
"admin_translations_languages_title": "admin_translations",
|
||||||
@@ -534,9 +530,7 @@ def test_load_locale_overrides_uses_db_when_file_missing(tmp_path):
|
|||||||
|
|
||||||
assert count == 1
|
assert count == 1
|
||||||
assert i18n.gettext("ru", "welcome") == "Из БД"
|
assert i18n.gettext("ru", "welcome") == "Из БД"
|
||||||
assert json.loads(overrides_path.read_text(encoding="utf-8")) == {
|
assert json.loads(overrides_path.read_text(encoding="utf-8")) == {"ru": {"welcome": "Из БД"}}
|
||||||
"ru": {"welcome": "Из БД"}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def test_load_locale_overrides_creates_empty_file_when_file_missing_and_db_empty(tmp_path):
|
def test_load_locale_overrides_creates_empty_file_when_file_missing_and_db_empty(tmp_path):
|
||||||
@@ -706,9 +700,7 @@ def test_update_locale_overrides_accepts_extra_language(tmp_path):
|
|||||||
assert db_state == {"uk": {"welcome": "Вітаю"}}
|
assert db_state == {"uk": {"welcome": "Вітаю"}}
|
||||||
assert i18n.gettext("uk", "welcome") == "Вітаю"
|
assert i18n.gettext("uk", "welcome") == "Вітаю"
|
||||||
assert i18n.gettext("uk", "plain") == "База"
|
assert i18n.gettext("uk", "plain") == "База"
|
||||||
assert json.loads(overrides_path.read_text(encoding="utf-8")) == {
|
assert json.loads(overrides_path.read_text(encoding="utf-8")) == {"uk": {"welcome": "Вітаю"}}
|
||||||
"uk": {"welcome": "Вітаю"}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def test_update_locale_overrides_fails_when_active_file_cannot_be_written(tmp_path):
|
def test_update_locale_overrides_fails_when_active_file_cannot_be_written(tmp_path):
|
||||||
|
|||||||
@@ -64,14 +64,16 @@ class MigrationDocumentationFactsTests(unittest.TestCase):
|
|||||||
missing = sorted(name for name in EXPECTED_CONTAINER_NAMES if name not in self.doc)
|
missing = sorted(name for name in EXPECTED_CONTAINER_NAMES if name not in self.doc)
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
missing,
|
missing,
|
||||||
f"migrations/remnawave-tg-shop.md is missing container names from current compose: {missing}",
|
"migrations/remnawave-tg-shop.md is missing container names "
|
||||||
|
f"from current compose: {missing}",
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_doc_lists_every_volume_in_current_compose(self):
|
def test_doc_lists_every_volume_in_current_compose(self):
|
||||||
missing = sorted(name for name in EXPECTED_VOLUME_NAMES if name not in self.doc)
|
missing = sorted(name for name in EXPECTED_VOLUME_NAMES if name not in self.doc)
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
missing,
|
missing,
|
||||||
f"migrations/remnawave-tg-shop.md is missing volume names from current compose: {missing}",
|
"migrations/remnawave-tg-shop.md is missing volume names "
|
||||||
|
f"from current compose: {missing}",
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_doc_warns_about_renamed_telegram_webhook_secret(self):
|
def test_doc_warns_about_renamed_telegram_webhook_secret(self):
|
||||||
@@ -234,7 +236,8 @@ class DocComposeFileReferencesTests(unittest.TestCase):
|
|||||||
self.assertIn(relpath, doc)
|
self.assertIn(relpath, doc)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
(REPO_ROOT / relpath).is_file(),
|
(REPO_ROOT / relpath).is_file(),
|
||||||
f"{relpath} is referenced in migrations/remnawave-tg-shop.md but missing on disk",
|
f"{relpath} is referenced in migrations/remnawave-tg-shop.md "
|
||||||
|
"but missing on disk",
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_doc_references_migrator_module_path(self):
|
def test_doc_references_migrator_module_path(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user