Esempio n. 1
0
def test_resolve_property_class_stored():
    conf = Data()
    conf.init()
    ctxid = 'http://example.org/ctx'
    ctx0 = Context(ctxid, conf=conf)
    modname = ModelDBPropertyClassDescription.__module__
    mod = ctx0(PythonModule)(name=modname)
    cd = ctx0(ModelDBPropertyClassDescription)(name='ModelDB_test_property',
                                               local_id='test_property',
                                               display_name='Test Property',
                                               module=mod)
    ctx0.save()

    ctx1 = Context(ctxid, conf=conf)
    ctx1.stored(ModelDBPropertyClassDescription)(ident=cd.identifier)
    assert issubclass(cd.resolve_class(), Property)
Esempio n. 2
0
def test_resolve_property_attr_from_graph():
    conf = Data()
    conf.init()
    ctxid = 'http://example.org/ctx'
    ctx0 = Context(ctxid, conf=conf)
    modname = ModelDBPropertyClassDescription.__module__
    mod = ctx0(PythonModule)(name=modname)
    ctx0(ModelDBPropertyClassDescription)(name='ModelDB_test_property',
                                          local_id='test_property',
                                          display_name='Test Property',
                                          module=mod)
    ctx0.save()

    ctx1 = Context(ctxid, conf=conf)
    ds = ctx1.stored(ModelDBDataSource)()
    assert ds.test_property is ds.test_property
Esempio n. 3
0
    def test_stored(self):
        '''
        Test resolving a class when the relevant data are "stored" in a RDFLib graph
        '''
        ctxid = 'http://example.org/test'
        ctx = Context(ident=ctxid, conf=self.TestConfig)

        cname = self.__class__.__name__
        mname = self.__class__.__module__
        trips = [(pcd, PythonClassDescription.name.link, R.Literal(cname),
                  ctxid), (pcd, PythonClassDescription.module.link, pm, ctxid),
                 (pm, PythonModule.name.link, R.Literal(mname), ctxid),
                 (pm, R.RDF.type, PythonModule.rdf_type, ctxid)]
        for t in trips:
            ctx.rdf.add(t)
        pcddo = ctx.stored(PythonClassDescription)(ident=pcd)
        self.assertEqual(self.__class__, pcddo.resolve_class())
Esempio n. 4
0
        if len(lctx) == 0:
            return frozenset()
        else:
            lctx = frozenset(ctxs) & lctx
            if len(lctx) == 0:
                return lctx
    return frozenset() if lctx is None else lctx


qctx = Context()
qctx(Neuron)('AVAL').innexin('UNC-7')
ctxs = query_context(conn.conf['rdf.graph'], qctx)
for c in ctxs:
    mqctx = Context(conf=conn.conf)
    print('CONTEXT', c.identifier)
    ev = mqctx.stored(Evidence)()
    ev.supports(Context(ident=c.identifier, conf=conn.conf).rdf_object)
    for x in ev.load():
        ref = x.reference()
        if isinstance(ref, Document):
            print(ref)
            print('AUTHOR:', ref.author())
            print('URI:', ref.uri())
            print('DOI:', ref.doi())
            print('PMID:', ref.pmid())
            print('WBID:', ref.wbid())
            print()
        elif isinstance(ref, Website):
            print(ref)
            print('TITLE:', ref.title())
            print('URL:', ref.url())