Ejemplo n.º 1
0
 def test_contents_triples(self):
     res_wanted = []
     ident_uri = 'http://example.com/context_1'
     ctx = Context(ident=ident_uri)
     for i in range(5):
         stmt = create_mock_statement(ident_uri, i)
         ctx.add_statement(stmt)
         res_wanted.append(stmt.to_triple())
     for triples in ctx.contents_triples():
         self.assertTrue(triples in res_wanted)
Ejemplo n.º 2
0
 def test_contents_triples(self):
     res_wanted = []
     ident_uri = 'http://example.com/context_1'
     ctx = Context(ident=ident_uri)
     for i in range(5):
         stmt = create_mock_statement(ident_uri, i)
         ctx.add_statement(stmt)
         res_wanted.append(stmt.to_triple())
     for triples in ctx.contents_triples():
         self.assertTrue(triples in res_wanted)
Ejemplo n.º 3
0
    def test_inverse_property_context(self):
        class A(DataObject):
            def __init__(self, **kwargs):
                super(A, self).__init__(**kwargs)
                self.a = A.ObjectProperty(value_type=B)

        class B(DataObject):
            def __init__(self, **kwargs):
                super(B, self).__init__(**kwargs)
                self.b = B.ObjectProperty(value_type=A)
        InverseProperty(B, 'b', A, 'a')
        ctx1 = Context(ident='http://example.org/context_1')
        ctx2 = Context(ident='http://example.org/context_2')
        a = ctx1(A)(ident='a')
        b = ctx2(B)(ident='b')
        a.a(b)
        expected = (URIRef('b'), URIRef('http://openworm.org/entities/B/b'), URIRef('a'))
        self.assertIn(expected, list(ctx1.contents_triples()))
Ejemplo n.º 4
0
    def test_inverse_property_context(self):
        class A(DataObject):
            def __init__(self, **kwargs):
                super(A, self).__init__(**kwargs)
                self.a = A.ObjectProperty(value_type=B)

        class B(DataObject):
            def __init__(self, **kwargs):
                super(B, self).__init__(**kwargs)
                self.b = B.ObjectProperty(value_type=A)

        InverseProperty(B, 'b', A, 'a')
        ctx1 = Context(ident='http://example.org/context_1')
        ctx2 = Context(ident='http://example.org/context_2')
        a = ctx1(A)(ident='a')
        b = ctx2(B)(ident='b')
        a.a(b)
        expected = (URIRef('b'), URIRef('http://openworm.org/entities/B/b'),
                    URIRef('a'))
        self.assertIn(expected, list(ctx1.contents_triples()))