def test_unique_two_delete_not_found(self): # Delete the zip code from an existing address that doesn't have a zip code. p = Pump("data/org_def.json") p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n765319', u'zip': u'None'}} [add, sub] = p.update() self.assertTrue(len(add) == 0 and len(sub) == 0)
def test_multiple_one_change_nothing(self): # Do nothing if the multiple values specified match those in VIVO p = Pump("data/person_def.json", verbose=True) p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n1723097935', u'types': u'person;thing;agent;fac;uf;ufc'}} [add, sub] = p.update() self.assertTrue(len(add) == 0 and len(sub) == 0)
def test_unique_one_delete(self): from rdflib import URIRef, Literal, XSD p = Pump() p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n111669', u'abbreviation': u'None'}} [add, sub] = p.update() self.assertTrue( len(add) == 0 and len(sub) == 1 and (URIRef("http://vivo.ufl.edu/individual/n111669"), URIRef("http://vivoweb.org/ontology/core#abbreviation"), Literal("JWRU", datatype=XSD.string)) in sub)
def test_unique_one_add(self): from rdflib import URIRef, Literal p = Pump() p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n1001011525', u'abbreviation': u'PH9'}} [add, sub] = p.update() self.assertTrue( len(add) == 1 and len(sub) == 0 and (URIRef("http://vivo.ufl.edu/individual/n1001011525"), URIRef("http://vivoweb.org/ontology/core#abbreviation"), Literal("PH9")) in add)
def test_without_lang(self): from rdflib import URIRef, Literal p = Pump("data/org_def.json", verbose=True) p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n928712', u'name': u'Ad ver tising'}} [add, sub] = p.update() self.assertTrue( len(add) == 1 and len(sub) == 1 and (URIRef("http://vivo.ufl.edu/individual/n928712"), URIRef("http://www.w3.org/2000/01/rdf-schema#label"), Literal("Ad ver tising")) in add)
def test_without_datatype(self): from rdflib import URIRef, Literal p = Pump("data/building_def.json", verbose=True) p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n1001011525', u'url': u'http://a'}} [add, sub] = p.update() self.assertTrue( len(add) == 4 and len(sub) == 0 and (None, URIRef("http://vivoweb.org/ontology/core#linkURI"), Literal("http://a")) in add)
def test_with_lang(self): from rdflib import URIRef, Literal p = Pump("data/building_def.json", verbose=True) p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n1001011525', u'name': u'Building 42'}} [add, sub] = p.update() self.assertTrue( len(add) == 1 and len(sub) == 1 and (URIRef("http://vivo.ufl.edu/individual/n1001011525"), URIRef("http://www.w3.org/2000/01/rdf-schema#label"), Literal("Building 42", lang="en-US")) in add)
def test_with_datatype(self): from rdflib import URIRef, Literal, XSD p = Pump("data/building_def.json", verbose=True) p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n1001011525', u'abbreviation': u'PH9'}} [add, sub] = p.update() self.assertTrue( len(add) == 1 and len(sub) == 0 and (URIRef("http://vivo.ufl.edu/individual/n1001011525"), URIRef("http://vivoweb.org/ontology/core#abbreviation"), Literal("PH9", datatype=XSD.string)) in add)
def test_multiple_one_delete(self): # Empty the set of values p = Pump("data/person_def.json", verbose=True) p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n25674', u'research_areas': u'None'}} [add, sub] = p.update() self.assertTrue(len(add) == 0 and len(sub) == 4)
def test_inject_empty_original_graph(self): from rdflib import Graph, URIRef p = Pump(verbose=True) p.original_graph = Graph() p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n8984374104', u'abbreviation': u'None'}} [add, sub] = p.update() self.assertTrue( len(add) == 1 and len(sub) == 0 and (None, URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), URIRef("http://vivoweb.org/ontology/core#Building")) in add)
def test_unique_two_delete(self): from rdflib import URIRef, Literal, XSD # Delete the zip code on an existing address p = Pump("data/org_def.json") p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n87597', u'zip': u'None'}} [add, sub] = p.update() self.assertTrue( len(add) == 0 and len(sub) == 1 and (URIRef("http://vivo.ufl.edu/individual/n994294"), URIRef("http://vivoweb.org/ontology/core#addressPostalCode"), Literal("32611", datatype=XSD.string)) in sub)
def test_unique_three_add_partial_path(self): from rdflib import URIRef, Literal p = Pump("data/grant_def.json", verbose=True) # WARNING. This test passes by constructing a new datetime interval. Not clear if this is the desired result. p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n42774', u'start_date': u'2006-03-01'}} [add, sub] = p.update() self.assertTrue( len(add) == 5 and len(sub) == 0 and (None, URIRef("http://vivoweb.org/ontology/core#dateTime"), Literal("2006-03-01")) in add)
def test_unique_three_add_fullpath(self): from rdflib import URIRef, Literal p = Pump("data/grant_def.json") # Add a start date to a grant. There is no date time interval, so a full path will need to be created p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n51914', u'start_date': u'2015-03-01'}} [add, sub] = p.update() self.assertTrue( len(add) == 5 and len(sub) == 0 and (None, URIRef("http://vivoweb.org/ontology/core#dateTime"), Literal("2015-03-01")) in add)
def test_unique_two_add_to_existing(self): from rdflib import URIRef, Literal # Add a zip code to the provost's office at UF. An address already exists, the zip needs to be # added to the existing address p = Pump("data/org_def.json") p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n765319', u'zip': u'32653'}} [add, sub] = p.update() self.assertTrue( len(add) == 1 and len(sub) == 0 and (URIRef("http://vivo.ufl.edu/individual/n119803"), URIRef("http://vivoweb.org/ontology/core#addressPostalCode"), Literal("32653")) in add)
def test_unique_two_add_fullpath(self): from rdflib import URIRef, Literal p = Pump("data/org_def.json") # Add a zip code to Lee County Extension Office. There is no address, so a full path will need # to be created p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n7023301', u'zip': u'32653'}} [add, sub] = p.update() self.assertTrue( len(add) == 4 and len(sub) == 0 and (None, URIRef("http://vivoweb.org/ontology/core#addressPostalCode"), Literal("32653")) in add)
def test_unique_three_delete(self): from rdflib import URIRef, Literal, XSD # WARNING: Delete start date value from existing datetime interval. This may not be the desirable data # management action p = Pump("data/grant_def.json", verbose=True) p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n650082272', u'start_date': u'None'}} [add, sub] = p.update() self.assertTrue( len(add) == 0 and len(sub) == 1 and (None, URIRef("http://vivoweb.org/ontology/core#dateTime"), Literal("2006-07-01T00:00:00", datatype=XSD.dateTime)) in sub)
def test_multiple_one_change(self): from rdflib import URIRef # Change the set of values adding one and removing another p = Pump("data/person_def.json", verbose=True) p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n1723097935', u'types': u'person;thing;agent;fac;uf;pd'}} [add, sub] = p.update() self.assertTrue(len(add) == 1 and len(sub) == 1 and (URIRef("http://vivo.ufl.edu/individual/n1723097935"), URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), URIRef("http://vivoweb.org/ontology/core#Postdoc")) in add and (URIRef("http://vivo.ufl.edu/individual/n1723097935"), URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), URIRef("http://vivo.ufl.edu/ontology/vivo-ufl/UFCurrentEntity")) in sub)
def test_multiple_one_add(self): from rdflib import URIRef # Add multiple values for an attribute to an entity that has no values for the attribute p = Pump("data/person_def.json", verbose=True) p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n1723097935', u'research_areas': u'http://vivo.ufl.edu/individual/n2551317090;http://vivo.ufl.edu/individual/n157098'}} [add, sub] = p.update() self.assertTrue( len(add) == 2 and len(sub) == 0 and (URIRef("http://vivo.ufl.edu/individual/n1723097935"), URIRef("http://vivoweb.org/ontology/core#hasResearchArea"), URIRef("http://vivo.ufl.edu/individual/n2551317090")) in add and (URIRef("http://vivo.ufl.edu/individual/n1723097935"), URIRef("http://vivoweb.org/ontology/core#hasResearchArea"), URIRef("http://vivo.ufl.edu/individual/n157098")) in add)
def test_unique_three_change_xsd(self): from rdflib import URIRef, Literal, XSD p = Pump("data/grant_def.json", verbose=True) # WARNING. This test passes by changing the start date value on an existing datetime interval. Not sure # if this is the desired behavior. p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n650082272', u'start_date': u'2006-03-02'}} [add, sub] = p.update() self.assertTrue( len(add) == 1 and len(sub) == 1 and (None, URIRef("http://vivoweb.org/ontology/core#dateTime"), Literal("2006-03-02")) in add and (None, URIRef("http://vivoweb.org/ontology/core#dateTime"), Literal("2006-07-01T00:00:00", datatype=XSD.dateTime)) in sub)
def test_small_case(self): p = Pump("data/person_def.json", verbose=True) p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n2084211328', u'remove': u'True'}} [add, sub] = p.update() self.assertTrue(len(add) == 0 and len(sub) == 1)
def test_missing_uri_column_inject(self): p = Pump() p.update_data = {1: {u'overview': u'None'}} with self.assertRaises(KeyError): p.update()
def test_not_found(self): p = Pump("data/person_def.json", verbose=True) p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n12345678', u'remove': u'True'}} [add, sub] = p.update() self.assertTrue(len(add) == 0 and len(sub) == 0)
def test_normal_inject(self): p = Pump() p.update_data = {1: {u'uri': u'http://vivo.ufl.edu/individual/n8984374104', u'abbreviation': u'None'}} p.update() self.assertTrue("8984374104" in str(p.update_data)) # Using the injected data, not default