Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
hub-client / dockerhub / test / marketo / test_mixins.py
Size: Mime:
class MarketoRequiresOauthTokenMixin(object):
    """
    Generic fixture that sets up data for httpretty mocking
    """
    OAUTH_TOKEN_URL = "https://fake.mktorest.com/identity/oauth/token"
    OAUTH_TOKEN_RESPONSE = {
        u'access_token': u'16cd5057-708d-4ff9-a12d-890d47c1d771:sj',
        u'token_type': u'bearer',
        u'expires_in': 1712,
        u'scope': u'marketo_api@docker.com'
    }


class MarketoGetLeadMixin(object):
    """
    Generic fixture
    """
    GET_LEAD_URL = "https://fake.mktorest.com/rest/v1/leads.json"
    POST_LEAD_URL = "https://fake.mktorest.com/rest/v1/leads.json"
    GET_LEAD_RESPONSE = {
        u'requestId': u'897e#14d33b2798e',
        u'success': True,
        u'result': [
            {
                u'id': 1097532,
                u'email': u'fake@email.com'
            }
        ]
    }
    GET_LEAD_NOT_FOUND_RESPONSE = {
        u'requestId': u'9a44#14ee0b31f46',
        u'success': True,
        u'result': []
    }
    POST_LEAD_RESPONSE = {
        u'requestId': u'e42b#14272d07d78',
        u'success': True,
        u'result': [
            {
                u'id': 1097532,
                u'status': u'updated'
            }
        ]
    }


class MarketoAddLeadToListMixin(object):
    POST_TO_LIST_URL = "https://fake.mktorest.com/rest/v1/lists/{0}/leads.json"
    POST_TO_LIST_URL_LIST_NOT_EXIST = "https://fake.mktorest.com/rest/v1/lists/{0}/leads.json"
    POST_TO_LIST_NOT_EXIST_RESPONSE = {
        u'errors': [{u'message': u'List not found', u'code': u'1013'}],
        u'requestId': u'98db#14ee5b342e9',
        u'success': False
    }
    POST_TO_LIST_RESPONSE = {
        u'requestId': u'2e8f#14d33af3eb3',
        u'success': True,
        u'result': [
            {
                u'status': u'added',
                u'id': 1097532
            }
        ]
    }


class MarketoRemoveFromListMixin(object):
    DELETE_FROM_LIST_URL = "https://fake.mktorest.com/rest/v1/lists/{0}/leads.json"
    DELETE_FROM_LIST_RESPONSE_NOT_IN_LIST = {
        u'requestId': u'16fd2#14d33b98991',
        u'success': True,
        u'result': [
            {
                u'status': u'skipped',
                u'reasons': [
                    {
                        u'message': u'Lead not in list',
                        u'code': u'1015'
                    }
                ],
                u'id': 1097532
            }
        ]
    }
    DELETE_FROM_LIST_RESPONSE_IN_LIST = {
        u'requestId': u'833b#14d33c3bf21',
        u'success': True,
        u'result': [
            {
                u'status': u'removed',
                u'id': 1097532
            }
        ]
    }


class MarketoIsSubscribedMixin(object):
    GET_LEADS_ON_LIST = "https://fake.mktorest.com/rest/v1/lists/{0}/leads.json"
    GET_LEADS_ON_LIST_NOT_IN_LIST_RESPONSE = {
        u'requestId': u'a235#14d33ca9e04',
        u'success': True,
        u'result': [
            {u'id': 1003773, u'email': None}, {u'id': 1003774, u'email': None},
            {u'id': 1003775, u'email': None}, {u'id': 1003776, u'email': None},
            {u'id': 1003777, u'email': None}, {u'id': 1003778, u'email': None},
            {u'id': 1003779, u'email': None}, {u'id': 1003780, u'email': None}
        ]
    }
    GET_LEADS_ON_LIST_IN_LIST_RESPONSE = {
        u'requestId': u'a235#14d33ca9e04',
        u'success': True,
        u'result': [
            {u'id': 1003773, u'email': None}, {u'id': 1003774, u'email': None},
            {u'id': 1003775, u'email': None}, {u'id': 1003776, u'email': None},
            {u'id': 1003777, u'email': None}, {u'id': 1003778, u'email': None},
            {u'id': 1003779, u'email': None}, {u'id': 1003780, u'email': None},
            {u'id': 1097532, u'email': u'fake@email.com'}
        ]
    }


class MarketoAssociateLeadMixin(object):
    ASSOCIATE_LEAD_URL = "https://fake.mktorest.com/rest/v1/leads/{0}/associate.json"
    ASSOCIATE_LEAD_RESPONSE = {
        u'requestId': u'14e41a000e7',
        u'success': True,
        u'result': []
    }


class MarketoAddLeadMixin(object):
    GET_LEAD_URL = "https://fake.mktorest.com/rest/v1/leads.json"
    GET_LEAD_RESPONSE = {
        u'requestId': u'897e#14d33b2798e',
        u'success': True,
        u'result': [
            {
                u'id': 1097532,
                u'email': u'fake@email.com'
            }
        ]
    }
    POST_LEAD_URL = "https://fake.mktorest.com/rest/v1/leads.json"
    POST_LEAD_RESPONSE = {
        u'requestId': u'e42b#14272d07d78',
        u'success': True,
        u'result': [
            {
                u'id': 1097532,
                u'status': u'updated'
            }
        ]
    }


class MarketoMemberOfListMixin(object):

    MEMBER_OF_LIST_URL = "https://fake.mktorest.com/rest/v1/lists/{0}/leads/ismember.json"
    GET_MEMBER_OF_LIST_RESPONSE = {
        u'requestId': u'2e8f#14d33af3eb3',
        u'success': True,
        u'result': [
            {
                u'status': u'memberof',
                u'id': 1097532
            }
        ]
    }
    GET_NOT_MEMBER_OF_LIST_RESPONSE = {
        u'requestId': u'2e8f#14d33af3eb3',
        u'success': True,
        u'result': [
            {
                u'status': u'notmemberof',
                u'id': 1097532
            }
        ]
    }


class MarketoRequestCampaignMixin(object):

    REQUEST_CAMPAIGN_URL = "https://fake.mktorest.com/rest/v1/campaigns/{0}/trigger.json"
    POST_VALID_CAMPAIGN_REQUEST_RESPONSE = {
        u'requestId': u'e42b#14272d07d78',
        u'success': True
    }
    POST_INVALID_CAMPAIGN_REQUEST_RESPONSE = {
        u'requestId': u'2e8f#14d33af3eb3',
        u'success': False,
        u'errors': [
            {
                u'message': u'Batch campaign not allowed',
                u'code': u'1003'
            },
            {
                u'message': u"Trigger campaign needs to have a 'Campaign Requested' trigger",
                u'code': u'1003'
            }
        ]
    }


class MarketoCreateActivityMixin(object):
    POST_CREATE_ACTIVITY_URL = "https://fake.mktorest.com/rest/v1/activities/external.json"
    POST_UNABLE_TO_CREATE_ACTIVITY_URL = "https://fake.mktorest.com/rest/v1/activities/external.json"
    POST_CREATE_ACTIVITY_RESPONSE = {
        "requestId": "e42b#14272d07d78",
        "success": True,
        "result": [
            {
                "id": 1097532,
                "status": "added"
            },
        ]
    }
    POST_UNABLE_TO_CREATE_ACTIVITY_RESPONSE = {
        "requestId": "e42b#14272d07d78",
        "success": False,
        "result": [
            {
                "status": "skipped",
                "errors": [
                    {
                        "code": "1004",
                        "message": "Lead not found"
                    }
                ]
            }
        ]
    }


class MarketoPageTokenMixin(object):
    GET_PAGE_TOKEN_URL = "https://fake.mktorest.com/rest/v1/activities/pagingtoken.json"
    GET_PAGE_TOKEN_RESPONSE = {
        "requestId": "1607c#14884f3e74e",
        "success": True,
        "nextPageToken": "GIYDAOBNGEYS2MBWKQYDAORQGA5DAMBOGAYDAKZQGAYDALBQ"
    }


class MarketoGetLeadActivitiesMixin(object):
    GET_LEAD_ACTIVITIES_URL = "https://fake.mktorest.com/rest/v1/activities.json"
    GET_LEAD_ACTIVITIES_MULTI_PAGE_RESPONSE_1 = {
        "requestId": "a9ae#148add1e53d",
        "success": True,
        "nextPageToken": "GIYDAOBNGEYS2MBWKQYDAORQGA5DAMBOGAYDAKZQGAYDALBRGA3TQ===",
        "moreResult": True,
        "result": [{
            "id": 2,
            "leadId": 6,
            "activityDate": "2013-09-26T06:56:35+0000",
            "activityTypeId": 12,
            "primaryAttributeValueId": 6,
            "primaryAttributeValue": "Owyliphys Iledil",
            "attributes": [{
                "name": "Source Type",
                "value": "Web page visit"
            }, {
                "name": "Source Info",
                "value": "http://search.yahoo.com/search?p=train+cappuccino+army"
            }]
        }, {
            "id": 3,
            "leadId": 9,
            "activityDate": "2013-12-28T00:39:45+0000",
            "activityTypeId": 1,
            "primaryAttributeValueId": 4,
            "primaryAttributeValue": "anti-phishing",
            "attributes": [{
                "name": "Query Parameters",
                "value": None
            }, {
                "name": "Client IP Address",
                "value": "203.141.7.100"
            }, {
                "name": "User Agent",
                "value": "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14"
            }, {
                "name": "Webpage ID",
                "value": 4
            }, {
                "name": "Webpage URL",
                "value": "/anti-phishing.html"
            }, {
                "name": "Referrer URL",
                "value": None
            }, {
                "name": "Search Engine",
                "value": None
            }, {
                "name": "Search Query",
                "value": None
            }]
        }]
    }
    GET_LEAD_ACTIVITIES_MULTI_PAGE_RESPONSE_2 = {
        # No nextPageToken or the tests will run forever
        "requestId": "a9ae#148add1e53d",
        "success": True,
        "moreResult": True,
        "result": [{
            "id": 2,
            "leadId": 6,
            "activityDate": "2013-09-26T06:56:35+0000",
            "activityTypeId": 12,
            "primaryAttributeValueId": 6,
            "primaryAttributeValue": "Owyliphys Iledil",
            "attributes": [{
                "name": "Source Type",
                "value": "Web page visit"
            }, {
                "name": "Source Info",
                "value": "http://search.yahoo.com/search?p=train+cappuccino+army"
            }]
        }]
    }


class MarketoGetLeadsOnListMixin(object):
    GET_LEADS_ON_LIST_URL = "https://fake.mktorest.com/rest/v1/list/{0}/leads.json"
    GET_LEADS_ON_LIST_MULTI_PAGE_RESPONSE_1 = {
        "requestId": "e42b#14272d07d78",
        "success": True,
        "nextPageToken": "PS5VL5WD4UOWGOUCJR6VY7JQO2KUXL7BGBYXL4XH4BYZVPYSFBAONP4V4KQKN4SSBS55U4LEMAKE6===",
        "result": [{
            "id": 50,
            "email": "kjashaedd@klooblept.com",
            "firstName": "Kataldar",
            "postalCode": "04828"
        }, {
            "id": 2343,
            "email": "kjashaedd@klooblept.com",
            "firstName": "Kataldar",
            "postalCode": "04828"
        }, {
            "id": 88498,
            "email": "kjashaedd@klooblept.com",
            "firstName": "Kataldar",
            "postalCode": "04828"
        }]
    }
    GET_LEADS_ON_LIST_MULTI_PAGE_RESPONSE_2 = {
        # don't use nextPageToken here or tests run infinitely
        "requestId": "e42b#14272d07d78",
        "success": True,
        "result": [{
            "id": 50,
            "email": "kjashaedd@klooblept.com",
            "firstName": "Kataldar",
            "postalCode": "04828"
        }, {
            "id": 2343,
            "email": "kjashaedd@klooblept.com",
            "firstName": "Kataldar",
            "postalCode": "04828"
        }, {
            "id": 88498,
            "email": "kjashaedd@klooblept.com",
            "firstName": "Kataldar",
            "postalCode": "04828"
        }]
    }