Beispiel #1
0
 def setUp(self):
     super(TestStateDictionaryProcessing, self).setUp()
     self.machineName = 'MyFsm'
     self.fsm = config._MachineConfig({constants.MACHINE_NAME_ATTRIBUTE: self.machineName})
     self.stateDict = {constants.STATE_NAME_ATTRIBUTE: 'MyState', 
                       constants.STATE_ACTION_ATTRIBUTE: 'MockAction', 
                       constants.NAMESPACE_ATTRIBUTE: 'fantasm_tests.config_test'}
Beispiel #2
0
 def setUp(self):
     super(TestStateDictionaryProcessing, self).setUp()
     self.machineName = 'MyFsm'
     self.fsm = config._MachineConfig({constants.MACHINE_NAME_ATTRIBUTE: self.machineName})
     self.stateDict = {constants.STATE_NAME_ATTRIBUTE: 'MyState', 
                       constants.STATE_ACTION_ATTRIBUTE: 'MockAction', 
                       constants.NAMESPACE_ATTRIBUTE: 'fantasm_tests.config_test'}
Beispiel #3
0
 def test_contextTypesParsed(self):
     self.machineDict[constants.MACHINE_CONTEXT_TYPES_ATTRIBUTE] = {
         'counter': 'types.IntType'
     }
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(1, len(fsm.contextTypes))
     self.assertTrue('counter' in fsm.contextTypes)
Beispiel #4
0
 def test_contextTypesParsed(self):
     self.machineDict[constants.MACHINE_CONTEXT_TYPES_ATTRIBUTE] = {
         'counter': 'types.IntType'
     }
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(1, len(fsm.contextTypes))
     self.assertTrue('counter' in fsm.contextTypes)
Beispiel #5
0
 def test(self):
     machineName = 'foo'
     machineConfig = config._MachineConfig({'name':machineName})
     machineConfig.addState({'name':'foo', 'initial': True, 'action': 'fantasm_tests.actions.CountExecuteCalls'})
     currentConfig = ConfigurationMock(machines=[machineConfig])
     factory = FSM(currentConfig=currentConfig)
     context = factory.createFSMInstance('foo')
Beispiel #6
0
 def test_contextTypesValueResolved(self):
     self.machineDict[constants.MACHINE_CONTEXT_TYPES_ATTRIBUTE] = {
         'counter': 'types.IntType',
         'batch-key': 'google.appengine.ext.db.Key'
     }
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(int, fsm.contextTypes['counter'])
     self.assertEquals(db.Key, fsm.contextTypes['batch-key'])
Beispiel #7
0
 def test_contextTypesValueResolved(self):
     self.machineDict[constants.MACHINE_CONTEXT_TYPES_ATTRIBUTE] = {
         'counter': 'types.IntType',
         'batch-key': 'google.appengine.ext.db.Key'
     }
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(int, fsm.contextTypes['counter'])
     self.assertEquals(db.Key, fsm.contextTypes['batch-key'])
Beispiel #8
0
 def test_contextTypesValueResolved(self):
     self.machineDict[constants.MACHINE_CONTEXT_TYPES_ATTRIBUTE] = {
         "counter": "types.IntType",
         "batch-key": "google.appengine.ext.db.Key",
     }
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(int, fsm.contextTypes["counter"])
     self.assertEquals(db.Key, fsm.contextTypes["batch-key"])
Beispiel #9
0
 def setUp(self):
     super(TestAdvancedTransitionDictionaryProcessing, self).setUp()
     self.transDict = {
         constants.TRANS_EVENT_ATTRIBUTE: 'MyEvent',
         constants.TRANS_TO_ATTRIBUTE: 'state2'
     }
     self.fsm = config._MachineConfig({constants.MACHINE_NAME_ATTRIBUTE: 'MyMachine', 
                                       constants.NAMESPACE_ATTRIBUTE: 'fantasm_tests.config_test',
                                       constants.TASK_RETRY_LIMIT_ATTRIBUTE: 100})
     self.state1 = self.fsm.addState({constants.STATE_NAME_ATTRIBUTE: 'state1', 
                                      constants.STATE_ACTION_ATTRIBUTE: 'MockAction'})
     self.state2 = self.fsm.addState({constants.STATE_NAME_ATTRIBUTE: 'state2', 
                                      constants.STATE_ACTION_ATTRIBUTE: 'MockAction'})
Beispiel #10
0
 def setUp(self):
     super(TestAdvancedTransitionDictionaryProcessing, self).setUp()
     self.transDict = {
         constants.TRANS_EVENT_ATTRIBUTE: 'MyEvent',
         constants.TRANS_TO_ATTRIBUTE: 'state2'
     }
     self.fsm = config._MachineConfig({constants.MACHINE_NAME_ATTRIBUTE: 'MyMachine', 
                                       constants.NAMESPACE_ATTRIBUTE: 'fantasm_tests.config_test',
                                       constants.TASK_RETRY_LIMIT_ATTRIBUTE: 100})
     self.state1 = self.fsm.addState({constants.STATE_NAME_ATTRIBUTE: 'state1', 
                                      constants.STATE_ACTION_ATTRIBUTE: 'MockAction'})
     self.state2 = self.fsm.addState({constants.STATE_NAME_ATTRIBUTE: 'state2', 
                                      constants.STATE_ACTION_ATTRIBUTE: 'MockAction'})
Beispiel #11
0
 def test(self):
     machineName = 'foo'
     machineConfig = config._MachineConfig({'name': machineName})
     machineConfig.addState({
         'name':
         'foo',
         'initial':
         True,
         'action':
         'fantasm_tests.actions.CountExecuteCalls'
     })
     currentConfig = ConfigurationMock(machines=[machineConfig])
     factory = FSM(currentConfig=currentConfig)
     context = factory.createFSMInstance('foo')
Beispiel #12
0
 def setUp(self):
     super(TestTransitionDictionaryProcessing, self).setUp()
     self.transDict = {
         constants.TRANS_EVENT_ATTRIBUTE: 'MyEvent',
         constants.TRANS_TO_ATTRIBUTE: 'GoodState'
     }
     self.fsm = config._MachineConfig({constants.MACHINE_NAME_ATTRIBUTE: 'MyMachine', 
                                       constants.NAMESPACE_ATTRIBUTE: 'fantasm_tests.config_test',
                                       constants.QUEUE_NAME_ATTRIBUTE: 'somequeue',
                                       constants.TASK_RETRY_LIMIT_ATTRIBUTE: 100,
                                       constants.MIN_BACKOFF_SECONDS_ATTRIBUTE: 101,
                                       constants.MAX_BACKOFF_SECONDS_ATTRIBUTE: 102,
                                       constants.TASK_AGE_LIMIT_ATTRIBUTE: 103,
                                       constants.MAX_DOUBLINGS_ATTRIBUTE: 104})
     self.goodState = self.fsm.addState({constants.STATE_NAME_ATTRIBUTE: 'GoodState', 
                                         constants.STATE_ACTION_ATTRIBUTE: 'MockAction'})
Beispiel #13
0
 def setUp(self):
     super(TestTransitionDictionaryProcessing, self).setUp()
     self.transDict = {
         constants.TRANS_EVENT_ATTRIBUTE: 'MyEvent',
         constants.TRANS_TO_ATTRIBUTE: 'GoodState'
     }
     self.fsm = config._MachineConfig({constants.MACHINE_NAME_ATTRIBUTE: 'MyMachine', 
                                       constants.NAMESPACE_ATTRIBUTE: 'fantasm_tests.config_test',
                                       constants.QUEUE_NAME_ATTRIBUTE: 'somequeue',
                                       constants.TASK_RETRY_LIMIT_ATTRIBUTE: 100,
                                       constants.MIN_BACKOFF_SECONDS_ATTRIBUTE: 101,
                                       constants.MAX_BACKOFF_SECONDS_ATTRIBUTE: 102,
                                       constants.TASK_AGE_LIMIT_ATTRIBUTE: 103,
                                       constants.MAX_DOUBLINGS_ATTRIBUTE: 104})
     self.goodState = self.fsm.addState({constants.STATE_NAME_ATTRIBUTE: 'GoodState', 
                                         constants.STATE_ACTION_ATTRIBUTE: 'MockAction'})
Beispiel #14
0
 def test_taskAgeLimitDefault(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.taskAgeLimit, constants.DEFAULT_TASK_AGE_LIMIT)
Beispiel #15
0
 def test_maxBackoffSecondsDefault(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.maxBackoffSeconds, constants.DEFAULT_MAX_BACKOFF_SECONDS)
Beispiel #16
0
 def test_settingMaxRetriesSetsTaskRetryLimit(self):
     """ maxRetries and taskRetryLimit should be set to the same value. """
     self.machineDict[constants.MAX_RETRIES_ATTRIBUTE] = "3"
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.taskRetryLimit, 3)
Beispiel #17
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)
Beispiel #18
0
 def test_maxRetriesParsed(self):
     self.machineDict[constants.MAX_RETRIES_ATTRIBUTE] = "3"
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.maxRetries, 3)
Beispiel #19
0
 def test_maxDoublingsDefault(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.maxDoublings, constants.DEFAULT_MAX_DOUBLINGS)
Beispiel #20
0
 def test_rootUrlOverridesDefault(self):
     fsm = config._MachineConfig({constants.MACHINE_NAME_ATTRIBUTE: "MyMachine"}, rootUrl="/myfsm")
     self.assertEquals(fsm.url, "/myfsm/fsm/MyMachine/")
Beispiel #21
0
 def test_queueParsed(self):
     queueName = 'SomeQueue'
     self.machineDict[constants.QUEUE_NAME_ATTRIBUTE] = queueName
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.queueName, queueName)
Beispiel #22
0
 def test_maxDoublingsParsed(self):
     self.machineDict[constants.MAX_DOUBLINGS_ATTRIBUTE] = '3'
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.maxDoublings, 3)
Beispiel #23
0
 def test_nameParsed(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.name, self.machineName)
Beispiel #24
0
 def test_rootUrlOverridesDefault(self):
     fsm = config._MachineConfig({constants.MACHINE_NAME_ATTRIBUTE: 'MyMachine'}, rootUrl='/myfsm')
     self.assertEquals(fsm.url, '/myfsm/fsm/MyMachine/')
Beispiel #25
0
 def test_urlIncludesHostName(self):
     fsm = config._MachineConfig({constants.MACHINE_NAME_ATTRIBUTE: 'MyMachine'})
     self.assertEquals(fsm.url, '%sfsm/MyMachine/' % constants.DEFAULT_ROOT_URL)
Beispiel #26
0
 def test_maxDoublingsDefault(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.maxDoublings, constants.DEFAULT_MAX_DOUBLINGS)
Beispiel #27
0
 def test_settingMaxRetriesSetsTaskRetryLimit(self):
     """ maxRetries and taskRetryLimit should be set to the same value. """
     self.machineDict[constants.MAX_RETRIES_ATTRIBUTE] = '3'
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.taskRetryLimit, 3)
Beispiel #28
0
 def test_queueHasDefaultValue(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.queueName, constants.DEFAULT_QUEUE_NAME)
Beispiel #29
0
 def test_queueParsed(self):
     queueName = "SomeQueue"
     self.machineDict[constants.QUEUE_NAME_ATTRIBUTE] = queueName
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.queueName, queueName)
Beispiel #30
0
 def test_noNamespaceYieldNoneAttribute(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.namespace, None)
Beispiel #31
0
 def test_maxBackoffSecondsParsed(self):
     self.machineDict[constants.MAX_BACKOFF_SECONDS_ATTRIBUTE] = '3'
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.maxBackoffSeconds, 3)
Beispiel #32
0
 def test_namespaceParsed(self):
     namespace = 'MyNamespace'
     self.machineDict[constants.NAMESPACE_ATTRIBUTE] = namespace
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.namespace, namespace)
Beispiel #33
0
 def test_maxRetriesDefault(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.maxRetries, constants.DEFAULT_TASK_RETRY_LIMIT)
Beispiel #34
0
 def test_maxRetriesParsed(self):
     self.machineDict[constants.MAX_RETRIES_ATTRIBUTE] = '3'
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.maxRetries, 3)
Beispiel #35
0
 def test_settingTaskRetryLimitSetsMaxRetries(self):
     """ taskRetryLimit and maxRetries should be set to the same value. """
     self.machineDict[constants.TASK_RETRY_LIMIT_ATTRIBUTE] = "3"
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.maxRetries, 3)
Beispiel #36
0
 def test_maxRetriesDefault(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.maxRetries, constants.DEFAULT_TASK_RETRY_LIMIT)
Beispiel #37
0
 def test_maxBackoffSecondsParsed(self):
     self.machineDict[constants.MAX_BACKOFF_SECONDS_ATTRIBUTE] = "3"
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.maxBackoffSeconds, 3)
Beispiel #38
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)
Beispiel #39
0
 def test_taskAgeLimitParsed(self):
     self.machineDict[constants.TASK_AGE_LIMIT_ATTRIBUTE] = "3"
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.taskAgeLimit, 3)
Beispiel #40
0
 def test_noNamespaceYieldNoneAttribute(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.namespace, None)
Beispiel #41
0
 def test_maxDoublingsParsed(self):
     self.machineDict[constants.MAX_DOUBLINGS_ATTRIBUTE] = "3"
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.maxDoublings, 3)
Beispiel #42
0
 def test_settingTaskRetryLimitSetsMaxRetries(self):
     """ taskRetryLimit and maxRetries should be set to the same value. """
     self.machineDict[constants.TASK_RETRY_LIMIT_ATTRIBUTE] = '3'
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.maxRetries, 3)
Beispiel #43
0
 def test_contextTypesDefault(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.contextTypes, {})
Beispiel #44
0
 def test_taskAgeLimitDefault(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.taskAgeLimit, constants.DEFAULT_TASK_AGE_LIMIT)
Beispiel #45
0
 def test_urlIncludesHostName(self):
     fsm = config._MachineConfig({constants.MACHINE_NAME_ATTRIBUTE: "MyMachine"})
     self.assertEquals(fsm.url, "%sfsm/MyMachine/" % constants.DEFAULT_ROOT_URL)
Beispiel #46
0
 def test_taskAgeLimitParsed(self):
     self.machineDict[constants.TASK_AGE_LIMIT_ATTRIBUTE] = '3'
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.taskAgeLimit, 3)
Beispiel #47
0
 def test_nameParsed(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.name, self.machineName)
Beispiel #48
0
 def test_maxBackoffSecondsDefault(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.maxBackoffSeconds, constants.DEFAULT_MAX_BACKOFF_SECONDS)
Beispiel #49
0
 def test_queueHasDefaultValue(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.queueName, constants.DEFAULT_QUEUE_NAME)
Beispiel #50
0
 def test_contextTypesDefault(self):
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.contextTypes, {})
Beispiel #51
0
 def test_namespaceParsed(self):
     namespace = "MyNamespace"
     self.machineDict[constants.NAMESPACE_ATTRIBUTE] = namespace
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.namespace, namespace)
Beispiel #52
0
 def test_taskRetryLimitParsed(self):
     self.machineDict[constants.TASK_RETRY_LIMIT_ATTRIBUTE] = '3'
     fsm = config._MachineConfig(self.machineDict)
     self.assertEquals(fsm.taskRetryLimit, 3)