コード例 #1
0
        def test_rabbit_add_inspireID():
            '''
            An inspire id is added to to an author artificially. Then, a record is uploaded with a
            heavily modifield name of the person + the same inspire ID. Despite the fact that the name
            is totally different, due to the fact that there is an inspire ID in place,
            the entry shall not change.
            '''
            self.main_marcxml_record = get_modified_marc_for_test(
                self.main_marcxml_record, author_name=self.author_name)
            self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                                     opt_mode='replace')
            rabbit([self.main_bibrec], verbose=True)
            personid_to_test = get_authors_by_name(self.author_name)[0]

            #PERSONID_EXTERNAL_IDENTIFIER_MAP.values() TODO
            add_external_id_to_author(personid_to_test, 'INSPIREID',
                                      self.ext_id)

            self.main_marcxml_record = get_modified_marc_for_test(
                self.main_marcxml_record,
                author_name=self.heavily_modified_name,
                ext_id=self.ext_id)
            self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                                     opt_mode='replace')
            rabbit([self.main_bibrec], verbose=True)
            self.assertEquals(
                personid_to_test,
                get_authors_by_name(self.heavily_modified_name)[0])

            _remove_external_id_from_author(personid_to_test, 'INSPIREID',
                                            self.ext_id)
コード例 #2
0
        def test_rabbit_claim_record():
            '''
            The test record is artificially being claimed. Then, the name of the author is being modified:
                i) slightly
                A slight modification of a claimed record should have the same behavior as before:
                    Name changes in aidPERSONIDPAPERS but not in aidPERSONIDDATA.
                ii) heavily
                Due to the fact that the paper is claimed the canonical name should NOT change in aidPERSONIDDATA.
            '''
            number_of_personids_before = get_count_of_pids()
            self.main_marcxml_record = get_modified_marc_for_test(
                self.main_marcxml_record, author_name=self.author_name)
            self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                                     opt_mode='replace')
            rabbit([self.main_bibrec], verbose=True)

            claim_test_paper(self.main_bibrec)

            self.main_marcxml_record = get_modified_marc_for_test(
                self.main_marcxml_record,
                author_name=self.slightly_modified_author_name)
            self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                                     opt_mode='replace')
            rabbit([self.main_bibrec], verbose=True)

            number_of_personids_after = get_count_of_pids()
            self.assertEquals(number_of_personids_before,
                              number_of_personids_after)
            self.assertTrue(
                person_in_aidpersonidpapers(self.slightly_modified_author_name,
                                            self.main_bibrec))
            self.assertFalse(
                person_in_aidpersonidpapers(self.author_name,
                                            self.main_bibrec))
            self.assertTrue(is_test_paper_claimed(self.main_bibrec, 100))

            self.main_marcxml_record = get_modified_marc_for_test(
                self.main_marcxml_record,
                author_name=self.heavily_modified_name)
            self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                                     opt_mode='replace')
            rabbit([self.main_bibrec], verbose=True)

            self.assertTrue(
                person_in_aidpersonidpapers(self.heavily_modified_name,
                                            self.main_bibrec))
            self.assertFalse(
                person_in_aidpersonidpapers(self.slightly_modified_author_name,
                                            self.main_bibrec))
            self.assertFalse(is_test_paper_claimed(self.main_bibrec, 100))
コード例 #3
0
        def test_rabbit_claim_record():
            self.main_marcxml_record = get_modified_marc_for_test(
                self.main_marcxml_record,
                author_name=self.author_name,
                co_authors_names=self.co_authors_names)
            self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                                     opt_mode='replace')
            rabbit([self.main_bibrec], verbose=True)
            claim_test_paper(self.main_bibrec)
            number_of_personids_before = get_count_of_pids()
            self.main_marcxml_record = get_modified_marc_for_test(
                self.main_marcxml_record,
                author_name=self.author_name,
                co_authors_names=self.slightly_mod_co_authors_names)
            self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                                     opt_mode='replace')
            rabbit([self.main_bibrec], verbose=True)
            number_of_personids_after = get_count_of_pids()
            self.assertEquals(number_of_personids_before,
                              number_of_personids_after)
            self.assertTrue(is_test_paper_claimed(self.main_bibrec, 700))
            self.assertTrue(
                person_in_aidpersonidpapers(self.author_name,
                                            self.main_bibrec))
            self.assertTrue(person_in_aidpersoniddata(self.author_name))
            for coauthor_name in self.slightly_mod_co_authors_names:
                self.assertTrue(
                    person_in_aidpersonidpapers(coauthor_name,
                                                self.main_bibrec))
            for coauthor_name in self.co_authors_names:
                self.assertTrue(person_in_aidpersoniddata(coauthor_name))
            self.main_marcxml_record = get_modified_marc_for_test(
                self.main_marcxml_record,
                author_name=self.author_name,
                co_authors_names=self.heavily_mod_co_authors_names)
            self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                                     opt_mode='replace')
            rabbit([self.main_bibrec], verbose=True)

            self.assertTrue(
                person_in_aidpersonidpapers(self.author_name,
                                            self.main_bibrec))
            self.assertTrue(person_in_aidpersoniddata(self.author_name))
            for coauthor_name in self.heavily_mod_co_authors_names:
                self.assertTrue(
                    person_in_aidpersonidpapers(coauthor_name,
                                                self.main_bibrec))
                self.assertTrue(person_in_aidpersoniddata(coauthor_name))
            self.assertFalse(is_test_paper_claimed(self.main_bibrec, 700))
コード例 #4
0
    def test_rabbit_matchable_name(self, mocked_func1, mocked_func2):
        '''
        The return value of the function that creates the matchable name is being mocked.
        With this test we ensure that the function create_matchable_name is actually being used.
        '''
        mocked_func1.return_value = 'Fake Name'
        mocked_func2.return_value = mocked_func1.return_value

        rabbit([self.main_bibrec], verbose=True)

        first_pid = run_sql(
            "select personid from aidPERSONIDPAPERS where bibrec=%s",
            (self.main_bibrec, ))[0][0]

        second_marcxml_record = get_new_marc_for_test(
            'Rabbit Test Paper', author_name=self.heavily_modified_name)
        second_bibrec = get_bibrec_for_record(second_marcxml_record,
                                              opt_mode='insert')
        self.bibrecs_to_clean.append(second_bibrec)

        rabbit([second_bibrec], verbose=True)

        second_pid = run_sql(
            "select personid from aidPERSONIDPAPERS where bibrec=%s",
            (second_bibrec, ))[0][0]
        self.assertEquals(first_pid, second_pid)
コード例 #5
0
 def test_rabbit_heavily_modify_coauthors():
     number_of_personids_before = get_count_of_pids()
     self.main_marcxml_record = get_modified_marc_for_test(
         self.main_marcxml_record,
         author_name=self.author_name,
         co_authors_names=self.heavily_mod_co_authors_names)
     self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                              opt_mode='replace')
     rabbit([self.main_bibrec], verbose=True)
     previous_bibref_value_of_author = self.current_bibref_value_of_author
     previous_bibrefs_of_coauthors = deepcopy(
         self.current_bibref_values_of_coauthors)
     for index, _ in enumerate(self.current_bibref_values_of_coauthors):
         self.current_bibref_values_of_coauthors[
             index] = get_bibref_value_for_name(
                 self.heavily_mod_co_authors_names[index])
     number_of_personids_after = get_count_of_pids()
     self.assertTrue(
         person_in_aidpersonidpapers(self.author_name,
                                     self.main_bibrec))
     self.assertEquals(previous_bibref_value_of_author,
                       self.current_bibref_value_of_author)
     self.assertNotEquals(set(previous_bibrefs_of_coauthors),
                          set(self.current_bibref_values_of_coauthors))
     self.assertEquals(number_of_personids_after,
                       number_of_personids_before)
     self.assertTrue(
         person_in_aidpersonidpapers(self.author_name,
                                     self.main_bibrec))
     self.assertTrue(person_in_aidpersoniddata(self.author_name))
     for coauthor_name in self.heavily_mod_co_authors_names:
         self.assertTrue(
             person_in_aidpersonidpapers(coauthor_name,
                                         self.main_bibrec))
         self.assertTrue(person_in_aidpersoniddata(coauthor_name))
コード例 #6
0
        def test_rabbit_heavily_modify_author():
            '''
            The author's name is modified heavily. This means, that the modified string is significantly
            different than the original.. After the run of rabbit, the name in
            aidPERSONIDDATA SHOULD change, since this is a heavy modification.
            '''
            number_of_personids_before = get_count_of_pids()
            self.main_marcxml_record = get_modified_marc_for_test(
                self.main_marcxml_record,
                author_name=self.heavily_modified_name)
            self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                                     opt_mode='replace')
            rabbit([self.main_bibrec], verbose=True)

            previous_bibref_value = self.current_bibref_value
            self.current_bibref_value = get_bibref_value_for_name(
                self.heavily_modified_name)
            number_of_personids_after = get_count_of_pids()
            self.assertNotEquals(previous_bibref_value,
                                 self.current_bibref_value)
            self.assertTrue(
                person_in_aidpersonidpapers(self.heavily_modified_name,
                                            self.main_bibrec))
            self.assertTrue(
                person_in_aidpersoniddata(self.heavily_modified_name))
            self.assertFalse(person_in_aidpersoniddata(self.author_name))
            self.assertFalse(
                person_in_aidpersonidpapers(self.slightly_modified_author_name,
                                            self.main_bibrec))
            self.assertEquals(number_of_personids_before,
                              number_of_personids_after)
コード例 #7
0
 def setUp(self):
     super(MnamesFunctionsTest, self).setUp()
     main_marcxml_record = get_new_marc_for_test(
         'Rabbit Test Paper', author_name=self.author_name)
     self.main_bibrec = get_bibrec_for_record(main_marcxml_record,
                                              opt_mode='insert')
     self.bibrecs_to_clean = list()
     self.bibrecs_to_clean.append(self.main_bibrec)
コード例 #8
0
 def setUp(self):
     self._pid = get_free_author_id()
     self._orcid = '1234-1234-1234-1234'
     add_orcid_id_to_author(self._pid, self._orcid)
     marc = get_new_marc_for_test('Orcid test paper',
                                  author_name='Author, SomeAuthor',
                                  identifiers=['ORCID:' + self._orcid])
     self._rec = get_bibrec_for_record(marc, opt_mode="insert")
     rabbit([self._rec])
     populate_partial_marc_caches([self._rec])
コード例 #9
0
        def test_rabbit_mark_record_as_deleted():
            number_of_personids_before = get_count_of_pids()
            self.main_marcxml_record = get_modified_marc_for_test(
                self.main_marcxml_record,
                author_name=self.author_name,
                co_authors_names=self.heavily_mod_co_authors_names)
            self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                                     opt_mode='delete')
            rabbit([self.main_bibrec], verbose=True)

            number_of_personids_after = get_count_of_pids()
            self.assertEquals(number_of_personids_before - 5,
                              number_of_personids_after)
コード例 #10
0
 def setUp(self):
     super(CoauthorsRabbitTestCase, self).setUp()
     self.main_marcxml_record = get_new_marc_for_test(
         'Rabbit Test Paper',
         author_name=self.author_name,
         co_authors_names=self.co_authors_names,
         identifiers=None)
     self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                              opt_mode='insert')
     self.main_marcxml_record = add_001_field(self.main_marcxml_record,
                                              self.main_bibrec)
     self.bibrecs_to_clean = list()
     self.bibrecs_to_clean.append(self.main_bibrec)
コード例 #11
0
 def setUp(self):
     super(AuthorRabbitTestCase, self).setUp()
     self.main_marcxml_record = get_new_marc_for_test(
         'Rabbit Test Paper',
         author_name=self.author_name,
         identifiers=[(
             self.ext_id,
             'i',
         )])
     self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                              opt_mode='insert')
     self.main_marcxml_record = add_001_field(self.main_marcxml_record,
                                              self.main_bibrec)
     self.bibrecs_to_clean = [self.main_bibrec]
コード例 #12
0
 def setUp(self):
     super(Marc100700CacheTestCase, self).setUp()
     marc_xml_record = get_new_marc_for_test(
         "Test",
         author_name=self.author_name,
         identifiers=None,
         co_authors_names=self.co_authors_names)
     self.bibrec_to_test = get_bibrec_for_record(marc_xml_record,
                                                 opt_mode='insert')
     self.bibrecs_to_clean = [self.bibrec_to_test]
     bibrefs = get_bibrefs_from_bibrecs([self.bibrec_to_test])
     for bibref in bibrefs:
         self.ref_table = bibref[1][0][0].split(":")[0]
         self.ref_value = bibref[1][0][0].split(":")[1]
     populate_partial_marc_caches([self.bibrec_to_test])
コード例 #13
0
 def test_rabbit_mark_record_as_deleted():
     '''
     A record is deleted. Rabbit should understand that and remove the author from the aidPERSON* tables.
     '''
     number_of_personids_before = get_count_of_pids()
     if config.CFG_INSPIRE_SITE:
         self.main_marcxml_record = get_modified_marc_for_test(
             self.main_marcxml_record,
             author_name=self.heavily_modified_name,
             ext_id=self.ext_id)
     self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                              opt_mode='delete')
     rabbit([self.main_bibrec], verbose=True)
     number_of_personids_after = get_count_of_pids()
     self.assertEquals(number_of_personids_before - 1,
                       number_of_personids_after)
コード例 #14
0
        def test_rabbit_remove_author_from_paper():
            '''
            The author field of the record is removed.
            Tests whether the author is actually removed by rabbit.
            '''
            number_of_personids_before = get_count_of_pids()
            self.main_marcxml_record = get_modified_marc_for_test(
                self.main_marcxml_record)
            self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                                     opt_mode='replace')

            rabbit([self.main_bibrec], verbose=True)
            number_of_personids_after = get_count_of_pids()
            self.assertEquals(number_of_personids_before,
                              number_of_personids_after + 1)
            self.assertFalse(
                person_in_aidpersonidpapers(self.author_name,
                                            self.main_bibrec))
            self.assertFalse(person_in_aidpersoniddata(self.author_name))
コード例 #15
0
        def test_rabbit_remove_coauthors_from_paper():

            number_of_personids_before = get_count_of_pids()
            self.main_marcxml_record = get_modified_marc_for_test(
                self.main_marcxml_record, author_name=self.author_name)
            self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                                     opt_mode='replace')
            rabbit([self.main_bibrec], verbose=True)
            number_of_personids_after = get_count_of_pids()
            self.assertEquals(number_of_personids_before,
                              number_of_personids_after + 4)

            self.assertTrue(
                person_in_aidpersonidpapers(self.author_name,
                                            self.main_bibrec))
            self.assertTrue(person_in_aidpersoniddata(self.author_name))

            for coauthor_name in self.co_authors_names:
                self.assertFalse(
                    person_in_aidpersonidpapers(coauthor_name,
                                                self.main_bibrec))
                self.assertFalse(person_in_aidpersoniddata(coauthor_name))
コード例 #16
0
 def test_rabbit_add_author_again():
     '''
     The author field of the record is re-added.
     Tests whether the author is added again to aidPERSONIDPAPERS and aidPERSONIDDATA.
     '''
     number_of_personids_before = get_count_of_pids()
     self.main_marcxml_record = get_modified_marc_for_test(
         self.main_marcxml_record, author_name=self.author_name)
     self.main_bibrec = get_bibrec_for_record(self.main_marcxml_record,
                                              opt_mode='replace')
     rabbit([self.main_bibrec], verbose=True)
     previous_bibref_value = self.current_bibref_value
     self.current_bibref_value = get_bibref_value_for_name(
         self.author_name)
     number_of_personids_after = get_count_of_pids()
     self.assertEquals(previous_bibref_value, self.current_bibref_value)
     self.assertEquals(number_of_personids_after,
                       number_of_personids_before + 1)
     self.assertTrue(
         person_in_aidpersonidpapers(self.author_name,
                                     self.main_bibrec))
     self.assertTrue(person_in_aidpersoniddata(self.author_name))