def test_create_instances(self): self.assertEquals(TEST_REDIS.hget('bf:Instance:1', 'instanceOf'), 'bf:SoftwareOrMultimedia:1') self.assertEquals(TEST_REDIS.hget('bf:Instance:2', 'instanceOf'), 'bf:SoftwareOrMultimedia:1')
def test_multiple_creators(self): self.ingester.ingest(os.path.join(PROJECT_HOME, 'bibframe', 'fixures', 'pg', 'pg1682.rdf')) self.assertEquals(TEST_REDIS.hget('bf:Person:2', 'schema:familyName'), 'Plato') self.assertEquals(TEST_REDIS.hget('bf:Person:3', 'rda:preferredNameForThePerson'), 'Jowett, Benjamin')
def test_extract_title_entity(self): ingester = JSONLinkedDataIngester(redis_datastore=TEST_REDIS) self.assertEquals(ingester.__extract_title_entity__( TEST_WORK.get('bf:title')), 'bf:TitleEntity:1') self.assertEquals(TEST_WORK.get('bf:title').get('bf:titleValue'), TEST_REDIS.hget('bf:TitleEntity:1', 'titleValue'))
def test_schema_givenName(self): self.assertEquals(getattr(self.person_ingester.person,'schema:givenName'), 'Jane') self.assertEquals(getattr(self.person_ingester.person, 'schema:givenName'), TEST_REDIS.hget(self.person_ingester.person.redis_key, 'schema:givenName'))
def test_extract_creator(self): self.assertEquals(TEST_REDIS.hget('bf:Person:1', 'rda:dateOfBirth'), '1804') self.assertEquals(TEST_REDIS.hget('bf:Person:1', 'rda:dateOfDeath'), '1864') self.assertEquals(TEST_REDIS.hget('bf:Person:1', 'rda:preferredNameForThePerson'), "Hawthorne, Nathaniel") self.assertEquals(TEST_REDIS.hget('bf:Person:1', 'schema:givenName'), "Nathaniel") self.assertEquals(TEST_REDIS.hget('bf:Person:1', 'schema:familyName'), "Hawthorne")
def test_extract_stock_number(self): self.assertEquals(getattr(self.instance_ingester.instance, 'stock-number'), ['240-951/147']) self.assertEquals(getattr(self.instance_ingester.instance,'stock-number'), [TEST_REDIS.hget(self.instance_ingester.instance.redis_key, "stock-number")])
def test_association_work_creator(self): self.assertEquals(TEST_REDIS.hget('bf:SoftwareOrMultimedia:1', 'rda:isCreatedBy'), 'bf:Person:1') self.assertEquals(TEST_REDIS.smembers( 'bf:SoftwareOrMultimedia:1:hasInstance'), set(['bf:Instance:1', 'bf:Instance:2']))
def test_dod(self): self.assertEquals(getattr(self.person_ingester.person, 'rda:dateOfDeath'), '1817') self.assertEquals(getattr(self.person_ingester.person, 'rda:dateOfDeath'), TEST_REDIS.hget(self.person_ingester.person.redis_key, 'rda:dateOfDeath'))
def test_dob(self): self.assertEquals(getattr(self.person_ingester.person, 'rda:dateOfBirth'), '1775') self.assertEquals(getattr(self.person_ingester.person, 'rda:dateOfBirth'), TEST_REDIS.hget(self.person_ingester.person.redis_key, 'rda:dateOfBirth'))
def test_extract_authority_lcsh(self): ingester = JSONLinkedDataIngester(redis_datastore=TEST_REDIS) authority_key = ingester.__extract_authority_lcsh__( 'http://id.loc.gov/authorities/names/no2008011986') self.assertEquals(authority_key, 'bf:Organization:1') self.assertEquals(TEST_REDIS.hget(authority_key, 'label'), 'Library of Congress. Working Group on the Future of Bibliographic Control')
def test_ingest(self): ingester = JSONLinkedDataIngester(redis_datastore=TEST_REDIS) ingester.linked_data = TEST_WORK self.assert_(not TEST_REDIS.exists('bf:Manuscript:1')) ingester.__ingest__() self.assert_(TEST_REDIS.exists('bf:Manuscript:1')) self.assertEquals( TEST_REDIS.hget("bf:Manuscript:1", 'rda:dateOfPublicationManifestation'), '1986') self.assertEquals( TEST_REDIS.hget('bf:Manuscript:1', 'hasInstance'), 'bf:Instance:1') self.assertEquals( TEST_REDIS.hget('bf:Manuscript:1', 'subject'), 'bf:Topic:1')
def test_extract_instances(self): ingester = JSONLinkedDataIngester(redis_datastore=TEST_REDIS) instances = [{'@type': 'bf:Instance', 'rda:carrierTypeManifestation': 'online resource', 'schema:contentUrl': '/pdf/Harrington_mf5_r6.pdf'}, {'@type': 'bf:Instance', 'rda:carrierTypeManifestation': 'microfilm'}] ingester.__extract_instances__(instances) self.assertEquals( TEST_REDIS.hget('bf:Instance:1', 'rda:carrierTypeManifestation'), 'online resource') self.assertEquals( TEST_REDIS.hget('bf:Instance:1', 'schema:contentUrl'), '/pdf/Harrington_mf5_r6.pdf') self.assertEquals( TEST_REDIS.hget('bf:Instance:2', 'rda:carrierTypeManifestation'), 'microfilm')
def test_extract_ismn(self): self.assertEquals(list(self.instance_ingester.instance.ismn)[0], '979-0-2600-0043-8') self.assertEquals(list(self.instance_ingester.instance.ismn)[0], TEST_REDIS.hget(self.instance_ingester.instance.redis_key, 'ismn'))
def test_extract_title(self): title_key = TEST_REDIS.hget('bf:SoftwareOrMultimedia:1', 'title') self.assertEquals(TEST_REDIS.hget(title_key, 'titleValue'), 'The Scarlet Letter')
def test_extract_lc_overseas_acq(self): self.assertEquals(list(getattr(self.instance_ingester.instance,'lc-overseas-acq'))[0], TEST_REDIS.hget(self.instance_ingester.instance.redis_key, 'lc-overseas-acq'))
def test_titleDate(self): self.assertEquals(TEST_REDIS.hget(self.new_title.redis_key, 'titleDate'), '1813')
def test_preferred_name(self): self.assertEquals(self.person_ingester.person.feature('rda:preferredNameForThePerson'), 'Austen, Jane') self.assertEquals(self.person_ingester.person.feature('rda:preferredNameForThePerson'), TEST_REDIS.hget(self.person_ingester.person.redis_key, 'rda:preferredNameForThePerson'))
def test_music_plate(self): self.assertEquals(list(getattr(self.instance_ingester.instance,'music-plate'))[0], 'B. & H. 8797') self.assertEquals(TEST_REDIS.hget(self.instance_ingester.instance.redis_key, 'music-plate'), 'B. & H. 8797')
def test_titleValue(self): self.assertEquals(TEST_REDIS.hget(self.new_title.redis_key, 'titleValue'), 'Pride and Prejudice')
def test_local(self): self.assertEquals(list(self.instance_ingester.instance.local)[0], 'b45647') self.assertEquals(list(self.instance_ingester.instance.local)[0], TEST_REDIS.hget(self.instance_ingester.instance.redis_key, "local"))