コード例 #1
0
 def test_check_collection(self):
     """bibmatch - check collection"""
     records = create_records(self.recxml4)
     [nomatchrecs, dummy1, dummy2, dummy3] = match_records(records, collections=["Books"], verbose=0)
     self.assertEqual(1, len(nomatchrecs))
     [dummy1, matchedrecs, dummy2, dummy3] = match_records(records, collections=["Articles"], verbose=0)
     self.assertEqual(1, len(matchedrecs))
コード例 #2
0
 def test_restricted_collections_remote(self):
     """bibmatch - check restricted collections remote search"""
     records = create_records(self.recxml5)
     # Jekyll should have access
     [dummy1, matchedrecs, dummy2, dummy3] = match_records(
         records,
         qrystrs=[("", "[088__a]")],
         collections=["Theses"],
         server_url="https://invenio-demo.cern.ch",
         user="******",
         password="******",
         verbose=0,
     )
     self.assertEqual(1, len(matchedrecs))
     # Hyde should not have access
     [nomatchrecs, dummy1, dummy2, dummy3] = match_records(
         records,
         qrystrs=[("", "[088__a]")],
         collections=["Theses"],
         server_url="https://invenio-demo.cern.ch",
         user="******",
         password="******",
         verbose=0,
     )
     self.assertEqual(1, len(nomatchrecs))
コード例 #3
0
 def test_check_collection(self):
     """bibmatch - check collection"""
     records = create_records(self.recxml3)
     [nomatchrecs, dummy1, dummy2, dummy3] = match_records(records, \
                                                           collections=["Articles"])
     self.assertEqual(1, len(nomatchrecs))
     [dummy1, matchedrecs, dummy2, dummy3] = match_records(records, \
                                                           collections=["Books"])
     self.assertEqual(1, len(matchedrecs))
コード例 #4
0
 def test_check_textmarc(self):
     """bibmatch - check textmarc as input"""
     marcxml = transform_input_to_marcxml("", self.textmarc)
     records = create_records(marcxml)
     [dummy1, matchedrecs, dummy3, dummy4] = match_records(records, \
                                                           server_url="http://invenio-demo.cern.ch")
     self.assertEqual(2, len(matchedrecs))
コード例 #5
0
 def test_check_textmarc(self):
     """bibmatch - check textmarc as input"""
     marcxml = transform_input_to_marcxml("", self.textmarc)
     records = create_records(marcxml)
     [dummy1, matchedrecs, dummy3, dummy4] = match_records(records, \
                                                           verbose=0)
     self.assertEqual(2, len(matchedrecs))
コード例 #6
0
 def test_check_remote(self):
     """bibmatch - check remote match (Invenio demo site)"""
     records = create_records(self.recxml6)
     [dummy1, matchedrecs, dummy3, dummy4] = match_records(records, \
                                                           server_url="http://invenio-demo.cern.ch", \
                                                           verbose=0)
     self.assertEqual(1, len(matchedrecs))
コード例 #7
0
 def test_check_textmarc(self):
     """bibmatch - check textmarc as input"""
     marcxml = transform_input_to_marcxml("", self.textmarc)
     records = create_records(marcxml)
     [dummy1, matchedrecs, dummy3, dummy4] = match_records(records, \
                                                           verbose=0)
     self.assertEqual(2, len(matchedrecs))
コード例 #8
0
 def test_check_remote(self):
     """bibmatch - check remote match (Invenio demo site)"""
     records = create_records(self.recxml6)
     [dummy1, matchedrecs, dummy3, dummy4] = match_records(records, \
                                                           server_url="http://invenio-demo.cern.ch", \
                                                           verbose=0)
     self.assertEqual(1, len(matchedrecs))
コード例 #9
0
 def test_check_altered(self):
     """bibmatch - check altered match"""
     records = create_records(self.recxml3)
     self.assertTrue(not record_has_field(records[0][0], '001'))
     [dummy1, matchedrecs, dummy3, dummy4] = match_records(records,
                                                           modify=1)
     self.assertTrue(record_has_field(matchedrecs[0][0], '001'))
コード例 #10
0
 def test_check_textmarc(self):
     """bibmatch - check textmarc as input"""
     marcxml = transform_input_to_marcxml("", self.textmarc)
     records = create_records(marcxml)
     [dummy1, matchedrecs, dummy3, dummy4] = match_records(records, \
                                                           server_url="http://invenio-demo.cern.ch")
     self.assertEqual(2, len(matchedrecs))
コード例 #11
0
 def test_check_qrystr(self):
     """bibmatch - check querystrings"""
     qrystrs = ["author||reportnumber"]
     records = create_records(self.recxml1)
     [dummy1, matchedrecs, dummy3, dummy4] = match_records(records,
                                                           qrystrs=qrystrs)
     self.assertEqual(1, len(matchedrecs))
コード例 #12
0
 def test_check_remote(self):
     """bibmatch - check remote match (Invenio demo site)"""
     records = create_records(self.recxml1)
     [dummy1, matchedrecs, dummy3, fuzzyrecs
      ] = match_records(records,
                        server_url="http://demo.invenio-software.org")
     self.assertEqual(1, len(matchedrecs))
コード例 #13
0
 def test_check_altered(self):
     """bibmatch - check altered match"""
     records = create_records(self.recxml4)
     self.assertTrue(not record_has_field(records[0][0], '001'))
     [dummy1, matchedrecs, dummy3, dummy4] = match_records(records, \
                                                           modify=1, \
                                                           verbose=0)
     self.assertTrue(record_has_field(matchedrecs[0][0], '001'))
コード例 #14
0
    def test_check_existing(self):
        """bibmatch - check existing record"""
        # Non-fuzzy searching will not find it
        records = create_records(self.recxml4)
        [nonmatchedrecs, dummy1, dummy2, dummy3] = match_records(records, verbose=0, fuzzy=False)
        self.assertEqual(1, len(nonmatchedrecs))

        # Fuzzy searching should find it
        records = create_records(self.recxml4)
        [dummy1, matchedrecs, dummy2, dummy3] = match_records(records, verbose=0, fuzzy=True)
        self.assertEqual(1, len(matchedrecs))

        # Check that searches returning more results are properly validated
        # This search should return 4 hits, but only real 1 match.
        records = create_records(self.recxml6)
        [dummy1, matchedrecs, dummy2, dummy3] = match_records(records, verbose=0)
        self.assertEqual(1, len(matchedrecs))
コード例 #15
0
 def test_check_fuzzy_validation(self):
     """bibmatch - check fuzzily matched record"""
     records = create_records(self.recxml7)
     [dummy1, dummy2, dummy3,
      fuzzyrecs] = match_records(records,
                                 qrystrs=[("", "[title]")],
                                 verbose=0)
     self.assertEqual(1, len(fuzzyrecs))
コード例 #16
0
 def test_check_textmarc(self):
     """bibmatch - check textmarc as input"""
     marcxml = transform_input_to_marcxml("", self.textmarc)
     records = create_records(marcxml)
     [dummy1, matchedrecs, dummy3, fuzzyrecs
      ] = match_records(records,
                        server_url="http://demo.invenio-software.org")
     self.assertEqual(2, len(matchedrecs))
コード例 #17
0
 def test_restricted_collections_local(self):
     """bibmatch - check restricted collections local search"""
     records = create_records(self.recxml5)
     # Jekyll should have access
     [dummy1, matchedrecs, dummy2, dummy3] = match_records(records, \
                                                           qrystrs=[("", "[088__a]")], \
                                                           collections=["Theses"], \
                                                           user="******",
                                                           password="******")
     self.assertEqual(1, len(matchedrecs))
     # Hyde should not have access
     [nomatchrecs, dummy1, dummy2, dummy3] = match_records(records, \
                                                           qrystrs=[("", "[088__a]")], \
                                                           collections=["Theses"], \
                                                           user="******", \
                                                           password="******",
                                                           verbose=0)
     self.assertEqual(1, len(matchedrecs))
コード例 #18
0
    def test_restricted_collections_local(self):
        """bibmatch - check restricted collections local search"""
        records = create_records(self.recxml5)
        # Should not have access
        [nomatchrecs, dummy1, dummy2, dummy3] = match_records(records, \
                                                              qrystrs=[("", "[088__a]")], \
                                                              collections=["Theses"], \
                                                              verbose=0)
        self.assertEqual(1, len(nomatchrecs))

        # Jekyll should have access
        [dummy1, matchedrecs, dummy2, dummy3] = match_records(records, \
                                                              qrystrs=[("", "[088__a]")], \
                                                              collections=["Theses"], \
                                                              user="******",
                                                              password="******", \
                                                              verbose=0)
        self.assertEqual(1, len(matchedrecs))
コード例 #19
0
    def test_restricted_collections_local(self):
        """bibmatch - check restricted collections local search"""
        records = create_records(self.recxml5)
        # Should not have access
        [nomatchrecs, dummy1, dummy2, dummy3] = match_records(records, \
                                                              qrystrs=[("", "[088__a]")], \
                                                              collections=["Theses"], \
                                                              verbose=0)
        self.assertEqual(1, len(nomatchrecs))

        if MECHANIZE_AVAILABLE:
            # Jekyll should have access
            [dummy1, matchedrecs, dummy2, dummy3] = match_records(records, \
                                                                  qrystrs=[("", "[088__a]")], \
                                                                  collections=["Theses"], \
                                                                  user="******",
                                                                  password="******", \
                                                                  verbose=0,
                                                                  insecure_login=True)
            self.assertEqual(1, len(matchedrecs))
コード例 #20
0
    def test_restricted_collections_local(self):
        """bibmatch - check restricted collections local search"""
        records = create_records(self.recxml5)
        # Should not have access
        [nomatchrecs, dummy1, dummy2, dummy3] = match_records(
            records, qrystrs=[("", "[088__a]")], collections=["Theses"], verbose=0
        )
        self.assertEqual(1, len(nomatchrecs))

        if MECHANIZE_AVAILABLE:
            # Jekyll should have access
            [dummy1, matchedrecs, dummy2, dummy3] = match_records(
                records,
                qrystrs=[("", "[088__a]")],
                collections=["Theses"],
                user="******",
                password="******",
                verbose=0,
                insecure_login=True,
            )
            self.assertEqual(1, len(matchedrecs))
コード例 #21
0
    def test_check_existing(self):
        """bibmatch - check existing record"""
        # Non-fuzzy searching will not find it
        records = create_records(self.recxml4)
        [nonmatchedrecs, dummy1, dummy2, dummy3] = match_records(records, \
                                                                 verbose=0, \
                                                                 fuzzy=False)
        self.assertEqual(1, len(nonmatchedrecs))

        # Fuzzy searching should find it
        records = create_records(self.recxml4)
        [dummy1, matchedrecs, dummy2, dummy3] = match_records(records, \
                                                              verbose=0, \
                                                              fuzzy=True)
        self.assertEqual(1, len(matchedrecs))

        # Check that searches returning more results are properly validated
        # This search should return 4 hits, but only real 1 match.
        records = create_records(self.recxml6)
        [dummy1, matchedrecs, dummy2, dummy3] = match_records(records, \
                                                              verbose=0)
        self.assertEqual(1, len(matchedrecs))
コード例 #22
0
def match_record(obj, eng):
    """
    Will try to find matches in stored records
    """
    from invenio.bibrecord import create_record
    from invenio.bibmatch_engine import match_records

    obj.db_obj.last_task_name = 'match_record'
    rec = create_record(obj.data['data'])
    matches = match_records(records=[rec], qrystrs=[("title", "[245__a]")])
    obj.db_obj.extra_data['tasks_results']['match_record'] = matches
    if matches[2] or matches[3]:
        # we have ambiguous or fuzzy results
        # render holding pen corresponding template
        eng.halt("Match resolution needed")
    elif matches[0]:
        eng.log.info("Matching: new record")
    else:
        results = matches[1][0][1]
        eng.log.info("Matching: existing record %s" % (results, ))
コード例 #23
0
 def test_check_existing(self):
     """bibmatch - check existing record"""
     records = create_records(self.recxml1)
     [dummy1, matchedrecs, dummy2, dummy3] = match_records(records)
     self.assertEqual(1,len(matchedrecs))
コード例 #24
0
 def test_check_fuzzy(self):
     """bibmatch - check fuzzily matched record"""
     records = create_records(self.recxml1)
     [dummy1, dummy2, dummy3, fuzzyrecs] = match_records(records, \
                                                         verbose=0)
     self.assertEqual(1, len(fuzzyrecs))
コード例 #25
0
 def test_check_ambiguous(self):
     """bibmatch - check an ambiguous record"""
     records = create_records(self.recxml3)
     [dummy1, dummy2, ambigrecs, dummy3] = match_records(records, \
                                                         verbose=0)
     self.assertEqual(1, len(ambigrecs))
コード例 #26
0
 def test_check_new(self):
     """bibmatch - check a new record"""
     records = create_records(self.recxml2)
     [newrecs, dummy1, dummy2, dummy3] = match_records(records, \
                                                       verbose=0)
     self.assertEqual(1, len(newrecs))
コード例 #27
0
 def test_check_ambiguous(self):
     """bibmatch - check an ambiguous record"""
     records = create_records(self.recxml1)
     [dummy1, dummy2, ambigrecs, dummy3] = match_records(records, qrystrs=[("", "[100__a]")])
     self.assertEqual(1, len(ambigrecs))
コード例 #28
0
 def test_check_fuzzy(self):
     """bibmatch - check fuzzily matched record"""
     records = create_records(self.recxml1)
     [dummy1, dummy2, dummy3, fuzzyrecs] = match_records(records, \
                                                         verbose=0)
     self.assertEqual(1, len(fuzzyrecs))
コード例 #29
0
 def test_check_ambiguous(self):
     """bibmatch - check an ambiguous record"""
     records = create_records(self.recxml3)
     [dummy1, dummy2, ambigrecs, dummy3] = match_records(records, \
                                                         verbose=0)
     self.assertEqual(1, len(ambigrecs))
コード例 #30
0
 def test_check_new(self):
     """bibmatch - check a new record"""
     records = create_records(self.recxml2)
     [newrecs, dummy1, dummy2, dummy3] = match_records(records, \
                                                       verbose=0)
     self.assertEqual(1, len(newrecs))
コード例 #31
0
 def test_check_completeness(self):
     """bibmatch - check query completeness"""
     records = create_records(self.recxml4)
     [dummy1, dummy2, ambigrecs,
      dummy3] = match_records(records, qrystrs=[("", "[088__a] [035__a]")])
     self.assertEqual(1, len(ambigrecs))
コード例 #32
0
 def test_check_completeness(self):
     """bibmatch - check query completeness"""
     records = create_records(self.recxml4)
     [dummy1, dummy2, ambigrecs, dummy3] = match_records(records, qrystrs=[("", "[088__a] [035__a]")])
     self.assertEqual(1, len(ambigrecs))
コード例 #33
0
 def test_check_qrystr(self):
     """bibmatch - check querystrings"""
     qrystrs = ["author||reportnumber"]
     records = create_records(self.recxml1)
     [dummy1, matchedrecs, dummy3, dummy4] = match_records(records, qrystrs=qrystrs)
     self.assertEqual(1,len(matchedrecs))
コード例 #34
0
 def test_check_existing(self):
     """bibmatch - check existing record"""
     records = create_records(self.recxml3)
     [dummy1, matchedrecs, dummy2, dummy3] = match_records(records)
     self.assertEqual(1, len(matchedrecs))
コード例 #35
0
 def test_check_ambiguous(self):
     """bibmatch - check an ambiguous record"""
     records = create_records(self.recxml1)
     [dummy1, dummy2, ambigrecs,
      dummy3] = match_records(records, qrystrs=[("", "[100__a]")])
     self.assertEqual(1, len(ambigrecs))