Ejemplo n.º 1
0
def test_elq_unknown_error(mock_get):
    """ exception raised on non-200 status code """
    mock_response = Mock()
    http_error = HTTPError()
    mock_response.raise_for_status.side_effect = http_error
    mock_get.return_value = mock_response
    Eloqua(company='test', username='******', password='******')
logging.basicConfig(filename=os.environ['OPENSHIFT_LOG_DIR'] +
                    '/Contacts.LeadType_getOfferDetails.log',
                    level=logging.INFO,
                    format='%(asctime)s - %(levelname)s - %(message)s')

#### setup Salesforce session

sf = Salesforce(username=os.environ['SALESFORCE_USER'],
                password=os.environ['SALESFORCE_PASSWORD'],
                security_token=os.environ['SALESFORCE_TOKEN'])
logging.info("Salesforce session established")

#### Setup Eloqua session

elq = Eloqua(username=os.environ['ELOQUA_USER'],
             password=os.environ['ELOQUA_PASSWORD'],
             company=os.environ['ELOQUA_COMPANY'])
logging.info("Eloqua session established")

#### Setup vars for creating import/export defs

cdoID = elq.GetCdoId(cdoName='Contacts.LeadType')

myFilter = "'{{CustomObject[1269].Field[23345]}}' = 'GET CAMPAIGN DETAILS'"

findFields = [
    "Contacts.LeadType.MostRecent_Offer_PrimarySolution",
    "Contacts.LeadType.MostRecent_Offer_ProductService",
    "Contacts.LeadType.MostRecent_OfferID", "Contacts.LeadType.S_Data_Status",
    "Contacts.LeadType.S_Last_Error", "Email_Address1"
]
Ejemplo n.º 3
0
def test_elq_set_user(mock_get):
    """ set username """
    mock_get.return_value = Mock(ok=True, status_code=200)
    mock_get.return_value.json.return_value = ELQ_LOGIN
    elq = Eloqua(company='test', username='******', password='******')
    assert elq.username == 'test'
Ejemplo n.º 4
0
def test_elq_invalid_auth(mock_get):
    """ exception raised on bad credentials """
    mock_get.return_value = Mock(ok=True, status_code=200)
    mock_get.return_value.json.return_value = "Not authenticated."
    Eloqua(company='test', username='******', password='******')
Ejemplo n.º 5
0
def test_elq_no_company():
    """ company required """
    Eloqua(username='******', password='******')
Ejemplo n.º 6
0
def test_elq_no_pwd():
    """ password required """
    Eloqua(company='test', username='******')
Ejemplo n.º 7
0
def test_elq_set_bulk_version():
    """ Change Bulk API version """
    elq = Eloqua(test=True)
    elq.set_bulk_version('1.2')
    assert elq.bulk_base == 'https://secure.p01.eloqua.com/API/BULK/1.2/'
Ejemplo n.º 8
0
def test_elq_no_user():
    """ username required """
    Eloqua(company='test', password='******')
Ejemplo n.º 9
0
def test_elq_test():
    """ test mode for authentication """
    elq = Eloqua(test=True)
    assert elq.auth == ('test\\test', 'test')
Ejemplo n.º 10
0
def test_elq_set_bulk_base(mock_get):
    """ set Bulk API base """
    mock_get.return_value = Mock(ok=True, status_code=200)
    mock_get.return_value.json.return_value = ELQ_LOGIN
    elq = Eloqua(company='test', username='******', password='******')
    assert elq.bulk_base == 'https://secure.p01.eloqua.com/API/Bulk/2.0/'
Ejemplo n.º 11
0
def test_elq_set_urlbase(mock_get):
    """ set URL base """
    mock_get.return_value = Mock(ok=True, status_code=200)
    mock_get.return_value.json.return_value = ELQ_LOGIN
    elq = Eloqua(company='test', username='******', password='******')
    assert elq.urlBase == 'https://secure.p01.eloqua.com'
Ejemplo n.º 12
0
def test_elq_set_auth(mock_get):
    """ set auth tuple """
    mock_get.return_value = Mock(ok=True, status_code=200)
    mock_get.return_value.json.return_value = ELQ_LOGIN
    elq = Eloqua(company='test', username='******', password='******')
    assert elq.auth == ('test\\test', 'test')
Ejemplo n.º 13
0
import re  ## comes standard with python and includes tools for working with strings
import zipcode  ## Includes functions for validating and working with zipcodes. Handy, right?
from pyeloqua import Eloqua  ## for working with Eloqua's Bulk API

print("try to connect...")
elq = Eloqua(company='mycompany',
             username='******',
             password='******')

print("Eloqua Site ID: " + elq.siteId)  ## outputs your Eloqua instance Site ID
print("Eloqua User: "******"Connected!")

print("Create a field statement for the API")
findTheseFields = ['Email Address', 'Zip or Postal Code'
                   ]  ## a list of fields we want from Eloqua
myFields = elq.CreateFieldStatement(entity='contacts',
                                    fields=findTheseFields,
                                    useInternalName=False)
print(myFields)

print("Create a filter for the API")
myFilter = elq.FilterExists(name='My Zipcodes to clean',
                            existsType='ContactSegment')
print(myFilter)

print("Tell the API what we want to export")
myExport = elq.CreateDef(entity='contacts',
                         defType='exports',
                         fields=myFields,
                         filters=myFilter,