示例#1
0
 def _get_api_call(self):
     super_ = \
         super(UnsuccessfulCreatePropertyGroup, self)._get_api_call()
     api_call = UnsuccessfulAPICall.init_from_generalization(
         super_,
         exception=self._exception,
         )
     return api_call
示例#2
0
 def _get_api_call(self):
     super_ = \
         super(UnsuccessfulCreatePropertyGroup, self)._get_api_call()
     api_call = UnsuccessfulAPICall.init_from_generalization(
         super_,
         exception=self._exception,
     )
     return api_call
示例#3
0
    def _get_api_call(self):
        super_ = \
            super(UnsuccessfulCreateStaticContactList, self)._get_api_call()

        api_call = UnsuccessfulAPICall.init_from_generalization(
            super_,
            exception=self._exception,
            )
        return api_call
示例#4
0
    def _get_api_call(self):
        super_ = \
            super(UnsuccessfulCreateStaticContactList, self)._get_api_call()

        api_call = UnsuccessfulAPICall.init_from_generalization(
            super_,
            exception=self._exception,
        )
        return api_call
示例#5
0
    def __call__(self):
        successful_api_call_simulator = self._successful_api_call_simulator

        api_calls = successful_api_call_simulator()

        contacts_by_page = successful_api_call_simulator._objects_by_page
        if contacts_by_page:
            last_api_call = api_calls[-1]
            last_api_call.response_body_deserialization['has-more'] = True

            page_count = len(contacts_by_page)
            unsuccessful_api_call_number = page_count + 1
            unsuccessful_api_call_query_string_args = \
                last_api_call.query_string_args.copy()
            unsuccessful_api_call_pagination_query_string_args = \
                successful_api_call_simulator._get_query_string_args_for_page(
                    unsuccessful_api_call_number,
                    )
            unsuccessful_api_call_query_string_args.update(
                unsuccessful_api_call_pagination_query_string_args,
                )

            unsuccessful_api_call = UnsuccessfulAPICall(
                last_api_call.url_path,
                last_api_call.http_method,
                unsuccessful_api_call_query_string_args,
                exception=self._exception,
                )
        else:
            last_api_call = api_calls.pop()
            unsuccessful_api_call = UnsuccessfulAPICall(
                last_api_call.url_path,
                last_api_call.http_method,
                last_api_call.query_string_args,
                exception=self._exception,
                )

        api_calls.append(unsuccessful_api_call)

        return api_calls
示例#6
0
    def __call__(self):
        api_calls = super(UnsuccessfulSaveContacts, self).__call__()
        if api_calls:
            last_api_call = api_calls.pop()
            unsuccessful_api_call = UnsuccessfulAPICall(
                last_api_call.url_path,
                last_api_call.http_method,
                last_api_call.query_string_args,
                last_api_call.request_body_deserialization,
                exception=self._exception,
            )
            api_calls.append(unsuccessful_api_call)

        return api_calls
示例#7
0
    def __call__(self):
        api_calls = self._available_properties_simulator()

        request_body_deserialization = format_contact_data_for_saving(
                self._contact,
                self._property_type_by_property_name,
        )
        api_call = UnsuccessfulAPICall(
                CONTACTS_API_SCRIPT_NAME + '/contact/',
                'POST',
                request_body_deserialization=request_body_deserialization,
                exception=self._exception
                )
        api_calls.append(api_call)

        return api_calls
示例#8
0
    def test_unsuccessful_api_call(self):
        exception = \
            HubspotAuthenticationError('Must authenticate', get_uuid4_str())
        expected_api_call = UnsuccessfulAPICall(
            _STUB_URL_PATH,
            'GET',
            exception=exception,
        )
        connection = \
            self._make_connection_for_expected_api_call(expected_api_call)

        with assert_raises(type(exception)) as context_manager:
            connection.send_get_request(_STUB_URL_PATH)

        eq_(exception, context_manager.exception)
        self._assert_sole_api_call_equals(expected_api_call, connection)