def test_unknownEventLogsCriticalEvent(self): loggingDouble = getLoggingDouble() self.context.currentState = self.stateInitial self.assertRaises(UnknownEventError, self.context.dispatch, 'bad-event', {}) # The "bad-event" message is logged twice: once when first looking it up (which raises exception), # then again when handling the exception (which uses the event to find the transition to find the retry policy) self.assertEquals(loggingDouble.count['critical'], 2)
def test_nonFinalStateEmittingNoEventLogsCriticalEvent(self): def executeReturnsNoEvent(context, obj): return None mock(name='CountExecuteCalls.execute', returns_func=executeReturnsNoEvent, tracker=None) loggingDouble = getLoggingDouble() self.context.currentState = self.stateInitial self.context.dispatch('next-event', {}) self.assertEquals(loggingDouble.count['critical'], 1)
def setUp(self): super(DatastoreFSMContinuationBaseTests, self).setUp() setUpByFilename(self, self.FILENAME, instanceName='instanceName', machineName=self.MACHINE_NAME) self.mockQueue = TaskQueueDouble() mock(name='Queue.add', returns_func=self.mockQueue.add, tracker=None) self.loggingDouble = getLoggingDouble() self.modelKeys = [] for i in range(10): modelKey = TestModel().put() self.modelKeys.append(modelKey)
def setUp(self): super(ReadWriteLockTest, self).setUp() self.loggingDouble = getLoggingDouble() self.state = State('name', None, None, None) self.context = FSMContext(self.state, queueName='default') self.context.currentState = self.state ReadWriteLock._BUSY_WAIT_ITER_SECS = ReadWriteLock.BUSY_WAIT_ITERS ReadWriteLock.BUSY_WAIT_ITER_SECS = 0 ReadWriteLock._BUSY_WAIT_ITERS = ReadWriteLock.BUSY_WAIT_ITERS ReadWriteLock.BUSY_WAIT_ITERS = 2 random.seed(0) # last step
def setUp(self): super(TaskQueueFSMRetryTests, self).setUp() filename = 'test-TaskQueueFSMRetryTests.yaml' machineName = getMachineNameByFilename(filename) self.factory = getFSMFactoryByFilename(filename) self.context = self.factory.createFSMInstance(machineName) self.mockQueue = TaskQueueDouble() mock(name='Queue.add', returns_func=self.mockQueue.add, tracker=None) self.loggingDouble = getLoggingDouble() # drive the machine to ready self.initEvent = self.context.initialize() self.mockQueue.purge() # clear the initialization task
def setUp(self): super(RunOnceSemaphoreTest, self).setUp() self.loggingDouble = getLoggingDouble() random.seed(0) # last step
def setUp(self): super(LoggerTestPersistent, self).setUp() filename = 'test-FSMContextTests.yaml' setUpByFilename(self, filename) self.context.logger.persistentLogging = self.PERSISTENT_LOGGING self.loggingDouble = getLoggingDouble()
def test_maxRetriesEmitsDeprecationWarning(self): loggingDouble = getLoggingDouble() self.transDict[constants.MAX_RETRIES_ATTRIBUTE] = "3" self.fsm.addTransition(self.transDict, "GoodState") self.assertEquals(loggingDouble.count["warning"], 1)
def test_continuationNotSpecifiedButHasContinuationMethodLogsWarning(self): loggingDouble = getLoggingDouble() self.stateDict[constants.STATE_CONTINUATION_ATTRIBUTE] = False self.stateDict[constants.STATE_ACTION_ATTRIBUTE] = "MockActionWithContinuation" self.fsm.addState(self.stateDict) self.assertEquals(loggingDouble.count["warning"], 1)
def test_maxRetriesIssuesDeprecationWarning(self): loggingDouble = getLoggingDouble() self.machineDict[constants.MAX_RETRIES_ATTRIBUTE] = "3" fsm = config._MachineConfig(self.machineDict) self.assertTrue(fsm) self.assertEquals(loggingDouble.count["warning"], 1)
def test_maxRetriesEmitsDeprecationWarning(self): loggingDouble = getLoggingDouble() self.transDict[constants.MAX_RETRIES_ATTRIBUTE] = '3' self.fsm.addTransition(self.transDict, 'GoodState') self.assertEquals(loggingDouble.count['warning'], 1)
def test_continuationNotSpecifiedButHasContinuationMethodLogsWarning(self): loggingDouble = getLoggingDouble() self.stateDict[constants.STATE_CONTINUATION_ATTRIBUTE] = False self.stateDict[constants.STATE_ACTION_ATTRIBUTE] = 'MockActionWithContinuation' self.fsm.addState(self.stateDict) self.assertEquals(loggingDouble.count['warning'], 1)
def test_maxRetriesIssuesDeprecationWarning(self): loggingDouble = getLoggingDouble() self.machineDict[constants.MAX_RETRIES_ATTRIBUTE] = '3' fsm = config._MachineConfig(self.machineDict) self.assertTrue(fsm) self.assertEquals(loggingDouble.count['warning'], 1)