Esempio n. 1
0
def storage(request):
    """
    Initializes a Storage for execution in a test environment. This fixture
    will instantiate the storage class given in the parameters. This way we
    ensure both the real implementation and dummy implementation work in the
    same way.

    When initializing the real PlugsStorage(), it will use a test-specific
    data-base to avoid any conflicts between tests and to avoid clashing with
    real databases.
    """
    if request.param is PlugsStorage:
        db_name = "testing-{}".format(request.node.name)

        plugs_storage = PlugsStorage(default_db_name=db_name)
        plugs_storage.__TESTING__ = True

        def finalizer():
            plugs_storage.get_connection().drop_database(db_name)

        request.addfinalizer(finalizer)
        return plugs_storage
    elif request.param is MemoryStorage:
        memory_storage = MemoryStorage()
        return memory_storage
    else:
        assert False
Esempio n. 2
0
def storage(request):
    """
    Initializes a Storage for execution in a test environment. This fixture
    will instantiate the storage class given in the parameters. This way we
    ensure both the real implementation and dummy implementation work in the
    same way.

    When initializing the real PlugsStorage(), it will use a test-specific
    data-base to avoid any conflicts between tests and to avoid clashing with
    real databases.
    """
    if request.param is PlugsStorage:
        db_name = 'testing-{}'.format(request.node.name)

        plugs_storage = PlugsStorage(default_db_name=db_name)
        plugs_storage.__TESTING__ = True

        def finalizer():
            plugs_storage.get_connection().drop_database(db_name)

        request.addfinalizer(finalizer)
        return plugs_storage
    elif request.param is MemoryStorage:
        memory_storage = MemoryStorage()
        return memory_storage
    else:
        assert False
Esempio n. 3
0
from web import PlugsStorage
s=PlugsStorage()
s.drop_all()
print 'Database dropped'

Esempio n. 4
0
from web import PlugsStorage

s = PlugsStorage()
s.drop_all()
print("Database dropped")
Esempio n. 5
0
def storage():
    with PlugsStorage("sqlite:///:memory:") as st:
        yield st