Exemple #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()))
Exemple #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)
Exemple #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()))
Exemple #4
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])
Exemple #5
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()))
Exemple #6
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()))
Exemple #7
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])
Exemple #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])
Exemple #9
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])
Exemple #10
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()))
Exemple #11
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()))
Exemple #12
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()))
Exemple #13
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()))
Exemple #14
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)
Exemple #15
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)
Exemple #16
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)
Exemple #17
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)
Exemple #18
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)
Exemple #19
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)
Exemple #20
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)