Beispiel #1
0
 def tearDown(self):
     if hasattr(self, 'logger_storage_days_lifetime'):
         config = Config()
         config.value = self.logger_storage_days_lifetime
         config.conf = 'logger_storage_days_lifetime'
         db.session.begin()
         db.session.merge(config)
         db.session.commit()
 def tearDown(self):
     if hasattr(self, 'logger_storage_days_lifetime'):
         config = Config()
         config.value = self.logger_storage_days_lifetime
         config.conf = 'logger_storage_days_lifetime'
         db.session.begin()
         db.session.merge(config)
         db.session.commit()
Beispiel #3
0
 def test_0003(self):
     """
         Verify bad error stored in configuration database
     """
     config = Config()
     config.conf = 'logger_storage_days_lifetime'
     config.value = 'ascodevida'
     db.session.begin()
     db.session.merge(config)
     db.session.commit()
     result = clean_logger()
     self.assertEqual(result, False)
Beispiel #4
0
 def test_0001(self):
     """
         Verify clean logger disables
     """
     config = Config()
     config.conf = 'logger_storage_days_lifetime'
     config.value = 0
     db.session.begin()
     db.session.merge(config)
     db.session.commit()
     result = clean_logger()
     self.assertEqual(result, True)
 def test_0003(self):
     """
         Verify bad error stored in configuration database
     """
     config = Config()
     config.conf = 'logger_storage_days_lifetime'
     config.value = 'ascodevida'
     db.session.begin()
     db.session.merge(config)
     db.session.commit()
     result = clean_logger()
     self.assertEqual(result, False)
 def test_0001(self):
     """
         Verify clean logger disables
     """
     config = Config()
     config.conf = 'logger_storage_days_lifetime'
     config.value = 0
     db.session.begin()
     db.session.merge(config)
     db.session.commit()
     result = clean_logger()
     self.assertEqual(result, True)
Beispiel #7
0
 def test_0002(self, mock_delete_raw):
     """
         Verify correct exit after error getting conf
     """
     mock_delete_raw.return_value = True, "[]"
     config = Config()
     config.conf = 'logger_storage_days_lifetime'
     config.value = 10
     db.session.begin()
     db.session.merge(config)
     db.session.commit()
     result = clean_logger()
     self.assertEqual(result, True)
     self.assertTrue(mock_delete_raw.called)
 def test_0002(self, mock_delete_raw):
     """
         Verify correct exit after error getting conf
     """
     mock_delete_raw.return_value = True, "[]"
     config = Config()
     config.conf = 'logger_storage_days_lifetime'
     config.value = 10
     db.session.begin()
     db.session.merge(config)
     db.session.commit()
     result = clean_logger()
     self.assertEqual(result, True)
     self.assertTrue(mock_delete_raw.called)
    def add_config(self, config_entity):
        if self.get_config(config_entity.conf) is not None:
            raise ConfigAlreadyExistsError

        token_config = Config(conf=config_entity.conf,
                              value=config_entity.value)
        db.session.begin()

        try:
            db.session.add(token_config)
            db.session.commit()
        except Exception:
            db.session.rollback()
            raise

        return None