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()
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()
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 )
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)