def test_asset_exists_list_none(mock_get): """ add exists filter - exception on no params """ 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_LIST_NAME) bulk.asset_exists(asset='lists')
def test_asset_exists_list_id(mock_get): """ add exists filter - Shared List by ID """ 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_LIST_ID) bulk.asset_exists(asset='lists', asset_id=1) assert bulk.job['filters'][0] == " EXISTS('{{ContactList[1]}}') "
def test_asset_exists_list_id_call(mock_get): """ add exists filter - Shared List by ID, api call """ 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_LIST_ID) bulk.asset_exists(asset='lists', asset_id=1) mock_get.assert_called_with(url=bulk.bulk_base + '/contacts/lists/1', auth=bulk.auth)
def test_asset_exists_list_nm_call(mock_get): """ add exists filter - Shared List by Name, api call """ 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_LIST_NAME) bulk.asset_exists(asset='lists', name='Test List 1') mock_get.assert_called_with(url=bulk.bulk_base + '/contacts/lists?q="name=Test*List*1"', auth=bulk.auth)
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 contact_records = bulk.get_export_data() # retrieve the prepared data # Let's take a look at our data: