Exemple #1
0
 def unschedule_contract(self) -> None:
     _log.info("Unscheduling contracts")
     try:
         scheduler.schedule_contract_invocation(self.model, action=scheduler.SchedulerActions.DELETE)
     except exceptions.TimingEventSchedulerError:
         _log.exception("Error unscheduling contract")
         self.model.set_state(state=self.end_error_state, msg="Error unscheduling contract execution")
Exemple #2
0
 def schedule_contract(self, action: scheduler.SchedulerActions = scheduler.SchedulerActions.CREATE) -> None:
     try:
         scheduler.schedule_contract_invocation(self.model, action=action)
     except exceptions.TimingEventSchedulerError:
         _log.exception("Error scheduling contract")
         self.model.set_state(state=self.end_error_state, msg="Error scheduling contract execution")
         raise
 def test_schedule_contract_invocation_raises(self, lpush):
     sc_model = FakeScModel("my_name", None, None)
     try:
         scheduler.schedule_contract_invocation(sc_model)
         self.fail("no error raised")
     except Exception as e:
         self.assertEqual(
             str(e), "You must provide cron or seconds to schedule a job")
         return
     self.fail()  # Force a failure if no exception thrown
 def test_schedule_contract_invocation(self, lpush):
     sc_model = MagicMock()
     sc_model.id = "my_name"
     sc_model.cron = "* * * * *"
     sc_model.seconds = None
     sc_model.txn_type = "banana"
     sc_model.execution_order = "serial"
     scheduler.schedule_contract_invocation(sc_model)
     lpush.assert_called_with(
         "mq:scheduler",
         '{"action":"create","contract_id":"my_name","txn_type":"banana","execution_order":"serial","cron":"* * * * *","seconds":null}',
     )