コード例 #1
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))
コード例 #2
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))
コード例 #3
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, "*****@*****.**")
コード例 #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, "*****@*****.**")