@@ -653,10 +653,8 @@ def test_init_prod_connection_runs_check_only_not_migration():
653653 Singleton ._instances .update (saved )
654654
655655
656- def test_init_prod_connection_raises_when_schema_mismatches ():
657- """When connection matches prod and schema doesn't match models, the check raises."""
658- from alembic .util .exc import AutogenerateDiffsDetected
659-
656+ def test_init_prod_connection_warns_on_schema_mismatch ():
657+ """When connection matches prod and schema doesn't match, startup succeeds with a warning (no raise)."""
660658 prod_conn = "Server=tcp:prod.database.windows.net;Database=prod_db;"
661659 saved = Singleton ._instances .copy ()
662660 Singleton ._instances .clear ()
@@ -665,15 +663,7 @@ def test_init_prod_connection_raises_when_schema_mismatches():
665663 patch ("pyrit.memory.AzureSQLMemory._create_engine" ),
666664 patch ("pyrit.memory.AzureSQLMemory._create_auth_token" ),
667665 patch ("pyrit.memory.AzureSQLMemory._enable_azure_authorization" ),
668- patch .object (
669- AzureSQLMemory ,
670- "_check_schema_migration" ,
671- side_effect = AutogenerateDiffsDetected (
672- "New upgrade operations detected" ,
673- revision_context = MagicMock (),
674- diffs = [],
675- ),
676- ),
666+ patch .object (AzureSQLMemory , "_check_schema_migration" ) as mock_check ,
677667 patch .dict (
678668 "os.environ" ,
679669 {
@@ -683,12 +673,13 @@ def test_init_prod_connection_raises_when_schema_mismatches():
683673 },
684674 ),
685675 ):
686- with pytest .raises (AutogenerateDiffsDetected ):
687- AzureSQLMemory (
688- connection_string = prod_conn ,
689- results_container_url = "https://test.blob.core.windows.net/test" ,
690- results_sas_token = "valid_sas_token" ,
691- )
676+ # Should not raise — _check_schema_migration warns internally on mismatch
677+ AzureSQLMemory (
678+ connection_string = prod_conn ,
679+ results_container_url = "https://test.blob.core.windows.net/test" ,
680+ results_sas_token = "valid_sas_token" ,
681+ )
682+ mock_check .assert_called_once ()
692683 finally :
693684 Singleton ._instances .clear ()
694685 Singleton ._instances .update (saved )
0 commit comments