Ejemplo n.º 1
0
 def test_empty_tags(self):
     self.assertEqual(0, _FantasmLog.all().count())
     self.assertEqual(0, sum(self.loggingDouble.count.values()))
     self.context.logger.info('a', tags=[])
     runQueuedTasks(queueName=self.context.queueName, assertTasks=self.PERSISTENT_LOGGING)
     self.assertEqual({True: 1, False: 0}[self.PERSISTENT_LOGGING], _FantasmLog.all().count())
     self.assertEqual(1, sum(self.loggingDouble.count.values()))
Ejemplo n.º 2
0
 def test_logging_TypeError(self):
     self.context.logger.info('%s')
     if self.PERSISTENT_LOGGING:
         runQueuedTasks(queueName=self.context.queueName)
         self.assertEqual('%s', _FantasmLog.all(namespace='').get().message)
         self.assertEqual(logging.INFO,
                          _FantasmLog.all(namespace='').get().level)
Ejemplo n.º 3
0
 def test_TaskTooLargeError(self):
     self.assertEqual(0, _FantasmLog.all().count())
     self.assertEqual(0, sum(self.loggingDouble.count.values()))
     self.context.logger.info('a' * 100000)
     runQueuedTasks(queueName=self.context.queueName, assertTasks=False)
     self.assertEqual({True: 0, False: 0}[self.PERSISTENT_LOGGING], _FantasmLog.all().count())
     self.assertEqual({True: 2, False: 1}[self.PERSISTENT_LOGGING], sum(self.loggingDouble.count.values()))
Ejemplo n.º 4
0
 def test_batchsize_10(self):
     self.context['batchsize'] = 10
     self.context.initialize() # queues the first task
     runQueuedTasks(maxRetries=0)
     self.assertEqual(1 + self.EXTRA_COUNT, _FantasmFanIn.all().count())
     self.assertEqual(self.EXTRA_VALUES + self.EXPECTED_VALUES, 
                      sorted(ContinuationFanInResult.get_by_key_name('test').values))
Ejemplo n.º 5
0
 def test_logging_object(self):
     self.context.logger.info({'a': 'b'})
     if self.PERSISTENT_LOGGING:
         runQueuedTasks(queueName=self.context.queueName)
         self.assertEqual("{'a': 'b'}", _FantasmLog.all().get().message)
     else:
         self.assertEqual("{'a': 'b'}", self.loggingDouble.messages['info'][0])
Ejemplo n.º 6
0
 def test_batchsize_11(self):
     self.context['batchsize'] = 11
     self.context.initialize()  # queues the first task
     runQueuedTasks(maxRetries=0)
     self.assertEqual(1, _FantasmFanIn.all(namespace='').count())
     self.assertEqual(
         self.EXPECTED_VALUES,
         sorted(ContinuationFanInResult.get_by_key_name('test').values))
Ejemplo n.º 7
0
 def test_batchsize_3(self):
     self.context['batchsize'] = 3
     self.context.initialize()  # queues the first task
     runQueuedTasks()
     self.assertEqual(4, _FantasmFanIn.all().count())
     self.assertEqual(
         self.EXPECTED_VALUES,
         sorted(ContinuationFanInResult.get_by_key_name('test').values))
Ejemplo n.º 8
0
 def test_logging_object(self):
     self.context.logger.info({'a': 'b'})
     if self.PERSISTENT_LOGGING:
         runQueuedTasks(queueName=self.context.queueName)
         self.assertEqual("{'a': 'b'}", _FantasmLog.all().get().message)
     else:
         self.assertEqual("{'a': 'b'}",
                          self.loggingDouble.messages['info'][0])
Ejemplo n.º 9
0
 def test_level_OFF(self):
     self.context.logger.setLevel(logging.CRITICAL+1)
     self.context.logger.critical('critical')
     self.context.logger.error('error')
     self.context.logger.warning('warning')
     self.context.logger.info('info')
     self.context.logger.debug('debug')
     runQueuedTasks(queueName=self.context.queueName, assertTasks=False)
     self.assertEqual({True: 0, False: 0}[self.PERSISTENT_LOGGING], _FantasmLog.all().count())
     self.assertEqual(0, sum(self.loggingDouble.count.values()))
Ejemplo n.º 10
0
 def test_maxLevel_WARNING(self):
     self.context.logger.setMaxLevel(logging.WARNING)
     self.context.logger.critical('critical')
     self.context.logger.error('error')
     self.context.logger.warning('warning')
     self.context.logger.info('info')
     self.context.logger.debug('debug')
     runQueuedTasks(queueName=self.context.queueName, assertTasks=self.PERSISTENT_LOGGING)
     self.assertEqual({True: 3, False: 0}[self.PERSISTENT_LOGGING], _FantasmLog.all().count())
     self.assertEqual(3, sum(self.loggingDouble.count.values()))
Ejemplo n.º 11
0
 def test_logging_bad_object(self):
     class StrRaises(object):
         def __str__(self):
             raise Exception()
     self.context.logger.info(StrRaises())
     if self.PERSISTENT_LOGGING:
         runQueuedTasks(queueName=self.context.queueName)
         self.assertEqual(LOG_ERROR_MESSAGE, _FantasmLog.all().get().message)
         self.assertEqual(logging.INFO, _FantasmLog.all().get().level)
     else:
         self.assertEqual('logging error', self.loggingDouble.messages['info'][0])
Ejemplo n.º 12
0
 def test_empty_tags(self):
     self.assertEqual(0, _FantasmLog.all(namespace='').count())
     self.assertEqual(0, sum(self.loggingDouble.count.values()))
     self.context.logger.info('a', tags=[])
     runQueuedTasks(queueName=self.context.queueName,
                    assertTasks=self.PERSISTENT_LOGGING)
     self.assertEqual({
         True: 1,
         False: 0
     }[self.PERSISTENT_LOGGING],
                      _FantasmLog.all(namespace='').count())
     self.assertEqual(1, sum(self.loggingDouble.count.values()))
Ejemplo n.º 13
0
 def test(self):
     self.context.initialize() # queues the first task
     self.assertEqual(0, _FantasmTaskSemaphore.all().count())
     self.assertEqual(0, SimpleModel.all().count())
     tq = apiproxy_stub_map.apiproxy.GetStub('taskqueue')
     tasks = tq.GetTasks('default')
     runQueuedTasks(tasksOverride=tasks)
     self.assertEqual(1, _FantasmTaskSemaphore.all().count())
     self.assertEqual(1, SimpleModel.all().count())
     runQueuedTasks(tasksOverride=tasks)
     logging.info([e.key().name() for e in _FantasmTaskSemaphore.all().fetch(100)])
     self.assertEqual(1, _FantasmTaskSemaphore.all().count())
     self.assertEqual(1, SimpleModel.all().count())
Ejemplo n.º 14
0
    def test_logging_bad_object(self):
        class StrRaises(object):
            def __str__(self):
                raise Exception()

        self.context.logger.info(StrRaises())
        if self.PERSISTENT_LOGGING:
            runQueuedTasks(queueName=self.context.queueName)
            self.assertEqual(LOG_ERROR_MESSAGE,
                             _FantasmLog.all().get().message)
            self.assertEqual(logging.INFO, _FantasmLog.all().get().level)
        else:
            self.assertEqual('logging error',
                             self.loggingDouble.messages['info'][0])
Ejemplo n.º 15
0
 def test_maxLevel_OFF(self):
     self.context.logger.setMaxLevel(logging.DEBUG - 1)
     self.context.logger.critical('critical')
     self.context.logger.error('error')
     self.context.logger.warning('warning')
     self.context.logger.info('info')
     self.context.logger.debug('debug')
     runQueuedTasks(queueName=self.context.queueName, assertTasks=False)
     self.assertEqual({
         True: 0,
         False: 0
     }[self.PERSISTENT_LOGGING],
                      _FantasmLog.all(namespace='').count())
     self.assertEqual(0, sum(self.loggingDouble.count.values()))
Ejemplo n.º 16
0
 def test_TaskTooLargeError(self):
     self.assertEqual(0, _FantasmLog.all(namespace='').count())
     self.assertEqual(0, sum(self.loggingDouble.count.values()))
     self.context.logger.info('a' * 1000000)
     runQueuedTasks(queueName=self.context.queueName, assertTasks=False)
     self.assertEqual({
         True: 0,
         False: 0
     }[self.PERSISTENT_LOGGING],
                      _FantasmLog.all(namespace='').count())
     self.assertEqual({
         True: 2,
         False: 1
     }[self.PERSISTENT_LOGGING], sum(self.loggingDouble.count.values()))
Ejemplo n.º 17
0
 def test(self):
     self.context.initialize()  # queues the first task
     self.assertEqual(0, _FantasmTaskSemaphore.all().count())
     self.assertEqual(0, SimpleModel.all().count())
     tq = apiproxy_stub_map.apiproxy.GetStub('taskqueue')
     tasks = tq.GetTasks('default')
     runQueuedTasks(tasksOverride=tasks)
     self.assertEqual(1, _FantasmTaskSemaphore.all().count())
     self.assertEqual(1, SimpleModel.all().count())
     runQueuedTasks(tasksOverride=tasks)
     logging.info(
         [e.key().name() for e in _FantasmTaskSemaphore.all().fetch(100)])
     self.assertEqual(1, _FantasmTaskSemaphore.all().count())
     self.assertEqual(1, SimpleModel.all().count())
Ejemplo n.º 18
0
 def test_level_WARNING(self):
     self.context.logger.setLevel(logging.WARNING)
     self.context.logger.critical('critical')
     self.context.logger.error('error')
     self.context.logger.warning('warning')
     self.context.logger.info('info')
     self.context.logger.debug('debug')
     runQueuedTasks(queueName=self.context.queueName,
                    assertTasks=self.PERSISTENT_LOGGING)
     self.assertEqual({
         True: 3,
         False: 0
     }[self.PERSISTENT_LOGGING],
                      _FantasmLog.all().count())
     self.assertEqual(3, sum(self.loggingDouble.count.values()))
Ejemplo n.º 19
0
 def test(self):
     self.context.initialize()  # queues the first task
     self.assertEqual(20, SimpleModel.all().count())
     runQueuedTasks(speedup=False)
     result = ResultModel.get_by_key_name('test')
     self.assertEqual(20, result.total)
Ejemplo n.º 20
0
 def test(self):
     self.context.initialize() # queues the first task
     self.assertEqual(20, SimpleModel.all().count())
     runQueuedTasks(speedup=False)
     result = ResultModel.get_by_key_name('test')
     self.assertEqual(20, result.total)
Ejemplo n.º 21
0
 def test_batchsize_3(self):
     self.context['batchsize'] = 3
     self.context.initialize() # queues the first task
     runQueuedTasks()
     self.assertEqual(4, _FantasmFanIn.all().count())
     self.assertEqual(self.EXPECTED_VALUES, sorted(ContinuationFanInResult.get_by_key_name('test').values))
Ejemplo n.º 22
0
 def test_stateName(self):
     self.context.logger.info('info')
     if self.PERSISTENT_LOGGING:
         runQueuedTasks(queueName=self.context.queueName)
         log = _FantasmLog.all(namespace='').get()
         self.assertEqual('pseudo-init', log.stateName)
Ejemplo n.º 23
0
 def test_machineName(self):
     self.context.logger.info('info')
     if self.PERSISTENT_LOGGING:
         runQueuedTasks(queueName=self.context.queueName)
         log = _FantasmLog.all(namespace='').get()
         self.assertEqual('FSMContextTests', log.machineName)
Ejemplo n.º 24
0
 def test_transitionName(self):
     self.context.logger.info('info')
     if self.PERSISTENT_LOGGING:
         runQueuedTasks(queueName=self.context.queueName)
         log = _FantasmLog.all().get()
         self.assertEqual(None, log.transitionName)
Ejemplo n.º 25
0
 def test_stateName(self):
     self.context.logger.info('info')
     if self.PERSISTENT_LOGGING:
         runQueuedTasks(queueName=self.context.queueName)
         log = _FantasmLog.all().get()
         self.assertEqual('pseudo-init', log.stateName)
Ejemplo n.º 26
0
 def test_machineName(self):
     self.context.logger.info('info')
     if self.PERSISTENT_LOGGING:
         runQueuedTasks(queueName=self.context.queueName)
         log = _FantasmLog.all().get()
         self.assertEqual('FSMContextTests', log.machineName)
Ejemplo n.º 27
0
 def test_logging_TypeError(self):
     self.context.logger.info('%s')
     if self.PERSISTENT_LOGGING:
         runQueuedTasks(queueName=self.context.queueName)
         self.assertEqual('%s', _FantasmLog.all().get().message)
         self.assertEqual(logging.INFO, _FantasmLog.all().get().level)
Ejemplo n.º 28
0
 def test_transitionName(self):
     self.context.logger.info('info')
     if self.PERSISTENT_LOGGING:
         runQueuedTasks(queueName=self.context.queueName)
         log = _FantasmLog.all(namespace='').get()
         self.assertEqual(None, log.transitionName)