Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
 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
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
 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
Ejemplo n.º 10
0
    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
Ejemplo n.º 11
0
 def setUp(self):
     super(RunOnceSemaphoreTest, self).setUp()
     self.loggingDouble = getLoggingDouble()
     random.seed(0)  # last step
Ejemplo n.º 12
0
 def setUp(self):
     super(LoggerTestPersistent, self).setUp()
     filename = 'test-FSMContextTests.yaml'
     setUpByFilename(self, filename)
     self.context.logger.persistentLogging = self.PERSISTENT_LOGGING
     self.loggingDouble = getLoggingDouble()
Ejemplo n.º 13
0
 def setUp(self):
     super(LoggerTestPersistent, self).setUp()
     filename = 'test-FSMContextTests.yaml'
     setUpByFilename(self, filename)
     self.context.logger.persistentLogging = self.PERSISTENT_LOGGING
     self.loggingDouble = getLoggingDouble()
Ejemplo n.º 14
0
 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)
Ejemplo n.º 15
0
 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)
Ejemplo n.º 16
0
 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)
Ejemplo n.º 17
0
 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)
Ejemplo n.º 18
0
 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)
Ejemplo n.º 19
0
 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)
Ejemplo n.º 20
0
 def setUp(self):
     super(RunOnceSemaphoreTest, self).setUp()
     self.loggingDouble = getLoggingDouble()
     random.seed(0) # last step