def find_online_presence(first_name, last_name, middle_name=None, domains=None, linkedin_url=None, angellist_url=None, twitter_url=None): """ Discover a single person's online presence, if possible. Attempts to find accurate user information from the following services/service types: #. Email (Gmail, Outlook, Hotmail, Yahoo) #. Web Domains (personal or corporate) #. LinkedIn #. AngelList #. Twitter :param first_name: The person's first name :param last_name: The person's last name :param middle_name: The person's middle name :param domains: Domains, personal or corporate, that the person associates with :param linkedin_url: The person's profile URL :param angellist_url: The person's AngelList URL :param twitter_url: The person's Twitter URL :return: JSON representation of the person's online presence information """ # Create our person to be found hidden_person = Person( first_name, last_name, middle_name, domains, linkedin_url, angellist_url, twitter_url ) # Create a locator to find the person locator = PersonLocator(hidden_person) # Find them. Do whatever it takes (brute_force=True) locator.locate(brute_force=True) return json.dumps(hidden_person.__dict__)
def setUp(self): self.locator = PersonLocator(Person('James', 'Bond', 'Herbert'))
class TestPersonLocator(unittest.TestCase): def setUp(self): self.locator = PersonLocator(Person('James', 'Bond', 'Herbert')) def test_enumerate_full_name_combinations_first_last(self): """ Are simple combinations of first and last names generated? """ self.locator._enumerate_full_name_representations() expected_names_subset = ['James Bond', 'Bond James', 'Bond, James'] for name in expected_names_subset: self.assertTrue(name in self.locator.full_name_representations) def test_enumerate_full_name_combinations_alternate_first_names(self): """ Are the simple combinations of first and last name containing alternate first names generated? """ self.locator._enumerate_full_name_representations() expected_names_subset = ['Jim Bond', 'Jimmie Bond', 'Jimmy Bond', 'Jamie Bond'] for name in expected_names_subset: self.assertTrue(name in self.locator.full_name_representations) def test_enumerate_full_name_combinations_first_middle_last(self): """ Are a sampling of the complex combinations of first, middle, and last names generated? """ self.locator._enumerate_full_name_representations() expected_names_subset = [ 'James Herbert Bond', 'Herbert Bond James', 'Bond James Herbert', 'James, Herbert, Bond', 'Herbert, Bond, James', 'Bond, James, Herbert', 'Bond, James Herbert' ] for name in expected_names_subset: self.assertTrue(name in self.locator.full_name_representations) def test_enumerate_full_name_combinations_first_middle_initial_last(self): """ Are a sample of complex combinations of first, middle, middle initial, and last names generated? """ self.locator._enumerate_full_name_representations() expected_names_subset = [ 'James H Bond', 'H Bond James', 'Bond James H', 'James, H, Bond', 'H, Bond, James', 'Bond, James, H', 'Bond, James H' ] for name in expected_names_subset: self.assertTrue(name in self.locator.full_name_representations) def test_determine_probable_usernames_for_full_name(self): """ Are a subset of username combinations and a subset of name/symbol combinations generated? """ self.locator._enumerate_probable_usernames() expected_usernames_subset = [ 'JamesBond', 'James.Bond', 'James_Bond', 'J.Bond', 'J.B', 'James.B', 'James_B', 'BondJames', 'BJames', 'B_James', 'JamesHerbertBond', 'JHerbertBond', 'J.HerbertBond', 'J_HerbertBond', 'JHerbert.Bond', 'JHerbert_Bond', 'Bond_James.H', 'BJH', 'J.H.B', 'James_H_Bond', 'Bond.J_Herbert' ] for username in expected_usernames_subset: self.assertTrue(username in self.locator.probable_usernames) # Names in the order of `Last Middle First` should not be generated self.assertTrue('BondHerbertJames' not in self.locator.probable_usernames) # Usernames should not start or end with special characters for username in self.locator.probable_usernames: self.assertFalse(username.startswith('.')) self.assertFalse(username.startswith('_')) self.assertFalse(username.endswith('.')) self.assertFalse(username.endswith('_'))