def test_single_match_strat_2(self):
        author1 = authors_model.objects.create(main_name="Han Lin Xuu")
        author2 = authors_model.objects.create(main_name="Han Xiu Lin")

        author_aliases.objects.create(author=author1, alias="Han Lin Xuu")
        author_aliases.objects.create(author=author1, alias="Han Xuu Lin")
        author_aliases.objects.create(author=author2, alias="Han Lin Xiu")
        author_aliases.objects.create(author=author2, alias="Han Lin")

        authors = [{
            "original_name": "Han Xiu",
            "parsed_name": "Han Xiu",
            "website": None,
            "contact": None,
            "about": None,
            "modified": None,
            "orcid_id": None,
        }]

        result = advanced_author_match(authors)
        self.assertEqual(result,[{
                "status": Status.SAFE,
                "match": Match.SINGLE_MATCH,
                "id": author2,
                "reason": None,
            },
        ])
    def test_multi_match_strat_2(self):
        author1 = authors_model.objects.create(main_name="Han Lin Xuu")
        author2 = authors_model.objects.create(main_name="Han Xiu Lin")

        author_aliases.objects.create(author=author1, alias="Han Lin Xuu")
        author_aliases.objects.create(author=author1, alias="Han Xuu Lin")
        author_aliases.objects.create(author=author2, alias="Han Lin Xiu")

        authors = [{
            "original_name": "Han Lin",
            "parsed_name": "Han Lin",
            "website": None,
            "contact": None,
            "about": None,
            "modified": None,
            "orcid_id": None,
        }]

        result = advanced_author_match(authors)
        self.assertEqual(result,[{
                    "status": Status.LIMBO,
                    "match": Match.MULTI_MATCH,
                    "id": None,
                    "reason": Reason.AMB_NAME_BLOCK
                }])
 def test_success_empty_db(self):
     authors=[{
         "original_name": "Karl Bauer",
         "parsed_name": "Karl Bauer",
         "website": None,
         "contact": None,
         "about": None,
         "modified": None,
         "orcid_id": None,
     },
     {
         "original_name": "Jarl Mauer",
         "parsed_name": "Jarl Mauer",
         "website": None,
         "contact": None,
         "about": None,
         "modified": None,
         "orcid_id": None,
     },
     ]
     result = advanced_author_match(authors)
     self.assertEqual(result, [{
             "status": Status.SAFE,
             "match": Match.NO_MATCH,
             "id": None,
             "reason": None,
         },
         {
             "status": Status.SAFE,
             "match": Match.NO_MATCH,
             "id": None,
             "reason": None,
         }
     ])
Exemplo n.º 4
0
    def test_long(self):
        for i in range(1000):
            lurl = local_url.objects.create(url="a", global_url=self.gurl)
            matches = advanced_author_match(self.authors)
            id_list = create_authors(matches, self.authors, lurl)

        for x in authors_model.objects.all():
            print(x.test())
        self.assertEqual(authors_model.objects.count(), 2)
    def test_single_alias_match(self):
        author = authors_model.objects.create(id=5, main_name ="Hans Gruber")
        authors = [{
            "original_name": "Hans. Gruber",
            "parsed_name": "Hans. Gruber",
            "website": None,
            "contact": None,
            "about": None,
            "modified": None,
            "orcid_id": None,
        },
        ]
        result = advanced_author_match(authors)

        self.assertEqual(result, [{
                "status": Status.SAFE,
                "match": Match.SINGLE_MATCH,
                "id": author,
                "reason": None,
            },
        ])