Beispiel #1
0
"""
    SQLite model unit tests
"""
import unittest
import subprocess, tempfile, os, signal, sys
import string, random, shutil, time

import modelTest 
from vesper.data.store.sqlite import SqliteStore, TransactionSqliteStore

class SqliteModelTestCase(modelTest.BasicModelTestCase):
    
    def getModel(self):
        model = SqliteStore(None)
        return self._getModel(model)

    def getTransactionModel(self):
        model = TransactionSqliteStore(self.tmpfilename)
        return self._getModel(model)

    def setUp(self):
        self.tmpdir = tempfile.mkdtemp(prefix="rhizometest")
        self.tmpfilename = os.path.join(self.tmpdir, 'test.sqlite') 
        
    def tearDown(self):
        #print 'tear down removing', self.tmpdir
        shutil.rmtree(self.tmpdir)

if __name__ == '__main__':
    modelTest.main(SqliteModelTestCase)
Beispiel #2
0
    proc = data['proc']
    if not proc.poll(): # process still alive
        #print "waiting for tyrant server to die..."
        #proc.terminate() #2.6 only, so use:
        os.kill(proc.pid, signal.SIGTERM)
        proc.wait()
        #print "tyrant server exited"
    shutil.rmtree(data['tmpdir'])

class TyrantModelTestCase(modelTest.BasicModelTestCase):    

    def getModel(self):
        port = self.tyrant['port']
        model = TyrantStore('127.0.0.1', port)
        return self._getModel(model)

    def getTransactionModel(self):
        port = self.tyrant['port']
        model = TransactionTyrantStore('127.0.0.1', port)
        return self._getModel(model)
    
    def setUp(self):
        self.tyrant = start_tyrant_server()

    def tearDown(self):
        stop_tyrant_server(self.tyrant)
        self.tyrant = None

if __name__ == '__main__':
    modelTest.main(TyrantModelTestCase)
Beispiel #3
0
    EXT = 'nt' #XXX EXT = 'json' fails because model uses the default writeTriples
    
    def getModel(self):
        #print 'opening', self.tmpfilename
        #sys.stdout.flush()
        model = IncrementalNTriplesFileStoreBase(self.tmpfilename)
        return model#self._getModel(model)

    def getTransactionModel(self):
        model = IncrementalNTriplesFileStoreBase(self.tmpfilename)
        return model#self._getModel(model)
    
    def testCommitFailure(self):
        pass #this test needs to be disabled for IncrementalNTriplesFileStore

    def testExternalChange(self):
        pass #XXX override overwriteString in test with one compatible with this model
        
class TransactionIncrementalFileModelTestCase(IncrementalFileModelTestCase):

    def getModel(self):
        model = IncrementalNTriplesFileStore(self.tmpfilename)
        return model#self._getModel(model)

    def getTransactionModel(self):
        model = IncrementalNTriplesFileStore(self.tmpfilename)
        return model#self._getModel(model)

if __name__ == '__main__':
    modelTest.main(FileModelTestCase)
Beispiel #4
0
    BDB model unit tests
"""
import unittest
import subprocess, tempfile, os, signal, sys
import string, random, shutil, time

import modelTest 
from vesper.data.store.bdb import BdbStore

class BdbModelTestCase(modelTest.BasicModelTestCase):
    persistentStore = True

    def getModel(self):
        model = BdbStore(self.tmpfilename, autcommit=True)
        return self._getModel(model)

    def getTransactionModel(self):
        model = BdbStore(self.tmpfilename, autocommit=False)
        return self._getModel(model)

    def setUp(self):
        self.tmpdir = tempfile.mkdtemp(prefix="rhizometest")
        self.tmpfilename = os.path.join(self.tmpdir, 'test.bdb') 
        
    def tearDown(self):
        #print 'tear down removing', self.tmpdir
        shutil.rmtree(self.tmpdir)

if __name__ == '__main__':
    modelTest.main(BdbModelTestCase)
Beispiel #5
0
    def getModel(self):
        model = AlchemySqlStore(self.tmpfilename, autocommit=True)
        return self._getModel(model)

    def getTransactionModel(self):
        model = AlchemySqlStore(self.tmpfilename, autocommit=False)
        return self._getModel(model)

    def setUp(self):
        '''
        Until I figure out a decent way to compartmentalize the particulars for more than
        one SQL database flavor, I hard-code this configuration right here for testing purposes
        using SQLA configuration parameter canning device, to wit (sqla 0.7.4): 
        class sqlalchemy.engine.url.URL(drivername, 
            username=None, 
            password=None, 
            host=None, 
            port=None, 
            database=None, 
            query=None)
        ''' 
        self.tmpdir = tempfile.mkdtemp(prefix="rhizometest")
        fname = os.path.abspath(os.path.join(self.tmpdir, 'test.sqlite'))
        self.tmpfilename = "sqlite:///{0}".format(fname)
       
    def tearDown(self):
        shutil.rmtree(self.tmpdir)

if __name__ == '__main__':
    modelTest.main(AlchemySqlModelTestCase)
Beispiel #6
0
import subprocess, tempfile, os, signal
import string, random, shutil, time

import modelTest
from vesper.data.store.memcache import MemCacheStore, TransactionMemCacheStore

_prefixCounter = time.time()

class MemCacheModelTestCase(modelTest.BasicModelTestCase):   
    
    def getModel(self):    
        model = MemCacheStore(prefix=str(self._prefixCounter))
        return self._getModel(model)

    def getTransactionModel(self):
        model = TransactionMemCacheStore(prefix=str(self._prefixCounter))
        return self._getModel(model)

    def setUp(self):
        global _prefixCounter
        _prefixCounter += 1
        self._prefixCounter = _prefixCounter
        print 'count', self._prefixCounter
        
    def tearDown(self):
        pass

if __name__ == '__main__':
    modelTest.main(MemCacheModelTestCase)