c5ba5229f00f — Arnaud Campeas[arnaud.campeas@pythonian.fr] 9 months ago
schedule/step: correct bug when the user is given to .prepare

We make argument passing between prepared call and its actual
invocation more clear. While doing so we note that the `domain` was
dispatched to the wrong place.
2 files changed, 19 insertions(+), 5 deletions(-)

M rework/monitor.py
M tests/test_schedule.py
M rework/monitor.py +18 -4
@@ 139,11 139,18 @@ class scheduler:
     def __repr__(self):
         return f'<scheduler for {self.domain} ->\n{self.defs}>'
 
-    def schedule(self, rule, *args):
+    def schedule(self, rule, opname, domain, rawinputdata, hostid, metadata):
         self.rulemap.append(
             (
                 rule,
-                lambda: api.schedule(self.engine, *args)
+                lambda: api.schedule(
+                    self.engine,
+                    opname=opname,
+                    domain=domain,
+                    rawinputdata=rawinputdata,
+                    hostid=hostid,
+                    metadata=metadata
+                )
             )
         )
 

          
@@ 194,9 201,16 @@ class scheduler:
             self.rulemap = []
             self.runnable = []
             self.logger.info(f'sched: starting with {len(defs)} definitions')
-            for idx, (operation, rule, inputdata, hostid, meta) in enumerate(defs):
+            for idx, (operation, rule, rawinputdata, hostid, meta) in enumerate(defs):
                 self.logger.info(f'{idx} {operation} {rule} {hostid} {meta}')
-                self.schedule(rule, operation, self.domain, inputdata, hostid, meta)
+                self.schedule(
+                    rule,
+                    opname=operation,
+                    domain=self.domain,
+                    rawinputdata=rawinputdata,
+                    hostid=hostid,
+                    metadata=meta
+                )
             self.defs = defs
 
         self.run_scheduled()

          
M tests/test_schedule.py +1 -1
@@ 19,4 19,4 @@ def test_web_scheduling(engine, cleanup,
             "\n[parameters: {\'name\': \'basic\', \'modname\': {\'user\': \'WEBUI\'}}]"
         )
 
-        assert error in printed[-1]
+        assert error not in printed[-1]