Esempio n. 1
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")
Esempio n. 2
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))
Esempio n. 3
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))
Esempio n. 4
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")
Esempio n. 5
0
    def test_evidence_asserts_all_about(self):
        """ Test that we can assert_all_about a containing object and
        then get evidence for contained objects.
        """
        import random
        random.seed()
        v = values('all')

        def make_syn():
            import struct
            u = struct.pack("=2f", random.random(), random.random())
            z = struct.pack("=2f", random.random(), random.random())
            a = Neuron(u.encode('hex'))
            b = Neuron(z.encode('hex'))
            v.value(a.neighbor(b))
            return (a, b)

        for x in range(200):
            make_syn()

        # the one we'll check for
        a, b = make_syn()
        ev = Evidence(author="Homer")
        ev.asserts_all_about(ev)
        ev.save()
        eve = Evidence()
        eve.asserts(a.neighbor(b))
Esempio n. 6
0
    def test_evidence_asserts_all_about(self):
        """ Test that we can assert_all_about a containing object and
        then get evidence for contained objects.
        """
        import random
        random.seed()
        v = values('all')

        def make_syn():
            import struct
            u = struct.pack("=2f", random.random(), random.random())
            z = struct.pack("=2f", random.random(), random.random())
            a = Neuron(u.encode('hex'))
            b = Neuron(z.encode('hex'))
            v.value(a.neighbor(b))
            return (a, b)

        for x in range(200):
            make_syn()

        # the one we'll check for
        a, b = make_syn()
        ev = Evidence(author="Homer")
        ev.asserts_all_about(ev)
        ev.save()
        eve = Evidence()
        eve.asserts(a.neighbor(b))
Esempio n. 7
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)
Esempio n. 8
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)
Esempio n. 9
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)
Esempio n. 10
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)
Esempio n. 11
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)
Esempio n. 12
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())))
Esempio n. 13
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())))
Esempio n. 14
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)
Esempio n. 15
0
    def test_2(self):
        # Reference two neurons
        n1 = Neuron(name='AVAL')
        n2 = Neuron(name='PVCR')

        # Declare a connection between them
        c = Connection(n1, n2, number=1)
        c_id = c.identifier
        # Attach some evidence for the connection
        e = Evidence(author="Danny Glover")
        e.asserts(c)
        # look at what else this evidence has stated
        e.save()
        e = Evidence(author="Danny Glover")
        r = e.asserts()
        ids = set(x.identifier for x in r)
        self.assertIn(c_id, ids)
Esempio n. 16
0
    def test_2(self):
        # Reference two neurons
        n1 = Neuron(name='AVAL')
        n2 = Neuron(name='PVCR')

        # Declare a connection between them
        c = Connection(n1, n2, number=1)
        c_id = c.identifier
        # Attach some evidence for the connection
        e = Evidence(author="Danny Glover")
        e.asserts(c)
        # look at what else this evidence has stated
        e.save()
        e = Evidence(author="Danny Glover")
        r = e.asserts()
        ids = set(x.identifier for x in r)
        self.assertIn(c_id, ids)