@@ -2247,6 +2247,114 @@ def test_indirect_non_breaking_view_model_non_representative_snapshot_migration(
22472247 assert count > 0
22482248
22492249
2250+ @time_machine .travel ("2023-01-08 15:00:00 UTC" )
2251+ @pytest .mark .parametrize (
2252+ "parent_a_category,parent_b_category,expected_child_category" ,
2253+ [
2254+ (
2255+ SnapshotChangeCategory .BREAKING ,
2256+ SnapshotChangeCategory .BREAKING ,
2257+ SnapshotChangeCategory .INDIRECT_BREAKING ,
2258+ ),
2259+ (
2260+ SnapshotChangeCategory .NON_BREAKING ,
2261+ SnapshotChangeCategory .NON_BREAKING ,
2262+ SnapshotChangeCategory .INDIRECT_NON_BREAKING ,
2263+ ),
2264+ (
2265+ SnapshotChangeCategory .BREAKING ,
2266+ SnapshotChangeCategory .NON_BREAKING ,
2267+ SnapshotChangeCategory .INDIRECT_NON_BREAKING ,
2268+ ),
2269+ (
2270+ SnapshotChangeCategory .NON_BREAKING ,
2271+ SnapshotChangeCategory .BREAKING ,
2272+ SnapshotChangeCategory .INDIRECT_BREAKING ,
2273+ ),
2274+ (
2275+ SnapshotChangeCategory .NON_BREAKING ,
2276+ SnapshotChangeCategory .METADATA ,
2277+ SnapshotChangeCategory .METADATA ,
2278+ ),
2279+ (
2280+ SnapshotChangeCategory .BREAKING ,
2281+ SnapshotChangeCategory .METADATA ,
2282+ SnapshotChangeCategory .METADATA ,
2283+ ),
2284+ (
2285+ SnapshotChangeCategory .METADATA ,
2286+ SnapshotChangeCategory .BREAKING ,
2287+ SnapshotChangeCategory .INDIRECT_BREAKING ,
2288+ ),
2289+ (
2290+ SnapshotChangeCategory .METADATA ,
2291+ SnapshotChangeCategory .NON_BREAKING ,
2292+ SnapshotChangeCategory .INDIRECT_NON_BREAKING ,
2293+ ),
2294+ (
2295+ SnapshotChangeCategory .METADATA ,
2296+ SnapshotChangeCategory .METADATA ,
2297+ SnapshotChangeCategory .METADATA ,
2298+ ),
2299+ (
2300+ SnapshotChangeCategory .FORWARD_ONLY ,
2301+ SnapshotChangeCategory .BREAKING ,
2302+ SnapshotChangeCategory .INDIRECT_BREAKING ,
2303+ ),
2304+ (
2305+ SnapshotChangeCategory .BREAKING ,
2306+ SnapshotChangeCategory .FORWARD_ONLY ,
2307+ SnapshotChangeCategory .FORWARD_ONLY ,
2308+ ),
2309+ (
2310+ SnapshotChangeCategory .FORWARD_ONLY ,
2311+ SnapshotChangeCategory .FORWARD_ONLY ,
2312+ SnapshotChangeCategory .FORWARD_ONLY ,
2313+ ),
2314+ ],
2315+ )
2316+ def test_rebase_two_changed_parents (
2317+ init_and_plan_context : t .Callable ,
2318+ parent_a_category : SnapshotChangeCategory , # This change is deployed to prod first
2319+ parent_b_category : SnapshotChangeCategory , # This change is deployed to prod second
2320+ expected_child_category : SnapshotChangeCategory ,
2321+ ):
2322+ context , plan = init_and_plan_context ("examples/sushi" )
2323+ context .apply (plan )
2324+
2325+ initial_model_a = context .get_model ("sushi.orders" )
2326+ initial_model_b = context .get_model ("sushi.items" )
2327+
2328+ # Make change A and deploy it to dev_a
2329+ context .upsert_model (initial_model_a .name , stamp = "1" )
2330+ plan_builder = context .plan_builder ("dev_a" , skip_tests = True )
2331+ plan_builder .set_choice (context .get_snapshot (initial_model_a .name ), parent_a_category )
2332+ context .apply (plan_builder .build ())
2333+
2334+ # Make change B and deploy it to dev_b
2335+ context .upsert_model (initial_model_a )
2336+ context .upsert_model (initial_model_b .name , stamp = "1" )
2337+ plan_builder = context .plan_builder ("dev_b" , skip_tests = True )
2338+ plan_builder .set_choice (context .get_snapshot (initial_model_b .name ), parent_b_category )
2339+ context .apply (plan_builder .build ())
2340+
2341+ # Deploy change A to prod
2342+ context .upsert_model (initial_model_a .name , stamp = "1" )
2343+ context .upsert_model (initial_model_b )
2344+ context .plan ("prod" , auto_apply = True , no_prompts = True , skip_tests = True )
2345+
2346+ # Apply change B in addition to A and plan against prod
2347+ context .upsert_model (initial_model_b .name , stamp = "1" )
2348+ plan = context .plan_builder ("prod" , skip_tests = True ).build ()
2349+
2350+ # Validate the category of child snapshots
2351+ direct_child_snapshot = plan .snapshots [context .get_snapshot ("sushi.order_items" ).snapshot_id ]
2352+ assert direct_child_snapshot .change_category == expected_child_category
2353+
2354+ indirect_child_snapshot = plan .snapshots [context .get_snapshot ("sushi.top_waiters" ).snapshot_id ]
2355+ assert indirect_child_snapshot .change_category == expected_child_category
2356+
2357+
22502358@time_machine .travel ("2023-01-08 15:00:00 UTC" )
22512359def test_unaligned_start_snapshot_with_non_deployable_downstream (init_and_plan_context : t .Callable ):
22522360 context , _ = init_and_plan_context ("examples/sushi" )
0 commit comments