Inject state dicts by name (prev/state), rename MigrationResult to MigrationReport.
State dict injection now works by parameter name (prev/state, annotation not checked) with DictPrev/DictState tags taking precedence; DictPre/DictPost remain as aliases. MigrationResult is renamed to MigrationReport with fields original/version/applied; the old type alias and a deprecated .migrations property remain. Old symbols stay covered by the original tests; new-style tests import from the kanta root. Includes some unrelated ruff formatting.
This commit is contained in:
@@ -206,3 +206,22 @@ def test_description_defaults_to_version_when_no_docstring():
|
||||
|
||||
result = reg.apply({}, current_version=0, kanta=kanta)
|
||||
assert result.migrations[0].description == "v1"
|
||||
|
||||
|
||||
def test_report_fields():
|
||||
from kanta import MigrationReport
|
||||
|
||||
reg = Migrations()
|
||||
kanta = _DummyKanta()
|
||||
|
||||
@reg.register
|
||||
def migrate_v1(d):
|
||||
d["x"] = 1
|
||||
|
||||
report = reg.apply({"x": 0}, current_version=0, kanta=kanta)
|
||||
assert isinstance(report, MigrationReport)
|
||||
assert report.original == 0
|
||||
assert report.version == 1
|
||||
assert [m.name for m in report.applied] == ["migrate_v1"]
|
||||
# Deprecated alias still works.
|
||||
assert report.migrations is report.applied
|
||||
|
||||
Reference in New Issue
Block a user