weblate/ci/migrate-scripts/assert-pending.py
Michal Čihař 3d1f813e6e chore: split out migration testing scripts
This makes the code easier to read and possible to lint for obvious
errors.
2026-02-13 16:20:25 +01:00

29 lines
1 KiB
Python

# Copyright © Michal Čihař <michal@weblate.org>
#
# SPDX-License-Identifier: GPL-3.0-or-later
"""Assertion for pending changes migration."""
from weblate.trans.models import PendingUnitChange
change = PendingUnitChange.objects.get()
unit = change.unit
errors = []
if change.target != unit.target:
errors.append(f"Target mismatch: '{change.target}' != '{unit.target}'")
if change.explanation != unit.explanation:
errors.append(
f"Explanation mismatch: '{change.explanation}' != '{unit.explanation}'"
)
if change.state != unit.state:
errors.append(f"State mismatch: {change.state} != {unit.state}")
# The migration uses get_last_content_change to get author
author = unit.get_last_content_change()[0]
if change.author != author:
errors.append(f"Author mismatch: {change.author} != {author}")
if change.source_unit_explanation != unit.source_unit.explanation:
errors.append(
f"Source unit explanation mismatch: '{change.source_unit_explanation}' != '{unit.source_unit.explanation}'"
)
assert not errors, "\n".join(errors)