def test_organization_relationships_built(self): org = Organization(TEST_DATA) self.assertIsNotNone(org.past_team) self.assertEqual('First', org.past_team.get(0).first_name) self.assertFalse(org.news) self.assertFalse(org.news.get(0)) self.assertIsNone(org.news.get(0).first_name)
def test_organization_built(self): org = Organization(TEST_DATA) self.assertEqual(org.description, 'Description') self.assertEqual(org.short_description, 'short description') self.assertEqual(org.founded_on, datetime(2012, 1, 2)) self.assertEqual(org.permalink, "testpermalink") self.assertEqual(org.homepage_url, "http://www.example.com") self.assertEqual(org.name, "Organization") self.assertEqual(org.total_funding_usd, 1234567) self.assertEqual(org.number_of_investments, 1) self.assertEqual(org.stock_symbol, "COY") self.assertEqual(org.number_of_employees, 1234)
def test_organization_built(self): org = Organization(TEST_DATA) self.assertEqual(org.permalink, "testpermalink") self.assertEqual(org.name, "Organization") self.assertEqual(org.short_description, 'short description') self.assertEqual(org.description, 'Description') self.assertEqual(org.primary_role, 'company') self.assertEqual(org.role_company, True) self.assertEqual(org.role_investor, False) self.assertEqual(org.role_group, False) self.assertEqual(org.role_school, False) self.assertEqual(org.founded_on, datetime(2012, 1, 2)) self.assertEqual(org.is_closed, False) self.assertEqual(org.closed_on, None) self.assertEqual(org.num_employees_min, 1234) self.assertEqual(org.num_employees_max, 2345) self.assertEqual(org.total_funding_usd, 1234567) self.assertEqual(org.number_of_investments, 1) self.assertEqual(org.homepage_url, "http://www.example.com") self.assertEqual(org.stock_symbol, "COY")
def test_organization_relationships_built(self): org = Organization(TEST_DATA) self.assertIsNotNone(org.current_team) self.assertEqual('Director of Title', org.current_team.get(0).title)
def enrich_company(self): try: name = self.enriched_entity.deduced['name'] if not self.enrich_key: # Search for all the companies with this name response = self._make_request(CrunchBaseEngager.PEOPLE_URL, {'name': name}) data = response.json().get('data') if not data or data.get('error'): raise EngagementException( "CrunchBaseEngager: error in retrieving company %s." % name) if len(data["items"]) > 1: raise EngagementException( "CrunchBaseEngager: company %s not ambiguous. Found %d people with this name." % (name, len(data["items"]))) if len(data["items"]) == 0: raise EngagementException( "CrunchBaseEngager: company %s not found." % name) # TODO: Future: Iterate over the returned people and check if there's another matching attribute (like social url) we can use to choose the right person permalink = data['items'][0]['properties']['permalink'] else: permalink = self.enrich_key response = self.get_node('organizations', permalink) if hasattr(response, 'from_cache'): self.set_data("from_cache", response.from_cache) if not response.from_cache: pass # code for debugging purposes data = response.json().get('data') org = Organization(data) # Name if org.name: self.set_data(C.NAME, org.name) # Get company logo if org.primary_image and len(org.primary_image) > 0: logo_url = org.primary_image[0].asset_path self.add_data(C.LOGOS, { C.LOGO_URL: logo_url, C.LOGO_SOURCE: 'crunchbase' }) # Get overview stats (acquisitions, total funds, etc.) if org.acquired_by and hasattr(org.acquired_by, 'acquirer'): acquiring_company = org.acquired_by.acquirer.name self.set_data(C.ACQUIRED_BY, acquiring_company) # Get headquarters if org.headquarters and len(org.headquarters) > 0: headquarters = '%s, %s' % (org.headquarters[0].city, org.headquarters[0].country) self.set_data(C.HEADQUARTERS, headquarters) # Get description if org.short_description: description = org.short_description self.set_data(C.DESCRIPTION, description) # Get founders if org.founders and len(org.founders) > 0: founders = [] for founder in org.founders: full_name = '%s %s' % (founder.first_name, founder.last_name) founders.append(full_name) self.set_data(C.FOUNDERS, founders) # Get categories if org.categories and len(org.categories) > 0: for category in org.categories: self.add_data(C.CATEGORIES, category.name) # Grab aliases if org.also_known_as: self.set_data(C.ALIASES, org.also_known_as) # Grab websites --> homepage_url ? if org.homepage_url and len(org.homepage_url) > 0: self.set_data(C.WEBSITE, org.homepage_url) # Is it a VC company if org.role_investor: self.set_data(C.INVESTMENT_COMPANY_TYPE, C.ORGANIZATION_TYPE_VENTURE_CAPITAL) # Is it an educational organization if org.role_school: self.set_data(C.ORGANIZATION_TYPE, C.ORGANIZATION_TYPE_SCHOOL) # Get socials if org.websites and len(org.websites) > 0: for url in org.websites: url_type = url.website_type.lower() if url_type == 'twitter': self.set_data(C.TWITTER_URL, url.url) elif url_type == 'facebook': self.set_data(C.FACEBOOK_URL, url.url) elif url_type == 'linkedin': self.set_data(C.LINKEDIN_URL, url.url) elif url_type == 'angellist': self.set_data(C.ANGELLIST_URL, url.url) else: pass # Get investments if org.investments and len(org.investments) > 0: all_investments = set() for investment in org.investments: investment_name = investment.invested_in.name all_investments.add(investment_name) self.set_data(C.PORTFOLIO_COMPANIES, list(all_investments)) # Get founding year if org.founded_on: founding_year = org.founded_on.year self.set_data(C.FOUNDING_YEAR, founding_year) # Get contact email - for emails-domain info # Get number of employees if org.num_employees_min and org.num_employees_max: employees_range_str = '%s|%s' % (org.num_employees_min, org.num_employees_max) self.set_data(C.EMPLOYEES_RANGE, employees_range_str) # Go over all investors if org.investors and len(org.investors) > 0: investors = [] for investor in org.investors: investor_dict = investor.data investor_type = investor_dict['type'].lower() if investor_type == 'person': investor_name = '%s %s' % ( investor_dict['properties']['first_name'], investor_dict['properties']['last_name']) elif investor_type == 'organization': investor_name = investor_dict['properties']['name'] else: pass str = 'partner/round' investors.append((investor_name, investor_type, str)) self.set_data(C.INVESTORS, investors) # Go over all board members if org.board_members_and_advisors and len( org.board_members_and_advisors) > 0: board_members = [] for board_member in org.board_members_and_advisors: # Do we need this: board_member.person.role_investor: full_name = '%s %s' % (board_member.person.first_name, board_member.person.last_name) board_members.append(full_name) self.set_data(C.ADVISORS, board_members) if org.founders and len(org.founders) > 0: founders = [] for founder in org.founders: # Do we need thjs: founder.role_investor: full_name = founder.first_name + " " + founder.last_name founders.append(full_name) self.set_data(C.FOUNDERS, founders) team_members = [] if org.past_team and len(org.past_team) > 0: for team_member in org.past_team: full_name = team_member.person.first_name + " " + team_member.person.last_name team_members.append(full_name) if org.current_team and len(org.current_team) > 0: for team_member in org.current_team: full_name = team_member.person.first_name + " " + team_member.person.last_name team_members.append(full_name) if len(team_members) > 0: self.set_data(C.TEAM, team_members) pass # Only if data was not found, get the companies by names # data = self.cb.organizations(company_name) # if 'items' in data: # permalink = data.items[0].permalink # self.set_data("permalink", permalink) # response = self.get_node('organizations', permalink) # node_data = response.json().get('data') # # Add the company name and other information (and then I can go to sleep! # pass except Exception as e: print( "CrunchBasengager::enrich_company - failed to enrich company %s (%s)" % (name, e)) raise EngagementException(e) return [C.NAME]