# Path: hbmqtt/plugins/manager.py
# class BaseContext:
#     def __init__(self):
#         self.loop = None
#         self.logger = None


import unittest
import logging
import os
import asyncio
import sqlite3
from hbmqtt.plugins.manager import BaseContext
from hbmqtt.plugins.persistence import SQLitePlugin
# Copyright (c) 2015 Nicolas JOUANIN
#
# See the file license.txt for copying permission.


formatter = "[%(asctime)s] %(name)s {%(filename)s:%(lineno)d} %(levelname)s - %(message)s"
logging.basicConfig(level=logging.DEBUG, format=formatter)


class TestSQLitePlugin(unittest.TestCase):
    def setUp(self):
        self.loop = asyncio.new_event_loop()

    def test_create_tables(self):
        dbfile = os.path.join(os.path.dirname(os.path.realpath(__file__)), "test.db")
        context = BaseContext()
        context.logger = logging.getLogger(__name__)
        context.config = {
            'persistence': {
                'file': dbfile

# Path: hbmqtt/plugins/manager.py
# class BaseContext:
#     def __init__(self):
#         self.loop = None
#         self.logger = None


# Path: tests/plugins/test_persistence.py
import unittest
import logging
import os
import asyncio
import sqlite3
from hbmqtt.plugins.manager import BaseContext
from hbmqtt.plugins.persistence import SQLitePlugin

# Copyright (c) 2015 Nicolas JOUANIN
#
# See the file license.txt for copying permission.


formatter = "[%(asctime)s] %(name)s {%(filename)s:%(lineno)d} %(levelname)s - %(message)s"
logging.basicConfig(level=logging.DEBUG, format=formatter)


class TestSQLitePlugin(unittest.TestCase):
    def setUp(self):
        self.loop = asyncio.new_event_loop()

    def test_create_tables(self):
        dbfile = os.path.join(os.path.dirname(os.path.realpath(__file__)), "test.db")
        context = BaseContext()
        context.logger = logging.getLogger(__name__)
        context.config = {
            'persistence': {
                'file': dbfile

            }