def test_add_fields_actvty(): """ add some activity fields """ bulk = Bulk(test=True) bulk.exports('activities', act_type='EmailOpen') fields = ['ActivityId', 'AssetId'] bulk.add_fields(fields) assert len(bulk.job['fields']) == 2
def test_accnt_system_fields_set(mock_get): """ add some account system fields """ bulk = Bulk(test=True) bulk.exports('accounts') mock_get.return_value = Mock(ok=True, status_code=200) mock_get.return_value.json.return_value = deepcopy(GOOD_FIELDS) bulk.add_fields(['accountID', 'createdAt']) assert len(bulk.job['fields']) == 2
def test_add_fields_notfound(mock_get): """ raise exception when field not found """ bulk = Bulk(test=True) bulk.exports('contacts') mock_get.return_value = Mock(ok=True, status_code=200) mock_get.return_value.json.return_value = deepcopy(GOOD_FIELDS) fields = ['C_EmailAddress', 'C_FirstName', 'C_LastName'] bulk.add_fields(fields)
def test_add_fields_display(mock_get): """ add contact fields to object by Display Name """ bulk = Bulk(test=True) bulk.exports('contacts') mock_get.return_value = Mock(ok=True, status_code=200) mock_get.return_value.json.return_value = deepcopy(GOOD_FIELDS) fields = ['Email Address', 'First Name'] bulk.add_fields(fields) assert bulk.job['fields'] == GOOD_FIELDS['items']
def test_add_fields_all(mock_get): """ add contact fields to object by Display Name """ bulk = Bulk(test=True) bulk.exports('contacts') mock_get.return_value = Mock(ok=True, status_code=200) mock_get.return_value.json.return_value = deepcopy(GOOD_FIELDS) bulk.add_fields() print(len(bulk.job['fields'])) print(len(ALL_CONTACT_FIELDS)) assert bulk.job['fields'] == ALL_CONTACT_FIELDS
bulk.exports('contacts') # list out what contact fields we want field_set = ['C_EmailAddress', 'contactID', 'createdAt', 'C_FirstName', 'isSubscribed', 'isBounced'] # 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
def test_add_fields_actvty_all(): """ add all activity fields """ bulk = Bulk(test=True) bulk.exports('activities', act_type='EmailOpen') bulk.add_fields() assert bulk.job['fields'] == ACTIVITY_FIELDS['EmailOpen']