@@ -2408,77 +2408,97 @@ def test_earliest_start_date(sushi_context: Context):
24082408
24092409def test_deployability_index (make_snapshot ):
24102410 # Breaking change - should be both representantive / deployable
2411- snapshot_a = make_snapshot (SqlModel (name = "a" , query = parse_one ("SELECT 1" )))
2412- snapshot_a .categorize_as (SnapshotChangeCategory .BREAKING )
2411+ snapshot_breaking = make_snapshot (SqlModel (name = "a" , query = parse_one ("SELECT 1" )))
2412+ snapshot_breaking .categorize_as (SnapshotChangeCategory .BREAKING )
24132413
24142414 # Forward only breaking change - cannot be representative / deployable due to forward only
2415- snapshot_b = make_snapshot (SqlModel (name = "b" , query = parse_one ("SELECT 1" )))
2416- snapshot_b .categorize_as (SnapshotChangeCategory .BREAKING , forward_only = True )
2417- snapshot_b .parents = (snapshot_a .snapshot_id ,)
2415+ snapshot_breaking_forward_only = make_snapshot (SqlModel (name = "b" , query = parse_one ("SELECT 1" )))
2416+ snapshot_breaking_forward_only .categorize_as (SnapshotChangeCategory .BREAKING , forward_only = True )
2417+ snapshot_breaking_forward_only .parents = (snapshot_breaking .snapshot_id ,)
24182418
24192419 # Indirect breaking - cannot be representative / deployable due to forward only non-deployable parent
2420- snapshot_c = make_snapshot (SqlModel (name = "c" , query = parse_one ("SELECT 1" )))
2421- snapshot_c .categorize_as (SnapshotChangeCategory .INDIRECT_BREAKING )
2422- snapshot_c .parents = (snapshot_b .snapshot_id ,)
2420+ snapshot_indirect_breaking_1 = make_snapshot (SqlModel (name = "c" , query = parse_one ("SELECT 1" )))
2421+ snapshot_indirect_breaking_1 .categorize_as (SnapshotChangeCategory .INDIRECT_BREAKING )
2422+ snapshot_indirect_breaking_1 .parents = (snapshot_breaking_forward_only .snapshot_id ,)
24232423
24242424 # Indirect breaking - cannot be representative / deployable due to forward only non-deployable parent
2425- snapshot_d = make_snapshot (SqlModel (name = "d" , query = parse_one ("SELECT 1" )))
2426- snapshot_d .categorize_as (SnapshotChangeCategory .INDIRECT_BREAKING )
2427- snapshot_d .parents = (snapshot_b .snapshot_id , snapshot_a .snapshot_id )
2425+ snapshot_indirect_breaking_2 = make_snapshot (SqlModel (name = "d" , query = parse_one ("SELECT 1" )))
2426+ snapshot_indirect_breaking_2 .categorize_as (SnapshotChangeCategory .INDIRECT_BREAKING )
2427+ snapshot_indirect_breaking_2 .parents = (
2428+ snapshot_breaking_forward_only .snapshot_id ,
2429+ snapshot_breaking .snapshot_id ,
2430+ )
24282431
24292432 # Non breaking - representative / deployable due to no breaking changes
2430- snapshot_e = make_snapshot (SqlModel (name = "e" , query = parse_one ("SELECT 1" )))
2431- snapshot_e .categorize_as (SnapshotChangeCategory .NON_BREAKING )
2433+ snapshot_non_breaking = make_snapshot (SqlModel (name = "e" , query = parse_one ("SELECT 1" )))
2434+ snapshot_non_breaking .categorize_as (SnapshotChangeCategory .NON_BREAKING )
24322435
24332436 # Indirect breaking - can be representative / deployable due to deployable parents
2434- snapshot_f = make_snapshot (SqlModel (name = "f" , query = parse_one ("SELECT 1" )))
2435- snapshot_f .categorize_as (SnapshotChangeCategory .INDIRECT_BREAKING )
2436- snapshot_f .parents = (snapshot_e .snapshot_id , snapshot_a .snapshot_id )
2437+ snapshot_indirect_breaking_deployable_parents = make_snapshot (
2438+ SqlModel (name = "f" , query = parse_one ("SELECT 1" ))
2439+ )
2440+ snapshot_indirect_breaking_deployable_parents .categorize_as (
2441+ SnapshotChangeCategory .INDIRECT_BREAKING
2442+ )
2443+ snapshot_indirect_breaking_deployable_parents .parents = (
2444+ snapshot_non_breaking .snapshot_id ,
2445+ snapshot_breaking .snapshot_id ,
2446+ )
24372447
24382448 # Indirect non breaking - cannot be representative / deployable due to possible data drift from prod
2439- snapshot_g = make_snapshot (SqlModel (name = "g" , query = parse_one ("SELECT 1" )))
2440- snapshot_g .intervals = [(to_timestamp ("2023-01-01" ), to_timestamp ("2023-01-02" ))]
2441- snapshot_g .categorize_as (SnapshotChangeCategory .INDIRECT_NON_BREAKING )
2442- snapshot_g .parents = (snapshot_e .snapshot_id ,)
2443-
2449+ snapshot_indirect_non_breaking = make_snapshot (SqlModel (name = "g" , query = parse_one ("SELECT 1" )))
2450+ snapshot_indirect_non_breaking .intervals = [
2451+ (to_timestamp ("2023-01-01" ), to_timestamp ("2023-01-02" ))
2452+ ]
2453+ snapshot_indirect_non_breaking .categorize_as (SnapshotChangeCategory .INDIRECT_NON_BREAKING )
2454+ snapshot_indirect_non_breaking .parents = (snapshot_non_breaking .snapshot_id ,)
2455+
24442456 # Indirect breaking - cannot be representative / deployable due to indirect non breaking non-deployable parent
2445- snapshot_h = make_snapshot (SqlModel (name = "h" , query = parse_one ("SELECT 1" )))
2446- snapshot_h .categorize_as (SnapshotChangeCategory .INDIRECT_BREAKING )
2447- snapshot_h .parents = (snapshot_g .snapshot_id ,)
2457+ snapshot_indirect_breaking_non_deployable_parents = make_snapshot (
2458+ SqlModel (name = "h" , query = parse_one ("SELECT 1" ))
2459+ )
2460+ snapshot_indirect_breaking_non_deployable_parents .categorize_as (
2461+ SnapshotChangeCategory .INDIRECT_BREAKING
2462+ )
2463+ snapshot_indirect_breaking_non_deployable_parents .parents = (
2464+ snapshot_indirect_non_breaking .snapshot_id ,
2465+ )
24482466
24492467 snapshots = {
24502468 s .snapshot_id : s
24512469 for s in [
2452- snapshot_a ,
2453- snapshot_b ,
2454- snapshot_c ,
2455- snapshot_d ,
2456- snapshot_e ,
2457- snapshot_f ,
2458- snapshot_g ,
2459- snapshot_h ,
2470+ snapshot_breaking ,
2471+ snapshot_breaking_forward_only ,
2472+ snapshot_indirect_breaking_1 ,
2473+ snapshot_indirect_breaking_2 ,
2474+ snapshot_non_breaking ,
2475+ snapshot_indirect_breaking_deployable_parents ,
2476+ snapshot_indirect_non_breaking ,
2477+ snapshot_indirect_breaking_non_deployable_parents ,
24602478 ]
24612479 }
24622480
24632481 deployability_index = DeployabilityIndex .create (snapshots )
24642482
2465- assert deployability_index .is_deployable (snapshot_a )
2466- assert deployability_index .is_deployable (snapshot_e )
2467- assert deployability_index .is_deployable (snapshot_f )
2468- assert not deployability_index .is_deployable (snapshot_b )
2469- assert not deployability_index .is_deployable (snapshot_c )
2470- assert not deployability_index .is_deployable (snapshot_d )
2471- assert not deployability_index .is_deployable (snapshot_g )
2472- assert not deployability_index .is_deployable (snapshot_h )
2473-
2474- assert deployability_index .is_representative (snapshot_a )
2475- assert deployability_index .is_representative (snapshot_e )
2476- assert deployability_index .is_representative (snapshot_f )
2477- assert not deployability_index .is_representative (snapshot_b )
2478- assert not deployability_index .is_representative (snapshot_c )
2479- assert not deployability_index .is_representative (snapshot_d )
2480- assert not deployability_index .is_representative (snapshot_g )
2481- assert not deployability_index .is_representative (snapshot_h )
2483+ assert deployability_index .is_deployable (snapshot_breaking )
2484+ assert deployability_index .is_deployable (snapshot_non_breaking )
2485+ assert deployability_index .is_deployable (snapshot_indirect_breaking_deployable_parents )
2486+ assert not deployability_index .is_deployable (snapshot_breaking_forward_only )
2487+ assert not deployability_index .is_deployable (snapshot_indirect_breaking_1 )
2488+ assert not deployability_index .is_deployable (snapshot_indirect_breaking_2 )
2489+ assert not deployability_index .is_deployable (snapshot_indirect_non_breaking )
2490+ assert not deployability_index .is_deployable (snapshot_indirect_breaking_non_deployable_parents )
2491+
2492+ assert deployability_index .is_representative (snapshot_breaking )
2493+ assert deployability_index .is_representative (snapshot_non_breaking )
2494+ assert deployability_index .is_representative (snapshot_indirect_breaking_deployable_parents )
2495+ assert not deployability_index .is_representative (snapshot_breaking_forward_only )
2496+ assert not deployability_index .is_representative (snapshot_indirect_breaking_1 )
2497+ assert not deployability_index .is_representative (snapshot_indirect_breaking_2 )
2498+ assert not deployability_index .is_representative (snapshot_indirect_non_breaking )
2499+ assert not deployability_index .is_representative (
2500+ snapshot_indirect_breaking_non_deployable_parents
2501+ )
24822502
24832503 all_deployable_index = deployability_index .all_deployable ()
24842504 assert all (all_deployable_index .is_deployable (s ) for s in snapshots .values ())
0 commit comments