Exemple #1
0
 def _migrate(cls):
     field = QueryCompiler().field_sql(cls.pp_log)
     table = cls._meta.db_table
     if cls._checkForColumn(cls.pp_log):
         return False  # False like: dude stop !
     cls._meta.database.execute_sql('ALTER TABLE %s ADD COLUMN %s' %
                                    (table, field))
     return True
Exemple #2
0
    def __init__(self, *args, **kwargs):
        self.queries = []
        logging.Handler.__init__(self, *args, **kwargs)

    def emit(self, record):
        self.queries.append(record)


database_initializer = DatabaseInitializer(TEST_BACKEND, TEST_DATABASE)

database_class = database_initializer.get_database_class()
test_db = database_initializer.get_database()
query_db = TestDatabase(':memory:')

compiler = query_db.compiler()
normal_compiler = QueryCompiler('"', '?', {}, {})


class TestModel(Model):
    class Meta:
        database = test_db


class PeeweeTestCase(TestCase):
    def setUp(self):
        self.qh = QueryLogHandler()
        logger.setLevel(logging.DEBUG)
        logger.addHandler(self.qh)

    def tearDown(self):
        logger.removeHandler(self.qh)