def test_match_with_invenio_matcher_task_without_result(self, _match, get_record_from_model): """Check invenio-matcher without results.""" from inspirehep.modules.workflows.tasks.matching import match_with_invenio_matcher obj = self.MockObj() eng = self.MockEng() _match.return_value.__iter__.return_value = iter([]) record = Record({'titles': [{'title': 'foo'}]}) get_record_from_model.return_value = record result = match_with_invenio_matcher()(obj, eng) self.assertFalse(result) self.assertEqual([], obj.extra_data['record_matches']['recids'])
def test_match_with_invenio_matcher_task_with_result(self, _match, get_record_from_model): """Check invenio-matcher multiple results.""" from invenio_matcher.models import MatchResult from inspirehep.modules.workflows.tasks.matching import match_with_invenio_matcher obj = self.MockObj() eng = self.MockEng() _match.return_value.__iter__.return_value = iter([ MatchResult(1, Record({"control_number": "1"}), 1.0), MatchResult(2, Record({"control_number": "2"}), 1.0), ]) record = Record({'titles': [{'title': 'foo'}]}) get_record_from_model.return_value = record result = match_with_invenio_matcher()(obj, eng) self.assertTrue(result) self.assertTrue(len(obj.extra_data['record_matches']['recids']) == 2)