def test_normal_submission(self): # create our signal handler with a timeout handler = sigasync_handler(mockhandler, spooler='test', timeout=10) # send it a message handler(sender=None, instance=None) # check our handler was called as expected assert len(mockhandler.call_args_list) == 1
def test_existing_behaviour(self): # create our signal handler without a timeout handler = sigasync_handler(mockhandler, spooler='test') # send it a message handler(sender=None, instance=None) # check our handler was called as expected assert len(mockhandler.call_args_list) == 1
def test_expired_submission(self): # create our signal handler with a timeout handler = sigasync_handler(mockhandler, spooler='test', timeout=10) with mock.patch('sigasync.sigasync_spooler.time') as mtime: # advance time by 11 seconds. this should discard job mtime.time.side_effect = lambda: time() + 11 # send job to handler handler(sender=None, instance=None) # check our patched time was called for sanity assert mtime.time.called # our handler should not have been called assert not mockhandler.called, mockhandler.call_args_list