예제 #1
0
from dad.test import mixin_controller


class MemoryDBTestCase(mixin_controller.BaseTestCase, unittest.TestCase):
    """
    I am a base class for mixin_controller tests using the memory database.
    """

    def setUp(self):
        self.testdb = memory.MemoryDB()
        self.provider = pdad.CoreDatabaseProvider()

class MemoryDBPickleTestCase(mixin_controller.BaseTestCase):
    """
    I am a base class for mixin_database tests using the memory database
    with pickle storage.
    """

    def setUp(self):
        self._fd, self._path = tempfile.mkstemp(suffix=u'.dad.test.memorydb')
        os.close(self._fd)

        self.testdb = memory.MemoryDB(self._path)
        self.provider = pdad.CoreDatabaseProvider()

    def tearDown(self):
        os.unlink(self._path)

# instantiate all generic database tests
globals().update(mixin_controller.makeTestCaseClasses(MemoryDBTestCase))
예제 #2
0
        # set up database

        yield self.db.createDB("dadtest")

        self.daddb = couch.DADDB(self.db, "dadtest")
        self.testdb = self.daddb

        thisDir = os.path.dirname(__file__)
        couchPath = os.path.abspath(os.path.join(thisDir, "..", "..", "..", "couchdb"))
        (status, output) = commands.getstatusoutput(
            "couchapp push --docid _design/dad "
            + "%s http://%s:%s@localhost:%d/dadtest/" % (couchPath, "testpaisley", "testpaisley", self.wrapper.port)
        )
        self.failIf(status, "Could not execute couchapp: %s" % output)


class CouchDatabaseTestCase(mixin_controller.BaseTestCase, DADDBTestCase):
    """
    I am a base class for tests defined in mixin_controller.
    """

    @defer.inlineCallbacks
    def setUp(self):
        yield DADDBTestCase.setUp(self)
        self.provider = pdadcouch.CouchDBDatabaseProvider()


# instantiate all generic database tests
globals().update(mixin_controller.makeTestCaseClasses(CouchDatabaseTestCase))