Exemple #1
0
    def testGraphConfigGraphFiles(self):
        conf = QuitConfiguration(configmode='graphfiles',
                                 configfile=self.localConfigFile)

        conf.initgraphconfig()
        graphs = conf.getgraphs()
        self.assertEqual(
            sorted(graphs),
            ['http://example.org/2/', 'http://example.org/discovered/'])

        files = conf.getfiles()
        self.assertEqual(sorted(files), ['example1.nq', 'example2.nt'])

        serialization = conf.getserializationoffile('example1.nq')
        self.assertEqual(serialization, 'nquads')

        gfMap = conf.getgraphurifilemap()
        self.assertEqual(
            gfMap, {
                'http://example.org/discovered/': 'example1.nq',
                'http://example.org/2/': 'example2.nt'
            })

        self.assertEqual(conf.getgraphuriforfile('example1.nq'),
                         ['http://example.org/discovered/'])
        self.assertEqual(conf.getgraphuriforfile('example2.nt'),
                         ['http://example.org/2/'])
        self.assertEqual(
            conf.getfileforgraphuri('http://example.org/discovered/'),
            'example1.nq')
        self.assertEqual(conf.getfileforgraphuri('http://example.org/2/'),
                         'example2.nt')
Exemple #2
0
    def testGraphConfigRemoteConfig(self):
        conf = QuitConfiguration(configmode='repoconfig',
                                 configfile=self.localConfigFile,
                                 namespace=self.ns)

        conf.initgraphconfig()
        graphs = conf.getgraphs()
        self.assertEqual(sorted([str(x) for x in graphs]),
                         ['http://example.org/1/', 'http://example.org/2/'])

        files = conf.getfiles()
        self.assertEqual(sorted(files), ['example1.nq', 'example2.nt'])

        serialization = conf.getserializationoffile('example1.nq')
        self.assertEqual(serialization, 'nquads')

        gfMap = conf.getgraphurifilemap()
        self.assertEqual(
            gfMap, {
                rdflib.term.URIRef('http://example.org/1/'): 'example1.nq',
                rdflib.term.URIRef('http://example.org/2/'): 'example2.nt'
            })

        self.assertEqual(
            [str(x) for x in conf.getgraphuriforfile('example1.nq')],
            ['http://example.org/1/'])
        self.assertEqual(
            [str(x) for x in conf.getgraphuriforfile('example2.nt')],
            ['http://example.org/2/'])
        self.assertEqual(conf.getfileforgraphuri('http://example.org/1/'),
                         'example1.nq')
        self.assertEqual(conf.getfileforgraphuri('http://example.org/2/'),
                         'example2.nt')