def test_flattened_initials(self): self.assertFalse(match_names( ('Jamie Oliver', 'Ryder'), ('Jo', 'Ryder'))) self.assertTrue(match_names( ('Jean-Pierre', 'Dupont'), ('JP.', 'Dupont'))) self.assertTrue(match_names( ('Jean-Pierre', 'Dupont'), ('Jp.', 'Dupont')))
def test_flattened_initials(self): self.assertFalse( match_names(('Jamie Oliver', 'Ryder'), ('Jo', 'Ryder'))) self.assertTrue( match_names(('Jean-Pierre', 'Dupont'), ('JP.', 'Dupont'))) self.assertTrue( match_names(('Jean-Pierre', 'Dupont'), ('Jp.', 'Dupont')))
def translate_author(self, dissemin_author, goal="optional"): first_name = dissemin_author['name']['first'] last_name = dissemin_author['name']['last'] author = "{} {}".format(first_name, last_name) if goal == "contrib": structure = { "data": { "type": "contributors", "attributes": { "full_name": author } } } # check if the author is the user doing the deposit user_name = (self.user.first_name, self.user.last_name) is_user = match_names((first_name, last_name), user_name) if is_user and self.user_id_on_osf: profile_url = (self.api_url + "v2/users/" + self.user_id_on_osf) structure['links'] = {"self": profile_url} return structure else: return author
def translate_author(self, dissemin_author, goal="optional"): first_name = dissemin_author['name']['first'] last_name = dissemin_author['name']['last'] author = "{} {}".format(first_name, last_name) if goal == "contrib": structure = { "data": { "type": "contributors", "attributes": { "full_name": author } } } # check if the author is the user doing the deposit user_name = (self.user.first_name, self.user.last_name) is_user = match_names((first_name, last_name), user_name) if is_user and self.user_id_on_osf: profile_url = ( self.api_url + "v2/users/" + self.user_id_on_osf) structure['links'] = { "self": profile_url } return structure else: return author
def test_unicode(self): self.assertTrue( match_names(('Thomas Émile', 'Bourgeat'), ('T. E.', 'Bourgeat')))
def test_last_name(self): self.assertFalse( match_names(('Claire', 'Mathieu'), ('Claire', 'Kenyon-Mathieu')))
def test_hyphen(self): self.assertTrue(match_names(('J.-P.', 'Dupont'), ('J.', 'Dupont'))) self.assertTrue( match_names(('Jean-Pierre', 'Dupont'), ('J.-P.', 'Dupont')))
def test_middle_initial(self): self.assertFalse( match_names(('W. T. K.', 'Gowers'), ('Timothy', 'Gowers')))
def test_reverse_order(self): self.assertTrue(match_names(('R. J.', 'Ryder'), ('J.', 'Ryder'))) self.assertTrue(match_names(('W. T.', 'Gowers'), ('Timothy', 'Gowers')))
def test_simple(self): self.assertTrue(match_names(('Robin', 'Ryder'), ('Robin', 'Ryder'))) self.assertTrue(match_names(('Robin', 'Ryder'), ('R.', 'Ryder'))) self.assertTrue(match_names(('R. J.', 'Ryder'), ('R.', 'Ryder'))) self.assertFalse(match_names(('Jean', 'Dupont'), ('Joseph', 'Dupont'))) self.assertFalse(match_names(('R. K.', 'Ryder'), ('J.', 'Ryder')))
def test_unicode(self): self.assertTrue(match_names( ('Thomas Émile', 'Bourgeat'), ('T. E.', 'Bourgeat')))
def test_last_name(self): self.assertFalse(match_names(('Claire', 'Mathieu'), ('Claire', 'Kenyon-Mathieu')))
def test_hyphen(self): self.assertTrue(match_names(('J.-P.', 'Dupont'), ('J.', 'Dupont'))) self.assertTrue(match_names( ('Jean-Pierre', 'Dupont'), ('J.-P.', 'Dupont')))
def test_middle_initial(self): self.assertFalse(match_names( ('W. T. K.', 'Gowers'), ('Timothy', 'Gowers')))
def test_reverse_order(self): self.assertTrue(match_names(('R. J.', 'Ryder'), ('J.', 'Ryder'))) self.assertTrue(match_names(('W. T.', 'Gowers'), ('Timothy', 'Gowers')))
def test_simple(self): self.assertTrue(match_names(('Robin', 'Ryder'), ('Robin', 'Ryder'))) self.assertTrue(match_names(('Robin', 'Ryder'), ('R.', 'Ryder'))) self.assertTrue(match_names(('R. J.', 'Ryder'), ('R.', 'Ryder'))) self.assertFalse(match_names(('Jean', 'Dupont'), ('Joseph', 'Dupont'))) self.assertFalse(match_names(('R. K.', 'Ryder'), ('J.', 'Ryder')))