File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -859,15 +859,15 @@ def _audit(
859859 select ("COUNT(*)" ).from_ (query .subquery ("audit" )),
860860 quote_identifiers = True ,
861861 ) # type: ignore
862- if count and raise_exception :
862+ if count :
863863 audit_error = AuditError (
864864 audit_name = audit .name ,
865865 model = snapshot .model_or_none ,
866866 count = count ,
867867 query = query ,
868868 adapter_dialect = self .adapter .dialect ,
869869 )
870- if blocking :
870+ if raise_exception and blocking :
871871 raise audit_error
872872 else :
873873 logger .warning (f"{ audit_error } \n Audit is warn only so proceeding with execution." )
Original file line number Diff line number Diff line change @@ -361,8 +361,19 @@ def test_override_builtin_audit_blocking_mode():
361361 )
362362 )
363363
364- plan = context .plan (auto_apply = True , no_prompts = True )
365- new_snapshot = next (iter (plan .context_diff .new_snapshots .values ()))
364+ logger = logging .getLogger ("sqlmesh.core.snapshot.evaluator" )
365+ with patch .object (logger , "warning" ) as mock_logger :
366+ plan = context .plan (auto_apply = True , no_prompts = True )
367+ new_snapshot = next (iter (plan .context_diff .new_snapshots .values ()))
368+
369+ assert mock_logger .mock_calls == [
370+ call (
371+ "Audit 'not_null' for model 'db.x' failed.\n "
372+ "Got 1 results, expected 0.\n "
373+ 'SELECT * FROM (SELECT * FROM "sqlmesh__db"."db__x__829001280" AS "db__x__829001280") AS "_q_0" WHERE "c" IS NULL AND TRUE\n '
374+ "Audit is warn only so proceeding with execution."
375+ )
376+ ]
366377
367378 # Even though there are two builtin audits referenced in the above definition, we only
368379 # store the one that overrides `blocking` in the snapshot; the other one isn't needed
You can’t perform that action at this time.
0 commit comments