'Verifies that the view contacts the E-Commerce API with the correct data and headers.'

def _test_successful_ecommerce_api_call(self, is_completed=True, utm_tracking_present=False):

    with mock.patch('commerce.api.v0.views.audit_log') as mock_audit_log:
        response = self._post_to_view(include_utm_cookie=utm_tracking_present)
        self.assertTrue(mock_audit_log.called)
    if is_completed:
        msg = Messages.ORDER_COMPLETED.format(order_number=TEST_ORDER_NUMBER)
        self.assertResponseMessage(response, msg)
    else:
        self.assertResponsePaymentData(response)
    self.assertIn('{}=sailthru    id'.format(SAILTHRU_CAMPAIGN_COOKIE), httpretty.last_request().headers['cookie'])
    if utm_tracking_present:
        cookie_string = '{cookie_name}={cookie_contents}'.format(cookie_name=UTM_COOKIE_NAME, cookie_contents=json.dumps(UTM_COOKIE_CONTENTS))
        self.assertIn(cookie_string, httpretty.last_request().headers['cookie'])
