def test_get_export_data_notexp(mock_data): """ get data from a synced export - exception """ bulk = Bulk(test=True) bulk.imports('contacts') bulk.job_def = IMPORT_JOB_DEF mock_data.return_value = RETURN_DATA['items'] bulk.get_export_data()
def test_get_export_data_call(mock_data): """ get data from a synced export - method call """ bulk = Bulk(test=True) bulk.exports('contacts') bulk.job_def = EXPORT_JOB_DEF mock_data.return_value = RETURN_DATA['items'] bulk.get_export_data() mock_data.assert_called_with(endpoint='/contacts/exports/1/data', max_recs=None, offset=0)
def test_get_export_data_rt(mock_data): """ get data from a synced export - return data """ bulk = Bulk(test=True) bulk.exports('contacts') bulk.job_def = EXPORT_JOB_DEF mock_data.return_value = RETURN_DATA['items'] data = bulk.get_export_data() assert data == RETURN_DATA['items']
# we could get the same set of fields like this: field_set = ['Email Address', 'contactID', 'createdAt', 'First Name', 'isSubscribed', 'isBounced'] # Now add them to our job bulk.add_fields(field_set) # Add a filter which will only give us contacts in our segment (using the ID from the segment URL) bulk.asset_exists('segments', asset_id=12345) # we could also get it like this, assuming the segment name is 'My Segment': bulk.asset_exists('segments', name='My Segment') # Now we're ready to export the data bulk.create_def('my export') bulk.sync() # creates a sync which tells Eloqua to prepare the data contact_records = bulk.get_export_data() # retrieve the prepared data # Let's take a look at our data: for contact in contact_records: print(contact)