Ejemplo n.º 1
0
    def test_trix_source(self):
        """ Test that we can load the datbase up from an XML file.
        """
        f = tempfile.mkstemp()

        c = Configure()
        c['rdf.source'] = 'trix'
        c['rdf.store'] = 'default'
        c['trix_location'] = f[1]

        with open(f[1], 'w') as fo:
            fo.write(TD.TriX_data)

        connect(conf=c)
        c = config()

        try:
            g = c['rdf.graph']
            b = g.query("ASK { ?S ?P ?O }")
            for x in b:
                self.assertTrue(x)
        except ImportError:
            pass
        finally:
            disconnect()
        os.unlink(f[1])
Ejemplo n.º 2
0
    def test_l(self):
        """
        Test that a property can be loaded when the owning
        object doesn't have any other values set
        This test is for many objects of the same kind
        """
        disconnect()
        from random import random
        from time import time
        # Generate data sets from 10 to 10000 in size
        #  query for properties
        print('starting testl')

        class _to(DataObject):

            def __init__(self, x=False):
                DataObject.__init__(self)
                DatatypeProperty('flexo', owner=self)
                if x:
                    self.flexo(x)
        # feel free to add more if you have the time
        nums = [10, 1e2, 1e3]

        connect("tests/testl.conf")
        try:
            # for 1000, takes about 10 seconds...
            for x in nums:
                print(
                    'running ',
                    x,
                    'sized test on a ',
                    Configureable.default['rdf.graph'].store,
                    'store')
                v = values('zim')
                for z in range(int(x)):
                    v.add(_to(random()))
                t0 = time()
                v.save()
                for _ in _to().flexo():
                    pass
                t1 = time()
                print("took", t1 - t0, "seconds")
                Configureable.default['rdf.graph'].remove((None, None, None))
        except:
            traceback.print_exc()
        disconnect()
Ejemplo n.º 3
0
    def test_l(self):
        """
        Test that a property can be loaded when the owning
        object doesn't have any other values set
        This test is for many objects of the same kind
        """
        disconnect()
        from random import random
        from time import time
        # Generate data sets from 10 to 10000 in size
        #  query for properties
        print('starting testl')

        class _to(DataObject):
            def __init__(self, x=False):
                DataObject.__init__(self)
                DatatypeProperty('flexo', owner=self)
                if x:
                    self.flexo(x)

        # feel free to add more if you have the time
        nums = [10, 1e2, 1e3]

        connect("tests/testl.conf")
        try:
            # for 1000, takes about 10 seconds...
            for x in nums:
                print('running ', x, 'sized test on a ',
                      Configureable.default['rdf.graph'].store, 'store')
                v = values('zim')
                for z in range(int(x)):
                    v.add(_to(random()))
                t0 = time()
                v.save()
                for _ in _to().flexo():
                    pass
                t1 = time()
                print("took", t1 - t0, "seconds")
                Configureable.default['rdf.graph'].remove((None, None, None))
        except:
            traceback.print_exc()
        disconnect()
Ejemplo n.º 4
0
def teardown():
    disconnect()
Ejemplo n.º 5
0
def teardown():
    disconnect()
Ejemplo n.º 6
0
 def tearDown(self):
     disconnect()
Ejemplo n.º 7
0
 def tearDown(self):
     disconnect()
Ejemplo n.º 8
0
def teardown():
    disconnect(connection)
Ejemplo n.º 9
0
def teardown():
    disconnect(connection)