Ejemplo n.º 1
0
def test_run_sync_timeout(mock_get, mock_post):
    """ fcn to run a sync end-to-end until finished - timeout """
    bulk = Bulk(test=True)
    bulk.exports('contacts')
    bulk.job_def = EXPORT_JOB_DEF
    mock_post.return_value = Mock(ok=True, status_code=200)
    mock_post.return_value.json.return_value = deepcopy(SYNC_RESPONSE)
    mock_get.return_value = Mock(ok=True, status_code=200)
    mock_get.return_value.json.return_value = SYNC_RESPONSE_ACTIVE
    bulk.sync(sleeptime=0.03, timeout=0.01)
Ejemplo n.º 2
0
def test_run_sync_timeout(mock_get, mock_post):
    """ fcn to run a sync end-to-end until finished - timeout """
    bulk = Bulk(test=True)
    bulk.exports('contacts')
    bulk.job_def = EXPORT_JOB_DEF
    mock_post.return_value = Mock(ok=True, status_code=200)
    mock_post.return_value.json.return_value = deepcopy(SYNC_RESPONSE)
    mock_get.return_value = Mock(ok=True, status_code=200)
    mock_get.return_value.json.return_value = SYNC_RESPONSE_ACTIVE
    bulk.sync(sleeptime=0.03, timeout=0.01)
Ejemplo n.º 3
0
def test_run_sync_error(mock_get, mock_post):
    """ fcn to run a sync end-to-end until finished - error """
    bulk = Bulk(test=True)
    bulk.exports('contacts')
    bulk.job_def = EXPORT_JOB_DEF
    mock_post.return_value = Mock(ok=True, status_code=200)
    mock_post.return_value.json.return_value = deepcopy(SYNC_RESPONSE)
    mock_get.return_value = Mock(ok=True, status_code=200)
    mock_get.return_value.json.return_value = SYNC_RESPONSE_ERROR
    status = bulk.sync(sleeptime=0.01)
    assert status == 'error'
Ejemplo n.º 4
0
def test_run_sync_error(mock_get, mock_post):
    """ fcn to run a sync end-to-end until finished - error """
    bulk = Bulk(test=True)
    bulk.exports('contacts')
    bulk.job_def = EXPORT_JOB_DEF
    mock_post.return_value = Mock(ok=True, status_code=200)
    mock_post.return_value.json.return_value = deepcopy(SYNC_RESPONSE)
    mock_get.return_value = Mock(ok=True, status_code=200)
    mock_get.return_value.json.return_value = SYNC_RESPONSE_ERROR
    status = bulk.sync(sleeptime=0.01)
    assert status == 'error'
Ejemplo n.º 5
0
# 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)