def sync_contacts(self): STATE = utils.get_clear_state() catalog = {"stream_alias": "hubspot_contacts"} tap_hubspot.default_contact_params["count"] = 1 STATE = tap_hubspot.sync_contacts(STATE, catalog) # offset has been cleared self.assertEqual(utils.caught_state["bookmarks"]["contacts"]["offset"], {}) # some bookmark has been recorded in the state self.assertNotEqual( utils.caught_state["bookmarks"]["contacts"]["lastmodifieddate"], None) # should sync some contacts # LOGGER.info('A caught record: {}'.format(utils.caught_records['contacts'][0])) self.assertGreater(len(utils.caught_records["contacts"]), 1) self.assertEqual(set(utils.caught_records.keys()), {"contacts"}) self.assertEqual(utils.caught_pks, {"contacts": ["vid"]}) utils.caught_records = [] STATE = tap_hubspot.sync_contacts(STATE, catalog) # no new records thanks to bookmark self.assertEqual(len(utils.caught_records), 0)
def sync_companies(self): STATE = utils.get_clear_state() catalog = {"stream_alias": "hubspot_companies"} STATE = tap_hubspot.sync_companies(STATE, catalog) # offset has been cleared self.assertEqual( utils.caught_state["bookmarks"]["companies"]["offset"], {}) # some bookmark has been recorded in the state self.assertNotEqual( utils.caught_state["bookmarks"]["companies"] ["hs_lastmodifieddate"], None) # should sync some contacts && some hubspot_contacts_by_company self.assertGreater(len(utils.caught_records), 0) self.assertEqual( set(utils.caught_records.keys()), {"companies", "hubspot_contacts_by_company"}, ) self.assertEqual( utils.caught_pks, { "companies": ["companyId"], "hubspot_contacts_by_company": ["company-id", "contact-id"], }, ) utils.caught_records = [] STATE = tap_hubspot.sync_companies(STATE, catalog) # no new records thanks to bookmark self.assertEqual(len(utils.caught_records), 0)
def sync_companies(self): STATE = utils.get_clear_state() catalog = {'stream_alias': 'hubspot_companies'} STATE = tap_hubspot.sync_companies(STATE, catalog) #offset has been cleared self.assertEqual( utils.caught_state['bookmarks']['companies']['offset'], {}) #some bookmark has been recorded in the state self.assertNotEqual( utils.caught_state['bookmarks']['companies'] ['hs_lastmodifieddate'], None) #should sync some contacts && some hubspot_contacts_by_company self.assertGreater(len(utils.caught_records), 0) self.assertEqual(set(utils.caught_records.keys()), {'companies', 'hubspot_contacts_by_company'}) self.assertEqual( utils.caught_pks, { 'companies': ['companyId'], 'hubspot_contacts_by_company': ['company-id', 'contact-id'] }) utils.caught_records = [] STATE = tap_hubspot.sync_companies(STATE, catalog) #no new records thanks to bookmark self.assertEqual(len(utils.caught_records), 0)
def sync_companies(self): simulated_exception = None STATE = utils.get_clear_state() catalog = {'stream_alias': 'hubspot_companies'} #change count = 1 tap_hubspot.default_company_params['limit'] = 1 try: STATE = tap_hubspot.sync_companies(STATE, catalog) except Exception as ex: simulated_exception = ex # logging.exception('strange') self.assertIsNot(simulated_exception, None) self.assertEqual(set(utils.caught_records.keys()), {'companies', 'hubspot_contacts_by_company'}) #should only emit 1 company record because of the limit self.assertEqual(len(utils.caught_records['companies']), 1) self.assertGreater( len(utils.caught_records['hubspot_contacts_by_company']), 0) #offset should be set in state LOGGER.info("utils.caught_state: {}".format(utils.caught_state)) self.assertNotEqual( utils.caught_state['bookmarks']['companies']['offset'], {}) #no bookmark though self.assertEqual( utils.caught_state['bookmarks']['companies'] ['hs_lastmodifieddate'], None) #change count back to 250 tap_hubspot.default_company_params['limit'] = 250