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_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_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)
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_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))
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)
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)
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_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 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_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())))
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)
def test_context_setter(self): a = DataObject() a.context = 42 self.assertEquals(a.context, 42)
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_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"))
def test_context_getter(self): a = DataObject() self.assertIsNone(a.context)
def test_rdfs_comment_property(self): a = DataObject(rdfs_comment='Hello') self.assertIn('Hello', a.rdfs_comment())
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))
def test_DataUser(self): do = DataObject() self.assertTrue(isinstance(do, DataUser))