Merge pull request 'fix(database): replace type: ignore with assert for type narrowing in LegacyDataMigrator' (#3241) from fix/type-safety-legacy-migrator-type-ignore into master
CI / push-validation (push) Successful in 22s
CI / helm (push) Successful in 27s
CI / build (push) Successful in 28s
CI / lint (push) Successful in 39s
CI / typecheck (push) Successful in 50s
CI / quality (push) Successful in 1m4s
CI / security (push) Successful in 1m9s
CI / benchmark-regression (push) Failing after 38s
CI / e2e_tests (push) Successful in 51s
CI / unit_tests (push) Successful in 6m59s
CI / docker (push) Successful in 1m29s
CI / push-validation (pull_request) Successful in 21s
CI / helm (pull_request) Successful in 25s
CI / build (pull_request) Successful in 30s
CI / lint (pull_request) Successful in 48s
CI / typecheck (pull_request) Successful in 59s
CI / security (pull_request) Successful in 1m6s
CI / quality (pull_request) Successful in 1m16s
CI / unit_tests (pull_request) Successful in 5m50s
CI / coverage (push) Successful in 12m24s
CI / docker (pull_request) Successful in 1m18s
CI / integration_tests (push) Successful in 27m32s
CI / status-check (push) Successful in 3s
CI / coverage (pull_request) Successful in 11m23s
CI / integration_tests (pull_request) Successful in 25m34s
CI / status-check (pull_request) Successful in 3s
CI / benchmark-publish (push) Has started running
CI / push-validation (push) Successful in 22s
CI / helm (push) Successful in 27s
CI / build (push) Successful in 28s
CI / lint (push) Successful in 39s
CI / typecheck (push) Successful in 50s
CI / quality (push) Successful in 1m4s
CI / security (push) Successful in 1m9s
CI / benchmark-regression (push) Failing after 38s
CI / e2e_tests (push) Successful in 51s
CI / unit_tests (push) Successful in 6m59s
CI / docker (push) Successful in 1m29s
CI / push-validation (pull_request) Successful in 21s
CI / helm (pull_request) Successful in 25s
CI / build (pull_request) Successful in 30s
CI / lint (pull_request) Successful in 48s
CI / typecheck (pull_request) Successful in 59s
CI / security (pull_request) Successful in 1m6s
CI / quality (pull_request) Successful in 1m16s
CI / unit_tests (pull_request) Successful in 5m50s
CI / coverage (push) Successful in 12m24s
CI / docker (pull_request) Successful in 1m18s
CI / integration_tests (push) Successful in 27m32s
CI / status-check (push) Successful in 3s
CI / coverage (pull_request) Successful in 11m23s
CI / integration_tests (pull_request) Successful in 25m34s
CI / status-check (pull_request) Successful in 3s
CI / benchmark-publish (push) Has started running
This commit was merged in pull request #3241.
This commit is contained in:
@@ -204,9 +204,17 @@ Feature: Legacy Data Migrator Coverage
|
||||
Given I have a legacy project with read-only JSON files
|
||||
When I run the legacy data migration
|
||||
Then the migration should handle backup errors gracefully
|
||||
|
||||
Scenario: get_all_for_project is called only once for multiple plans
|
||||
Given I have a legacy project with multiple plans to migrate efficiently
|
||||
When I run the legacy data migration with query tracking
|
||||
Then get_all_for_project should be called exactly once
|
||||
And the migration should return true
|
||||
And all plans should be migrated correctly
|
||||
|
||||
Scenario: Map existing plan IDs correctly during migration
|
||||
Given I have a legacy project with plans already in database
|
||||
When I run the legacy data migration
|
||||
Then existing plans should not be duplicated
|
||||
And the migration should return true
|
||||
And the existing plan id should be mapped without type suppression
|
||||
|
||||
@@ -1085,3 +1085,17 @@ def step_check_all_plans_migrated(context: Context) -> None:
|
||||
assert plan_names == expected_names, (
|
||||
f"Expected plans {expected_names}, got {plan_names}"
|
||||
)
|
||||
|
||||
|
||||
@then("the existing plan id should be mapped without type suppression")
|
||||
def step_check_existing_plan_id_mapped(context: Context) -> None:
|
||||
"""Check that existing plan id was mapped correctly via assert type narrowing."""
|
||||
with context.unit_of_work.transaction() as ctx:
|
||||
project = ctx.projects.get_by_name("existing_plans")
|
||||
assert project is not None, "Project 'existing_plans' should exist in database"
|
||||
plans = ctx.plans.get_all_for_project(project.id)
|
||||
main_plans = [p for p in plans if p.name == "main"]
|
||||
assert len(main_plans) == 1, "Should have exactly one 'main' plan"
|
||||
assert main_plans[0].id is not None, (
|
||||
"Existing plan id must be non-None (assert narrowing validates this)"
|
||||
)
|
||||
|
||||
@@ -110,7 +110,8 @@ class LegacyDataMigrator:
|
||||
(p for p in all_plans if p.name == plan_name), None
|
||||
)
|
||||
if existing_plan:
|
||||
plan_id_map[plan_name] = existing_plan.id # type: ignore
|
||||
assert existing_plan.id is not None
|
||||
plan_id_map[plan_name] = existing_plan.id
|
||||
continue
|
||||
|
||||
# Create new plan
|
||||
|
||||
Reference in New Issue
Block a user