Пример #1
0
 def test_save_import(self):
     ctx0 = Context(ident='http://example.com/context_0')
     ctx = Context(ident='http://example.com/context_1')
     new_ctx = Context(ident='http://example.com/context_1')
     ctx.add_import(new_ctx)
     ctx.save_imports(ctx0)
     self.assertEqual(len(ctx0), 1)
Пример #2
0
    def test_imports_no_imports_graph_in_stored(self):
        # create a Data config so all contexts use the same rdflib.Graph
        conf = Data()
        ctx = Context('http://example.org/ctx1', conf=conf)
        imported_ctx = Context('http://example.org/ctx2', conf=conf)
        other_ctx = Context('http://example.org/other_ctx', conf=conf)
        ctx.add_import(imported_ctx)
        ctx.save_imports(other_ctx)

        assert list(ctx.stored.imports) == []
Пример #3
0
    def test_imports_with_imports_graph_in_stored(self):
        # create a Data config so all contexts use the same rdflib.Graph
        conf = Data()
        conf.init()
        conf[IMPORTS_CONTEXT_KEY] = 'http://example.org/imports'
        ctx = Context('http://example.org/ctx1', conf=conf)
        imported_ctx = Context('http://example.org/ctx2', conf=conf)
        imports_ctx = Context('http://example.org/imports', conf=conf)
        ctx.add_import(imported_ctx)
        ctx.save_imports(imports_ctx)

        assert [c.identifier
                for c in ctx.stored.imports] == [imported_ctx.identifier]
Пример #4
0
 def test_add_import(self):
     ctx0 = Context(ident='http://example.com/context_0')
     ctx = Context(ident='http://example.com/context_1')
     ctx2 = Context(ident='http://example.com/context_2')
     ctx2_1 = Context(ident='http://example.com/context_2_1')
     ctx.add_import(ctx2)
     ctx.add_import(ctx2_1)
     ctx3 = Context(ident='http://example.com/context_3')
     ctx3.add_import(ctx)
     final_ctx = Context(ident='http://example.com/context_1',
                         imported=(ctx3, ))
     final_ctx.save_imports(ctx0)
     self.assertEqual(len(ctx0), 4)
Пример #5
0
 def test_zero_imports(self):
     ctx0 = Context(ident='http://example.com/context_0')
     ctx = Context(ident='http://example.com/context_1')
     ctx.save_imports(ctx0)
     self.assertEqual(len(ctx0), 0)