Example #1
0
    def __init__(self, **kwargs):
        self.backup = kwargs.get('backup', True)
        self.normalize = kwargs.get('normalize', True)
        self.dbpath = kwargs.get('dbpath')
        if not self.dbpath:
            self.dbpath = DEFAULT_DB_FILE
        logger.debug(_("Using database file '%s'") % self.dbpath)
        
        engine = kwargs.get('engine')
        if not engine:
            engine = create_engine('sqlite:///%s' % self.dbpath)
            metadata.bind = engine
            session.configure(bind=engine)

        self._photoset = None
        self._db_version = None
Example #2
0
# -*- coding: utf8 -*-
import os
import unittest

from fixture import DataSet, DataTestCase, SQLAlchemyFixture

from models import create_engine, metadata, session, Photo, Tag, Meta
from controller import FSpotController


# Setup temporary database
DB_PATH = ':memory:'
engine = create_engine('sqlite:///' + DB_PATH)
metadata.bind = engine
session.configure(bind=engine)
metadata.create_all()

BASE_PATH=os.path.abspath(os.path.dirname(__file__))

"""
Fixtures
"""
dbfixture = SQLAlchemyFixture(env={'PhotoData': Photo, 
                                   'TagData': Tag,
                                   'MetaData': Meta},
                              engine=metadata.bind)

class PhotoData(DataSet):
    class on_disk:
        base_uri = os.path.join('file://', BASE_PATH, 'tests')
        filename = 'bee.jpg'