Beispiel #1
0
 def test_object_from_id(self):
     print(RDFTypeTable)
     g = DataObject.object_from_id('http://openworm.org/entities/Neuron')
     self.assertIsInstance(g, Neuron)
     g = DataObject.object_from_id(
         'http://openworm.org/entities/Connection')
     self.assertIsInstance(g, Connection)
Beispiel #2
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)
Beispiel #3
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)
Beispiel #4
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)
Beispiel #5
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)
Beispiel #6
0
    def __init__(self, triples=None, graph=None, **kwargs):
        DataObject.__init__(self, **kwargs)
        if triples is None:
            triples = []

        if graph is not None:
            self._triples = graph
        else:
            self._triples = triples
Beispiel #7
0
    def __init__(self,triples=None,graph=None,**kwargs):
        DataObject.__init__(self,**kwargs)
        if triples is None:
            triples = []

        if graph is not None:
            self._triples = graph
        else:
            self._triples = triples
Beispiel #8
0
 def test_same_value_same_id_empty(self):
     """
     Test that two SimpleProperty objects with the same name have the same identifier()
     """
     do = DataObject(ident=R.URIRef("http://example.org"))
     do1 = DataObject(ident=R.URIRef("http://example.org"))
     c = DataObject.DatatypeProperty("boots", do)
     c1 = DataObject.DatatypeProperty("boots", do1)
     self.assertEqual(c.identifier(), c1.identifier())
Beispiel #9
0
 def test_diff_value_diff_id_not_equal(self):
     """
     Test that two SimpleProperty with the same name have the same identifier()
     """
     do = DataObject(ident=R.URIRef("http://example.org"))
     do1 = DataObject(ident=R.URIRef("http://example.org"))
     c = DataObject.DatatypeProperty("boots", do)
     c1 = DataObject.DatatypeProperty("boots", do1)
     do.boots('join')
     do1.boots('partition')
     self.assertNotEqual(c.identifier(), c1.identifier())
Beispiel #10
0
 def test_diff_prop_same_name_same_object_same_value_same_id(self):
     """
     Test that two SimpleProperty with the same name have the same identifier
     """
     # why would you ever do this?
     do = DataObject(ident=R.URIRef("http://example.org"))
     c = DataObject.DatatypeProperty("boots", do)
     c1 = DataObject.DatatypeProperty("boots", do)
     c('join')
     c1('join')
     self.assertEqual(c.identifier(), c1.identifier())
Beispiel #11
0
 def test_diff_prop_same_name_same_object_diff_value_diff_id(self):
     """
     Test that two SimpleProperty with the same name, but different values
     have distinct identifiers
     """
     # why would you ever do this?
     do = DataObject(ident=R.URIRef("http://example.org"))
     c = DataObject.DatatypeProperty("boots", do)
     c1 = DataObject.DatatypeProperty("boots", do)
     c('partition')
     c1('join')
     self.assertNotEqual(c.identifier(), c1.identifier())
Beispiel #12
0
    def test_triples_with_no_value(self):
        """ Test that when there is no value set for a property, it still yields triples """
        do = DataObject(ident=R.URIRef("http://example.org"))

        class T(SimpleProperty):
            property_type = 'DatatypeProperty'
            linkName = 'test'
            owner_type = DataObject

        sp = DataObject.attach_property(do, T)
        self.assertEqual(len(list(sp.triples())), 0)
        self.assertEqual(len(list(sp.triples(query=True))), 0)
Beispiel #13
0
    def identifier(self, *args, **kwargs):
        ident = DataObject.identifier(self, *args, **kwargs)
        if 'query' in kwargs and kwargs['query'] == True:
            if not DataObject._is_variable(ident):
                return ident
        owners = self.getOwners(P.Worm().neuron_network.link)
        data = []
        for x in owners:
            ident = x.identifier(query=True) # XXX: Query is set to true so a fixed identifier isn't generated randomly
            if not DataObject._is_variable(ident):
                data.append(ident)
        data = sorted(data)

        return self.make_identifier(data)
Beispiel #14
0
    def test_diff_value_insert_order_same_id(self):
        """
        Test that two SimpleProperty with the same name have the same identifier()
        """
        do = DataObject(ident=R.URIRef("http://example.org"))
        do1 = DataObject(ident=R.URIRef("http://example.org"))

        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())
Beispiel #15
0
    def test_object_property_diff_value_insert_order_same_id(self):
        """
        Test that two SimpleProperty with the same name have the same identifier()
        """
        do = DataObject(ident=R.URIRef("http://example.org"))
        do1 = DataObject(ident=R.URIRef("http://example.org"))

        oa = DataObject(ident=R.URIRef("http://example.org/a"))
        ob = DataObject(ident=R.URIRef("http://example.org/b"))
        oc = 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())
Beispiel #16
0
 def test_object_from_id(self):
     print(RDFTypeTable)
     g = DataObject.object_from_id('http://openworm.org/entities/Neuron')
     self.assertIsInstance(g, Neuron)
     g = DataObject.object_from_id('http://openworm.org/entities/Connection')
     self.assertIsInstance(g, Connection)
Beispiel #17
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"))
Beispiel #18
0
 def test_same_value_same_id_not_empty_object_property(self):
     """
     Test that two SimpleProperty with the same name have the same identifier()
     """
     do = DataObject(ident=R.URIRef("http://example.org"))
     do1 = DataObject(ident=R.URIRef("http://example.org"))
     dz = DataObject(ident=R.URIRef("http://example.org/vip"))
     dz1 = 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())
Beispiel #19
0
 def test_DataUser(self):
     do = DataObject()
     self.assertTrue(isinstance(do, PyOpenWorm.DataUser))
Beispiel #20
0
 def __init__(self, name, conf=False):
     DataObject.__init__(self,conf=conf)
     self._name = name
Beispiel #21
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"))
Beispiel #22
0
    def __init__(self, **kwargs):
        DataObject.__init__(self,**kwargs)

        self.synapses = Network.ObjectProperty('synapse', owner=self, value_type=P.Connection, multiple=True)
        Network.ObjectProperty('neuron',owner=self,value_type=P.Neuron, multiple=True)
Beispiel #23
0
 def __init__(self, conf=False):
     DataObject.__init__(self,conf=conf)
Beispiel #24
0
    def __init__(self, data=False, *args, **kwargs):
        DataObject.__init__(self, **kwargs)
        Plot.DatatypeProperty('_data_string', self, multiple=False)

        if data:
            self.set_data(data)
Beispiel #25
0
 def __init__(self, name, conf=False):
     DataObject.__init__(self, conf=conf)
     self._name = name
Beispiel #26
0
 def test_repr(self):
     self.assertRegexpMatches(
         repr(DataObject(ident="http://example.com")),
         r"DataObject\(ident=rdflib\.term\.URIRef\("
         r"u?[\"']http://example.com[\"']\)\)")