Beispiel #1
0
    def test_dbadd(self):
        from ptrdf.triples.db import DBTriples
        dbname = 'new02.db'
        t = DBTriples(dbname,'n')
        t.add('foo','bar','baz')
        t.add('foo','bar','quux')
        t.commit()
        t.disconnect()

        expected = ''.join(map(lambda x: x+'\n',
                               sorted(('v1 = foo', 'ifoo = 1',
                                       'v2 = bar', 'ibar = 2',
                                       'v3 = baz', 'ibaz = 3',
                                       'v4 = quux', 'iquux = 4',
                                       'l = 4',
                                       't1,2,3 = 1',
                                       't1,2,4 = 1',
                                       'o1,2 = 3+4',
                                       's2,3 = 1',
                                       's2,4 = 1'))))
        self.assertEqual(dbread(dbname), expected, 'db data for 2 triples')