feat: expand platform APIs, sources, and test coverage
Some checks failed
CI/CD Pipeline / Run Tests (pull_request) Successful in 1m53s
CI/CD Pipeline / Telegram Notify Success (push) Has been cancelled
CI/CD Pipeline / Run Tests (push) Has been cancelled
CI/CD Pipeline / Code Quality Checks (push) Has been cancelled
CI/CD Pipeline / Code Quality Checks (pull_request) Failing after 2m54s
CI/CD Pipeline / Telegram Notify Success (pull_request) Has been skipped

This commit is contained in:
2026-03-17 12:56:48 +01:00
parent b505c67968
commit 3d298ce352
101 changed files with 8387 additions and 292 deletions

View File

@@ -79,7 +79,9 @@ class ExchangeConnectionService:
cursor.execute("SELECT 1")
except Exception as exc: # noqa: BLE001
cls._mark_connection_error(connection, str(exc))
raise ExchangeServiceError(f"Ошибка подключения к целевой БД: {exc}") from exc
raise ExchangeServiceError(
f"Ошибка подключения к целевой БД: {exc}"
) from exc
return alias
@@ -145,7 +147,9 @@ class ExchangeConnectionService:
connections[alias].ensure_connection()
except Exception as exc: # noqa: BLE001
cls._mark_connection_error(connection, str(exc))
raise ExchangeServiceError(f"Ошибка подключения к целевой БД: {exc}") from exc
raise ExchangeServiceError(
f"Ошибка подключения к целевой БД: {exc}"
) from exc
cls.validate_target_structure(
connection=connection,
@@ -187,7 +191,7 @@ class ExchangeConnectionService:
"ENGINE": "django.db.backends.postgresql",
"NAME": connection.database_name,
"USER": connection.username,
"PASSWORD": connection.password,
"PASSWORD": connection.get_decrypted_password(),
"HOST": connection.server,
"PORT": connection.port,
"OPTIONS": {
@@ -348,7 +352,10 @@ class ExchangeConnectionService:
@classmethod
def _requires_registry_organizations(cls, models_to_copy: list) -> bool:
return any(
any(field.name == "registry_organization" for field in model._meta.local_fields)
any(
field.name == "registry_organization"
for field in model._meta.local_fields
)
for model in models_to_copy
)
@@ -377,7 +384,10 @@ class ExchangeConnectionService:
pk_name = model._meta.pk.attname
for source_obj in queryset.iterator(chunk_size=chunk_size):
row_data = {field_name: getattr(source_obj, field_name) for field_name in field_names}
row_data = {
field_name: getattr(source_obj, field_name)
for field_name in field_names
}
batch.append(model(**row_data))
if len(batch) >= chunk_size:
@@ -441,7 +451,9 @@ class ExchangeConnectionService:
return len(existing_after - existing_before)
@classmethod
def _mark_connection_error(cls, connection: ExchangeConnection, error_message: str) -> None:
def _mark_connection_error(
cls, connection: ExchangeConnection, error_message: str
) -> None:
connection.last_checked_at = timezone.now()
connection.last_error = error_message
connection.save(update_fields=["last_checked_at", "last_error", "updated_at"])