<commit_before># Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
#     http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

require 'spec_helper'
require 'ostruct'

module Seahorse
  module Client
    describe Base do

      let(:api) {{ 'endpoint' => 'http://endpoint:123' }}

      let(:client_class) { Base.define(api: api) }

      let(:client) { client_class.new }

      let(:required_plugins) { Base::REQUIRED_PLUGINS }

      let(:plugin_a) { Class.new }

      let(:plugin_b) { Class.new }

      describe '#config' do

        it 'returns a Configuration object' do
          expect(client.config).to be_kind_of(Configuration)
        end

        it 'contains the client api' do
          expect(client.config.api).to be(client_class.api)
        end

        it 'defaults endpoint to the api endpoint' do
          expect(client.config.endpoint).to eq(api['endpoint'])
        end

        it 'defaults ssl_default to true' do
          expect(client.config.ssl_default).to equal(true)
        end

        it 'passes constructor args to the config' do
          client = client_class.new(foo: 'bar')
          client.config.add_option(:foo)
          expect(client.config.foo).to eq('bar')
        end

      end

      describe '#handlers' do

        it 'returns a HandlerList' do
          expect(client.handlers).to be_kind_of(HandlerList)
        end

        it 'builds a handler list from client plugins' do
          client_class.clear_plugins
          client_class.add_plugin(Plugins::NetHttp)
          expect(client.handlers.to_a).to eq([
            NetHttp::Handler,
            Plugins::Endpoint::EndpointHandler,
          ])
        end

        it 'defaults the send handler to a NetHttp::Handler' do
          expect(client.handlers.first).to be(NetHttp::Handler)
        end

      end

      describe '#build_request' do

        let(:request) { client.build_request('operation') }

        it 'returns a Request' do
          expect(request).to be_kind_of(Request)
        end

        it 'populates the request handlers' do
          expect(request.handlers.to_a).to eq(client.handlers.to_a)
        end

        it 'includes operation specific handlers in the handler list' do
          handler = double('handler')
          client.handlers.add(handler, operations: ['operation'])
          request = client.build_request('operation')
          expect(request.handlers.to_a).to include(handler)
        end

        it 'populates the request context operation name' do
          request = client.build_request('operation_name')
          expect(request.context.operation_name).to eq('operation_name')
        end
<commit_msg>Added placeholder context blocks to Client::Base specs for new functionality coming.<commit_after># Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
#     http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

require 'spec_helper'
require 'ostruct'

module Seahorse
  module Client
    describe Base do

      let(:api) {{ 'endpoint' => 'http://endpoint:123' }}

      let(:client_class) { Base.define(api: api) }

      let(:client) { client_class.new }

      let(:required_plugins) { Base::REQUIRED_PLUGINS }

      let(:plugin_a) { Class.new }

      let(:plugin_b) { Class.new }

      describe '#config' do

        it 'returns a Configuration object' do
          expect(client.config).to be_kind_of(Configuration)
        end

        it 'contains the client api' do
          expect(client.config.api).to be(client_class.api)
        end

        it 'defaults endpoint to the api endpoint' do
          expect(client.config.endpoint).to eq(api['endpoint'])
        end

        it 'defaults ssl_default to true' do
          expect(client.config.ssl_default).to equal(true)
        end

        it 'passes constructor args to the config' do
          client = client_class.new(foo: 'bar')
          client.config.add_option(:foo)
          expect(client.config.foo).to eq('bar')
        end

      end

      describe '#handlers' do

        it 'returns a HandlerList' do
          expect(client.handlers).to be_kind_of(HandlerList)
        end

        it 'builds a handler list from client plugins' do
          client_class.clear_plugins
          client_class.add_plugin(Plugins::NetHttp)
          expect(client.handlers.to_a).to eq([
            NetHttp::Handler,
            Plugins::Endpoint::EndpointHandler,
          ])
        end

        it 'defaults the send handler to a NetHttp::Handler' do
          expect(client.handlers.first).to be(NetHttp::Handler)
        end

      end

      describe '#on_request' do
      end

      describe '#on_response' do
      end

      describe '#around' do
      end

      describe '#build_request' do

        let(:request) { client.build_request('operation') }

        it 'returns a Request' do
          expect(request).to be_kind_of(Request)
        end

        it 'populates the request handlers' do
          expect(request.handlers.to_a).to eq(client.handlers.to_a)
        end

        it 'includes operation specific handlers in the handler list' do
          handler = double('handler')
          client.handlers.add(handler, operations: ['operation'])
          request = client.build_request('operation')
          expect(request.handlers.to_a).to include(handler)
        end

        it 'populates the request context operation name' do
          request = client.build_request('operation_name')
          expect(request.context.operation_name).to eq('operation_name')
        end

{'fraction_non_alphanumeric': 0.09292929292929293, 'fraction_numerical': 0.003418803418803419, 'mean_word_length': 2.4732865623313547, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2116491', 'n_tokens_mistral': 1793, 'n_tokens_neox': 1720, 'n_words': 542}