コード例 #1
0
    def test_wrap(self):
        soap_endpoint = "_soap_endpoint_"
        user_id = "_user_id_"
        encryption_key = "_encryption_key_"
        client = Client(soap_endpoint=soap_endpoint,
                        user_id=user_id,
                        encryption_key=encryption_key)
        body = "<body/>"
        header = "<header/>"

        with patch("marketo.auth.header", return_value=header):
            actual_result = client.wrap(body=body)

        self.assertEqual(
            actual_result,
            u'<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
            u'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
            u'xmlns:wsdl="http://www.marketo.com/mktows/" '
            u'xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" '
            u'xmlns:ins0="http://www.marketo.com/mktows/" '
            u'xmlns:ns1="http://www.marketo.com/mktows/" '
            u'xmlns:mkt="http://www.marketo.com/mktows/">'
            u'{header}'
            u'<env:Body>'
            u'{body}'
            u'</env:Body>'
            u'</env:Envelope>'.format(header=header, body=body))
コード例 #2
0
ファイル: test.py プロジェクト: veeloinc/marketo-python
    def test_get_lead_with_found(self):
        soap_endpoint = "_soap_endpoint_"
        user_id = "_user_id_"
        encryption_key = "_encryption_key_"
        client = Client(soap_endpoint=soap_endpoint, user_id=user_id, encryption_key=encryption_key)

        mock_response = Mock(status_code=200, text="<root>"
                                                   "<leadRecord>"
                                                   "<Id>100</Id>"
                                                   "<Email>[email protected]</Email>"
                                                   "</leadRecord>"
                                                   "</root>")
        with patch.object(client, "request", return_value=mock_response):
            lead = client.get_lead(email="*****@*****.**")

        self.assertEqual(lead.id, 100)
        self.assertEqual(lead.email, "*****@*****.**")
コード例 #3
0
ファイル: test.py プロジェクト: veeloinc/marketo-python
    def test_get_lead_with_not_found(self):
        soap_endpoint = "_soap_endpoint_"
        user_id = "_user_id_"
        encryption_key = "_encryption_key_"
        client = Client(soap_endpoint=soap_endpoint, user_id=user_id, encryption_key=encryption_key)

        mock_response = Mock(status_code=0, text="<root>"
                                                 "<detail>"
                                                 "<message>No lead found with IDNUM = 1 (20103)</message>"
                                                 "<code>20103</code>"
                                                 "</detail>"
                                                 "</root>")
        try:
            with patch.object(client, "request", return_value=mock_response):
                client.get_lead(idnum=1)
        except exceptions.MktLeadNotFound as e:
            self.assertEqual(str(e), "No lead found with IDNUM = 1 (20103)")
        except Exception as e:
            self.assertTrue(isinstance(e, exceptions.MktLeadNotFound), repr(e))
コード例 #4
0
    def test_get_lead_with_found(self):
        soap_endpoint = "_soap_endpoint_"
        user_id = "_user_id_"
        encryption_key = "_encryption_key_"
        client = Client(soap_endpoint=soap_endpoint,
                        user_id=user_id,
                        encryption_key=encryption_key)

        mock_response = Mock(status_code=200,
                             text="<root>"
                             "<leadRecord>"
                             "<Id>100</Id>"
                             "<Email>[email protected]</Email>"
                             "</leadRecord>"
                             "</root>")
        with patch.object(client, "request", return_value=mock_response):
            lead = client.get_lead(email="*****@*****.**")

        self.assertEqual(lead.id, 100)
        self.assertEqual(lead.email, "*****@*****.**")
コード例 #5
0
    def test_get_lead_with_not_found(self):
        soap_endpoint = "_soap_endpoint_"
        user_id = "_user_id_"
        encryption_key = "_encryption_key_"
        client = Client(soap_endpoint=soap_endpoint,
                        user_id=user_id,
                        encryption_key=encryption_key)

        mock_response = Mock(
            status_code=0,
            text="<root>"
            "<detail>"
            "<message>No lead found with IDNUM = 1 (20103)</message>"
            "<code>20103</code>"
            "</detail>"
            "</root>")
        try:
            with patch.object(client, "request", return_value=mock_response):
                client.get_lead(idnum=1)
        except exceptions.MktLeadNotFound as e:
            self.assertEqual(str(e), "No lead found with IDNUM = 1 (20103)")
        except Exception as e:
            self.assertTrue(isinstance(e, exceptions.MktLeadNotFound), repr(e))
コード例 #6
0
ファイル: test.py プロジェクト: veeloinc/marketo-python
    def test_wrap(self):
        soap_endpoint = "_soap_endpoint_"
        user_id = "_user_id_"
        encryption_key = "_encryption_key_"
        client = Client(soap_endpoint=soap_endpoint, user_id=user_id, encryption_key=encryption_key)
        body = "<body/>"
        header = "<header/>"

        with patch("marketo.auth.header", return_value=header):
            actual_result = client.wrap(body=body)

        self.assertEqual(actual_result,
                         u'<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
                         u'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
                         u'xmlns:wsdl="http://www.marketo.com/mktows/" '
                         u'xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" '
                         u'xmlns:ins0="http://www.marketo.com/mktows/" '
                         u'xmlns:ns1="http://www.marketo.com/mktows/" '
                         u'xmlns:mkt="http://www.marketo.com/mktows/">'
                         u'{header}'
                         u'<env:Body>'
                         u'{body}'
                         u'</env:Body>'
                         u'</env:Envelope>'.format(header=header, body=body))