File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -440,23 +440,29 @@ def test_rulefile_in_file_like_object_2__336(self):
440440
441441
442442 def test_rule_exec_context (self ):
443- rule_id = - 1
444- if self .sess .server_version == (4 , 2 , 1 ):
443+ if self .sess .server_version < (4 , 3 ):
445444 self .skipTest ("""RuleExec's "context" attribute not available before 4.3.0""" )
445+
446+ rule_id = - 1
447+
446448 try :
449+ # Schedule a delayed rule.
447450 n_minutes = 15
448451 random_int = random .randint (1 << 30 , (1 << 31 )- 1 )
449452 r = Rule (
450453 self .sess ,
451454 body = f'''delay("<PLUSET>{ n_minutes } m</PLUSET>") {{writeLine("serverLog","{ random_int } ")}}'''
452455 )
453456 r .execute ()
457+
458+ # Get the delayed rule's ID, needed for cancellation.
454459 l = list (self .sess .query (RuleExec ).filter (Like (RuleExec .name ,f'%"{ random_int } "%' )))
455460 rule_id = l [0 ][RuleExec .id ]
456461
457462 # Assert context exists, is of string type, and is not empty.
458463 self .assertGreater (l [0 ][RuleExec .context ], "" )
459464 finally :
465+ # Remove the delayed rule from the queue.
460466 if rule_id >= 0 :
461467 r .remove_by_id (rule_id )
462468
You can’t perform that action at this time.
0 commit comments