Example #1
0
 def test_upload_date(self):
     """ Make sure that we're marking a statement with it's upload date """
     g = make_graph(20)
     r = DataObject(triples=g)
     r.save()
     u = r.upload_date()
     self.assertIsNotNone(u)
Example #2
0
    def test_asserts_query_multiple(self):
        """ Show that setting the evidence with distinct objects yields
            distinct results """
        r = DataObject(key='relationship')
        ar = DataObject(key='aref')
        br = DataObject(key='bref')

        e = self.ctx.Evidence(key="a", reference=ar)
        e.supports(r)
        self.save()

        e1 = self.ctx.Evidence(key="b", reference=br)
        e1.supports(r)
        self.save()

        e0 = Evidence()
        e0.supports(r)
        for x in e0.load():
            lar = x.reference.one()
            lbr = x.reference.one()
            # Testing that either a has a result [email protected] and y has nothing or
            # y has a result 1999 and a has nothing
            if x.idl == e1.idl:
                self.assertEqual(lbr, br)
            elif x.idl == e.idl:
                self.assertEqual(lar, ar)
            else:
                self.fail("Unknown object returned from load")
 def test_diff_prop_same_name_same_object_diff_value_same_id(self):
     do = self.ctx.DataObject(ident=R.URIRef("http://example.org"))
     c = DataObject.DatatypeProperty("boots", do)
     c1 = DataObject.DatatypeProperty("boots", do)
     c('partition')
     c1('join')
     self.assertEqual(c.identifier, c1.identifier)
Example #4
0
 def test_uploader(self):
     """ Make sure that we're marking a statement with it's uploader """
     g = make_graph(20)
     r = DataObject(triples=g, conf=self.config)
     r.save()
     u = r.uploader()
     self.assertEqual(self.config['user.email'], u)
Example #5
0
 def test_uploader(self):
     """ Make sure that we're marking a statement with it's uploader """
     g = make_graph(20)
     r = DataObject(triples=g, conf=self.config)
     r.save()
     u = r.uploader()
     self.assertEqual(self.config['user.email'], u)
Example #6
0
 def test_upload_date(self):
     """ Make sure that we're marking a statement with it's upload date """
     g = make_graph(20)
     r = DataObject(triples=g)
     r.save()
     u = r.upload_date()
     self.assertIsNotNone(u)
 def test_diff_value_diff_id_equal(self):
     do = self.ctx.DataObject(ident=R.URIRef("http://example.org"))
     do1 = self.ctx.DataObject(ident=R.URIRef("http://example.org"))
     c = DataObject.DatatypeProperty("boots", do)
     c1 = DataObject.DatatypeProperty("boots", do1)
     do.boots('join')
     do1.boots('partition')
     self.assertEqual(c.identifier, c1.identifier)
 def test_same_value_same_id_not_empty_object_property(self):
     do = self.ctx.DataObject(ident=R.URIRef("http://example.org"))
     do1 = self.ctx.DataObject(ident=R.URIRef("http://example.org"))
     dz = self.ctx.DataObject(ident=R.URIRef("http://example.org/vip"))
     dz1 = self.ctx.DataObject(ident=R.URIRef("http://example.org/vip"))
     c = DataObject.ObjectProperty("boots", do)
     c1 = DataObject.ObjectProperty("boots", do1)
     do.boots(dz)
     do1.boots(dz1)
     self.assertEqual(c.identifier, c1.identifier)
    def test_diff_value_insert_order_same_id(self):
        do = self.ctx.DataObject(ident=R.URIRef("http://example.org"))
        do1 = self.ctx.DataObject(ident=R.URIRef("http://example.org"))

        print(list(self.context.contents_triples()))
        c = DataObject.DatatypeProperty("boots", do, multiple=True)
        c1 = DataObject.DatatypeProperty("boots", do1, multiple=True)
        do.boots('join')
        do.boots('simile')
        do.boots('partition')
        do1.boots('partition')
        do1.boots('join')
        do1.boots('simile')
        self.assertEqual(c.identifier, c1.identifier)
Example #10
0
    def test_multiple_evidence_for_single_fact(self):
        """
        Can we assert the same fact with two distinct pieces of Evidence?
        """

        e1 = Evidence()
        e1.pmid('777')

        e2 = Evidence()
        e2.pmid('888')

        c = DataObject(key=23)
        e1.asserts(c)
        e2.asserts(c)

        e1.save()
        e2.save()

        evs = Evidence()
        evs.asserts(c)

        saved_pmids = set(['777', '888'])
        loaded_pmids = set([x.pmid() for x in evs.load()])

        self.assertTrue(saved_pmids.issubset(loaded_pmids))
Example #11
0
    def test_asserts_query_multiple(self):
        """ Show that setting the evidence with distinct objects yields
            distinct results """
        r = DataObject(key='relationship')

        e = Evidence(key="a", author='*****@*****.**')
        e.asserts(r)
        e.save()

        e1 = Evidence(key="b", year=1999)
        e1.asserts(r)
        e1.save()

        e0 = Evidence()
        e0.asserts(r)
        for x in e0.load():
            a = x.author.one()
            y = x.year()
            # Testing that either a has a result [email protected] and y has nothing or
            # y has a result 1999 and a has nothing
            if x.idl == e1.idl:
                self.assertEqual(y, 1999)
            elif x.idl == e.idl:
                self.assertEqual(a, '*****@*****.**')
            else:
                self.fail("Unknown object returned from load")
 def test_cache_no_refresh_for_no_change(self):
     o = self.ctx.DataObject(ident=R.URIRef("http://example.org/a"))
     DataObject.DatatypeProperty("boots", o)
     o.boots()
     c1 = o.po_cache
     self.assertIsNotNone(c1)
     o.boots()
     self.assertIs(c1, o.po_cache)
    def test_property_get_returns_collection(self):
        """
        This is for issue #175.
        """

        do = self.ctx.DataObject(ident=R.URIRef("http://example.org"))
        do.boots = DataObject.DatatypeProperty(multiple=True)
        do.boots(4)
        # self.save()

        do = self.ctx.DataObject(ident=R.URIRef("http://example.org"))
        do.boots = DataObject.DatatypeProperty(multiple=True)

        x = do.boots()
        l1 = list(x)
        print(l1)
        b = list(x)
        self.assertEqual([4], b)
Example #14
0
 def test_asserts(self):
     """
     Asserting something should allow us to get it back.
     """
     e = Evidence(key='WBPaper00044600')
     r = DataObject(key="context_data_object")
     e.supports(r)
     s = list(e.supports.get())
     self.assertIn(r, s)
Example #15
0
 def test_asserts_query(self):
     """ Show that we can store the evidence on an object and later retrieve it """
     e = self.ctx.Evidence(key="a")
     r = DataObject(key="relationship")
     e.supports(r)
     self.save()
     e0 = self.ctx.Evidence()
     e0.supports(r)
     s = list(e0.load())
     self.assertIn(e, s)
Example #16
0
 def test_asserts(self):
     """
     Asserting something should allow us to get it back.
     """
     e = Evidence(key='WBPaper00044600', wormbase='WBPaper00044600')
     r = DataObject(key="relationship")
     e.asserts(r)
     e.save()
     l = list(e.asserts())
     self.assertIn(r, l)
 def test_cache_refresh_clear(self):
     o = self.ctx.DataObject(ident=R.URIRef("http://example.org/a"))
     DataObject.DatatypeProperty("boots", o)
     o.boots()
     c1 = o.po_cache
     self.assertIsNotNone(c1)
     # XXX: Note that it doesn't matter if the triple was
     # actually in the graph
     o.clear_po_cache()
     o.boots()
     self.assertIsNot(c1, o.po_cache)
 def test_cache_refresh_after_triple_add(self):
     o = self.ctx.DataObject(ident=R.URIRef("http://example.org/a"))
     DataObject.DatatypeProperty("boots", o)
     o.boots()
     c1 = o.po_cache
     self.assertIsNotNone(c1)
     self.config['rdf.graph'].add(
         (R.URIRef('http://example.org/a'), R.URIRef('http://bluhbluh.com'),
          R.URIRef('http://bluhah.com')))
     o.boots()
     self.assertIsNot(c1, o.po_cache)
Example #19
0
 def test_asserts_query(self):
     """ Show that we can store the evidence on an object and later retrieve it """
     e = Evidence(key="a", author='*****@*****.**')
     r = DataObject(key="relationship")
     e.asserts(r)
     e.save()
     e0 = Evidence()
     e0.asserts(r)
     s = list(e0.load())
     author = s[0].author.one()
     self.assertIn('*****@*****.**', author)
    def test_object_property_diff_value_insert_order_same_id(self):
        do = self.ctx.DataObject(ident=R.URIRef("http://example.org"))
        do1 = self.ctx.DataObject(ident=R.URIRef("http://example.org"))

        oa = self.ctx.DataObject(ident=R.URIRef("http://example.org/a"))
        ob = self.ctx.DataObject(ident=R.URIRef("http://example.org/b"))
        oc = self.ctx.DataObject(ident=R.URIRef("http://example.org/c"))

        c = DataObject.ObjectProperty("boots", do, multiple=True)
        c1 = DataObject.ObjectProperty("boots", do1, multiple=True)

        do.boots(oa)
        do.boots(ob)
        do.boots(oc)

        do1.boots(oc)
        do1.boots(oa)
        do1.boots(ob)

        self.assertEqual(c.identifier, c1.identifier)
Example #21
0
    def setUp(self):
        super(Issue211EvidenceTest, self).setUp()
        self.e1 = self.ctx.Evidence()
        self.e2 = self.ctx.Evidence()

        c = DataObject(key=23)
        self.e1.supports(c)
        self.e2.supports(c)
        self.evs = self.context.stored(Evidence)()
        self.evs.supports(c)

        self.expected_ids = set(['777', '888'])
 def test_cache_refresh_after_triple_remove(self):
     o = self.ctx.DataObject(ident=R.URIRef("http://example.org/a"))
     DataObject.DatatypeProperty("boots", o)
     o.boots()
     c1 = o.po_cache
     self.assertIsNotNone(c1)
     # XXX: Note that it doesn't matter if the triple was
     # actually in the graph
     self.config['rdf.graph'].remove(
         (R.URIRef('/not/in'), R.URIRef('/the'), R.URIRef('/graph')))
     o.boots()
     self.assertIsNot(c1, o.po_cache)
Example #23
0
    def test_asserts_query_multiple_author_matches(self):
        """ Show that setting the evidence with distinct objects yields
        distinct results even if there are matching values """
        e = Evidence(key="k", author='*****@*****.**')
        r = DataObject(key="a_statement")
        e.asserts(r)
        e.save()

        e1 = Evidence(key="j", author='*****@*****.**')
        e1.asserts(r)
        e1.save()

        e0 = Evidence()
        e0.asserts(r)
        self.assertEqual(2, len(list(e0.load())))
Example #24
0
    def test_evidence_retrieves_instead_of_overwrites(self):
        """
        Test that creating a new Evidence with the same attributes of an
        already-saved Evidence does not overwrite the previous Evidence,
        but instead retrieves it.
        """
        e = Evidence(key="NBK",
                     author='Rodney Dangerfield',
                     title="Natural Born Killers")
        r = DataObject(key='Dangerfields_dramatic_range')
        e.asserts(r)
        e.save()

        e1 = Evidence(author='Rodney Dangerfield')
        facts = list(e1.asserts())
        self.assertIn(r, facts)
Example #25
0
 def __init__(self, x=False):
     DataObject.__init__(self)
     DatatypeProperty('flexo', owner=self)
     if x:
         self.flexo(x)
Example #26
0
 def test_rdfs_comment_property(self):
     a = DataObject(rdfs_comment='Hello')
     self.assertIn('Hello', a.rdfs_comment())
Example #27
0
 def assertEvidences(self, prop):
     self.e1.reference(DataObject(ident='777'))
     self.e2.reference(DataObject(ident='888'))
     self.save()
     loaded_ids = set(str(x.identifier) for x in self.evs.reference.get())
     self.assertTrue(self.expected_ids.issubset(loaded_ids))
Example #28
0
 def test_context_getter(self):
     a = DataObject()
     self.assertIsNone(a.context)
Example #29
0
 def test_repr(self):
     self.assertRegexpMatches(
         repr(DataObject(ident="http://example.com")),
         r"DataObject\(ident=rdflib\.term\.URIRef\("
         r"u?[\"']http://example.com[\"']\)\)")
 def test_same_value_same_id_empty(self):
     do = self.ctx.DataObject(ident=R.URIRef("http://example.org"))
     do1 = self.ctx.DataObject(ident=R.URIRef("http://example.org"))
     c = DataObject.DatatypeProperty("boots", do)
     c1 = DataObject.DatatypeProperty("boots", do1)
     self.assertEqual(c.identifier, c1.identifier)
Example #31
0
 def test_open_set(self):
     print (DataObject.openSet())
     values('exo-skeleton')
     values(', ex=')
     print (DataObject.openSet())
Example #32
0
 def test_identifier(self):
     """ Test that we can set and return an identifier """
     do = DataObject(ident="http://example.org")
     self.assertEqual(do.identifier, R.URIRef("http://example.org"))
Example #33
0
 def test_DataUser(self):
     do = DataObject()
     self.assertTrue(isinstance(do, DataUser))
Example #34
0
 def test_context_setter(self):
     a = DataObject()
     a.context = 42
     self.assertEquals(a.context, 42)
Example #35
0
 def test_object_from_id_type_0(self):
     g = DataObject.object_from_id('http://openworm.org/entities/Neuron')
     self.assertIsInstance(g, Neuron)
Example #36
0
 def test_object_from_id_type_1(self):
     g = DataObject.object_from_id('http://openworm.org/entities/Connection')
     self.assertIsInstance(g, Connection)
Example #37
0
 def test_rdfs_comment_property(self):
     a = DataObject(rdfs_comment='Hello')
     self.assertIn('Hello', a.rdfs_comment())
Example #38
0
 def __eq__(self,other):
     return DataObject.__eq__(self,other) or (isinstance(other,Cell) and set(self.name()) == set(other.name()))
Example #39
0
 def test_context_setter(self):
     a = DataObject()
     a.context = 42
     self.assertEquals(a.context, 42)