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_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_duplicate_cc_marc21(self):
     # Default in test for Colorado College specific ingestor
     record = pymarc.Record()
     record.add_field(pymarc.Field(tag='907',
                                   indicators=[' ',' '],
                                   subfields=['a', '.b12345x']))
     TEST_REDIS.hset('ils-bib-numbers', 'b12345', 'bf:Work:1')
     ingester = MARC21toBIBFRAME(redis_datastore=TEST_REDIS,
                                 record=record)
     self.assert_(ingester.__duplicate_check__('ils-bib-numbers') is True)
 def test_duplicate_alliance_marc21(self):
     # Default in test record for the ingestor
     new_record = pymarc.Record()
     new_record.add_field(pymarc.Field(tag='945',
                                       indicators=[' ',' '],
                                       subfields=['a', 'test_a b12345']))
     TEST_REDIS.hset('ils-bib-numbers', 'b12345', 'bf:Work:1')
     ingester = MARC21toBIBFRAME(redis_datastore=TEST_REDIS,
                                 record=new_record)
     self.assert_(ingester.__duplicate_check__('ils-bib-numbers') is True)
 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')
예제 #6
0
 def setUp(self):
     self.title_entity = TitleEntity(redis_datastore = TEST_REDIS,
                                     label='Pride and Prejudice',
                                     titleValue='Pride and Prejudice')
     self.title_entity.save()
     index_title(self.title_entity, TEST_REDIS)
     self.work = Book(redis_datastore=TEST_REDIS,
                      associatedAgent=set(["bf:Person:1"]),
                      title=self.title_entity.redis_key)
     setattr(self.work, 'rda:isCreatedBy', 'bf:Person:1')
     self.work.save()
     TEST_REDIS.sadd(
         "{0}:relatedResources".format(self.title_entity.redis_key),
         self.work.redis_key)
 def test_extract_coden(self):
     self.assertEquals(self.instance_ingester.instance.coden[0],
                       'ASIRAF')
     self.assertEquals(self.instance_ingester.instance.coden[1],
                       'ASITAF')
     self.assert_(TEST_REDIS.sismember('identifiers:coden:invalid',
                                       self.instance_ingester.instance.coden[1]))
 def test_extract_performerNote(self):
     self.assertEquals(list(self.work_ingester.creative_work.performerNote)[1],
                       'Cast: Cutter, Charles')
     self.assertEquals(list(self.work_ingester.creative_work.performerNote)[0],
                       'Cast: Pareto, Vilfredo')
     self.assertEquals(self.work_ingester.creative_work.performerNote,
                       TEST_REDIS.smembers('{0}:performerNote'.format(self.work_ingester.creative_work.redis_key)))
 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'))
예제 #10
0
 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_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_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_topics(self):
     wichita_indians_topic = models.Topic(redis_datastore=TEST_REDIS,
                                          label='Wichita Indians')
     wichita_indians_topic.save()
     TEST_REDIS.hset('lcsh-hash',
                     'http://id.loc.gov/authorities/subjects/sh85028785',
                     wichita_indians_topic.redis_key)
     ingester = JSONLinkedDataIngester(redis_datastore=TEST_REDIS)
     topics = [
         {'bf:identifier': 'http://id.loc.gov/authorities/subjects/sh85018617',
          'bf:label': u'Caddo Indians' },
         {'bf:identifier': 'http://id.loc.gov/authorities/subjects/sh85146582',
          'bf:label': u'Wichita Indians'},
         {'bf:identifier': 'http://id.loc.gov/authorities/subjects/sh85028785',
          'bf:label':  u'Comanche Indians'}]
     self.assertEquals(ingester.__extract_topics__(topics),
                       ['bf:Topic:2', 'bf:Topic:3', 'bf:Topic:1'])
예제 #14
0
 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'))
예제 #15
0
 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')
예제 #19
0
 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'))
예제 #20
0
 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"))
 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')
예제 #22
0
 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')
예제 #23
0
 def test_titleDate(self):
     self.assertEquals(TEST_REDIS.hget(self.new_title.redis_key,
                                       'titleDate'),
                       '1813')
예제 #24
0
 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'))
예제 #25
0
 def test_iso(self):
     self.assertEquals(self.instance_ingester.instance.iso[0],
                       '19200 Baud')
     self.assert_(TEST_REDIS.sismember('identifiers:iso:invalid',
                                       '2400 Baud'))
예제 #26
0
 def test_extract_supplementaryContentNote(self):
     self.assertEquals(self.instance_ingester.instance.supplementaryContentNote,
                       ['Literature cited: p. 67-68. References: 19'])
     self.assertEquals(list(TEST_REDIS.smembers('{0}:supplementaryContentNote'.format(self.instance_ingester.instance.redis_key)))[1],
                       'Has numerous supplements')
 def tearDown(self):
     TEST_REDIS.flushdb()
예제 #28
0
 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'))
예제 #29
0
 def test_titleValue(self):
     self.assertEquals(TEST_REDIS.hget(self.new_title.redis_key,
                                       'titleValue'),
                       'Pride and Prejudice')
예제 #30
0
 def test_isrc(self):
     self.assertEquals(self.instance_ingester.instance.isrc[0],
                       'NLC018413261')
     self.assert_(TEST_REDIS.sismember("identifiers:isrc:invalid",
                                       "NLC018403261"))