Esempio n. 1
0
def test_suite():
    suite = unittest.TestSuite()
    if not have_backend('mysql'):
        print "Skipping mysql tests"
        return suite

    import MySQLdb
    try:
        # Check if we can connect to the server.
        # use db_exists() to make a connection, ignore it's return value
        mysqlOpener.module.db_exists(config)
    except (MySQLdb.MySQLError, DatabaseError), msg:
        print "Skipping mysql tests (%s)"%msg
Esempio n. 2
0
class tsearch2Opener:
    if have_backend('tsearch2'):
        module = get_backend('tsearch2')

    def setUp(self):
        pass

    def tearDown(self):
        self.nuke_database()

    def nuke_database(self):
        # clear out the database - easiest way is to nuke and re-create it
        self.module.db_nuke(config)
Esempio n. 3
0
class mysqlOpener:
    if have_backend('mysql'):
        module = get_backend('mysql')

    def setUp(self):
        self.module.db_nuke(config)

    def tearDown(self):
        self.db.close()
        self.nuke_database()

    def nuke_database(self):
        self.module.db_nuke(config)
Esempio n. 4
0
def test_suite():
    suite = unittest.TestSuite()
    if not have_backend('mysql'):
        print "Skipping mysql tests"
        return suite

    import MySQLdb
    try:
        # Check if we can connect to the server.
        # use db_exists() to make a connection, ignore it's return value
        mysqlOpener.module.db_exists(config)
    except (MySQLdb.MySQLError, DatabaseError), msg:
        print "Skipping mysql tests (%s)" % msg
Esempio n. 5
0
def test_suite():
    suite = unittest.TestSuite()
    from roundup import backends
    if not have_backend('sqlite'):
        print 'Skipping sqlite tests'
        return suite
    print 'Including sqlite tests'
    suite.addTest(unittest.makeSuite(sqliteDBTest))
    suite.addTest(unittest.makeSuite(sqliteROTest))
    suite.addTest(unittest.makeSuite(sqliteSchemaTest))
    suite.addTest(unittest.makeSuite(sqliteClassicInitTest))
    suite.addTest(unittest.makeSuite(sqliteSessionTest))
    return suite
Esempio n. 6
0
def test_suite():
    suite = unittest.TestSuite()

    suite.addTest(unittest.makeSuite(IndexerTest))

    try:
        import xapian

        suite.addTest(unittest.makeSuite(XapianIndexerTest))
    except ImportError:
        print "Skipping Xapian indexer tests"
        pass

    if have_backend("postgresql"):
        # make sure we start with a clean slate
        if postgresqlOpener.module.db_exists(config):
            postgresqlOpener.module.db_nuke(config, 1)
        suite.addTest(unittest.makeSuite(postgresqlIndexerTest))
    else:
        print "Skipping postgresql indexer tests"

    if have_backend("mysql"):
        # make sure we start with a clean slate
        if mysqlOpener.module.db_exists(config):
            mysqlOpener.module.db_nuke(config)
        suite.addTest(unittest.makeSuite(mysqlIndexerTest))
    else:
        print "Skipping mysql indexer tests"

    if have_backend("sqlite"):
        # make sure we start with a clean slate
        if sqliteOpener.module.db_exists(config):
            sqliteOpener.module.db_nuke(config)
        suite.addTest(unittest.makeSuite(sqliteIndexerTest))
    else:
        print "Skipping sqlite indexer tests"

    return suite
Esempio n. 7
0
def test_suite():
    suite = unittest.TestSuite()
    from roundup import backends

    if not have_backend("sqlite"):
        print "Skipping sqlite tests"
        return suite
    print "Including sqlite tests"
    suite.addTest(unittest.makeSuite(sqliteDBTest))
    suite.addTest(unittest.makeSuite(sqliteROTest))
    suite.addTest(unittest.makeSuite(sqliteSchemaTest))
    suite.addTest(unittest.makeSuite(sqliteClassicInitTest))
    suite.addTest(unittest.makeSuite(sqliteSessionTest))
    suite.addTest(unittest.makeSuite(sqliteConcurrencyTest))
    suite.addTest(unittest.makeSuite(sqliteFilterCacheTest))
    return suite
Esempio n. 8
0
def test_suite():
    suite = unittest.TestSuite()
    if not have_backend('postgresql'):
        print "Skipping postgresql tests"
        return suite

    # make sure we start with a clean slate
    if postgresqlOpener.module.db_exists(config):
        postgresqlOpener.module.db_nuke(config, 1)

    # TODO: Check if we can run postgresql tests
    print 'Including postgresql tests'
    suite.addTest(unittest.makeSuite(postgresqlDBTest))
    suite.addTest(unittest.makeSuite(postgresqlROTest))
    suite.addTest(unittest.makeSuite(postgresqlSchemaTest))
    suite.addTest(unittest.makeSuite(postgresqlClassicInitTest))
    suite.addTest(unittest.makeSuite(postgresqlSessionTest))
    return suite
Esempio n. 9
0
def test_suite():
    suite = unittest.TestSuite()
    if not have_backend('tsearch2'):
        print "Skipping tsearch2 tests"
        return suite

    # make sure we start with a clean slate
    if tsearch2Opener.module.db_exists(config):
        tsearch2Opener.module.db_nuke(config, 1)

    # TODO: Check if we can run postgresql tests
    print 'Including tsearch2 tests'
    suite.addTest(unittest.makeSuite(tsearch2DBTest))
    suite.addTest(unittest.makeSuite(tsearch2ROTest))
    suite.addTest(unittest.makeSuite(tsearch2SchemaTest))
    suite.addTest(unittest.makeSuite(tsearch2ClassicInitTest))
    suite.addTest(unittest.makeSuite(tsearch2SessionTest))
    return suite
Esempio n. 10
0
class postgresqlOpener:
    if have_backend('postgresql'):
        module = get_backend('postgresql')

    def setup_class(cls):
        # nuke the db once for the class. Handles the case
        # where an aborted test run (^C during setUp for example)
        # leaves the database in an unusable, partly configured state.
        try:
            cls.nuke_database(cls)
        except:
            # ignore failure to nuke the database.
            pass

    def setUp(self):
        pass

    def tearDown(self):
        self.nuke_database()

    def nuke_database(self):
        # clear out the database - easiest way is to nuke and re-create it
        self.module.db_nuke(config)
Esempio n. 11
0
class sqliteOpener:
    if have_backend('sqlite'):
        module = get_backend('sqlite')

    def nuke_database(self):
        shutil.rmtree(config.DATABASE)
Esempio n. 12
0
    def setUp(self):
        self.module.db_nuke(config)

    def tearDown(self):
        self.db.close()
        self.nuke_database()

    def nuke_database(self):
        self.module.db_nuke(config)


# FIX: workaround for a bug in pytest.mark.skip():
#   https://github.com/pytest-dev/pytest/issues/568
from .pytest_patcher import mark_class

if not have_backend('mysql'):
    skip_mysql = mark_class(
        pytest.mark.skip(reason='Skipping MySQL tests: backend not available'))
else:
    try:
        import MySQLdb
        mysqlOpener.module.db_exists(config)
        skip_mysql = lambda func, *args, **kwargs: func
    except (MySQLdb.MySQLError, DatabaseError) as msg:
        skip_mysql = mark_class(
            pytest.mark.skip(reason='Skipping MySQL tests: %s' % str(msg)))


@skip_mysql
class mysqlDBTest(mysqlOpener, DBTest, unittest.TestCase):
    def setUp(self):
Esempio n. 13
0
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

import unittest

import pytest
from roundup.hyperdb import DatabaseError
from roundup.backends import get_backend, have_backend

from .db_test_base import DBTest, ROTest, config, SchemaTest, ClassicInitTest
from .db_test_base import ConcurrentDBTest, HTMLItemTest, FilterCacheTest
from .db_test_base import ClassicInitBase, setupTracker, SpecialActionTest

if not have_backend('postgresql'):
    # FIX: workaround for a bug in pytest.mark.skip():
    #   https://github.com/pytest-dev/pytest/issues/568
    from .pytest_patcher import mark_class
    skip_postgresql = mark_class(
        pytest.mark.skip(
            reason='Skipping PostgreSQL tests: backend not available'))
else:
    try:
        from roundup.backends.back_postgresql import psycopg, db_command
        db_command(config, 'select 1')
        skip_postgresql = lambda func, *args, **kwargs: func
    except (DatabaseError) as msg:
        from .pytest_patcher import mark_class
        skip_postgresql = mark_class(
            pytest.mark.skip(