Пример #1
0
    def setUp(self):
        """LogModel test set up"""

        if os.path.isfile('/tmp/box.db'):
            os.unlink('/tmp/box.db')
        DBHelper().set_db('/tmp/box.db')
        InstallHelper.reset()
        LogModel.install()
Пример #2
0
    def setUp(self):
        """LogModel test set up"""

        if os.path.isfile('/tmp/box.db'):
            os.unlink('/tmp/box.db')
        DBHelper().set_db('/tmp/box.db')
        InstallHelper.reset()
        LogModel.install()
Пример #3
0
    def log(message, level):
        """Log a message at a given level
        Returns the created log entry, if any
        """

        if level > LogHelper._level:
            return None

        if not LogHelper._model_installed:
            LogModel.install()
            LogHelper._model_installed = True

        return LogModel({
            'message': message,
            'level': level,
            'created_at': timegm(datetime.utcnow().utctimetuple())
        }).save()
Пример #4
0
    def test_add_entry(self):
        """Test adding a log entry"""

        message = 'A Debug Message'
        LogModel({'message': message}).save()
        self.assertEqual(
            LogModel.all().limit(1).next().message(),
            message
        )
Пример #5
0
    def test_add_entry(self):
        """Test adding a log entry"""

        message = 'A Debug Message'
        LogModel({'message': message}).save()
        self.assertEqual(LogModel.all().limit(1).next().message(), message)