Sha256: 4899697787d57edc87fc2d7be81c9a54703bf2a039bf8b2c921944499995efd7

Contents?: true

Size: 1.62 KB

Versions: 9

Compression:

Stored size: 1.62 KB

Contents

# Unit tests for Bandwidth::StatisticsApi
describe 'StatisticsApi' do
  # statistics info
  let(:current_call_queue_size) { 0 }
  let(:max_call_queue_size) { 7500 }

  # stubs
  let(:get_statistics_headers_stub) { { 'content-type' => 'application/json' } }
  let(:get_statistics_body_stub) { "{\"currentCallQueueSize\":#{current_call_queue_size},\"maxCallQueueSize\":#{max_call_queue_size}}" }
  
  before(:all) do
    Bandwidth.configure do |config|
      config.debugging = true
    end
    @statistics_api_instance = Bandwidth::StatisticsApi.new
  end

  describe 'test an instance of StatisticsApi' do
    it 'should create an instance of StatisticsApi' do
      expect(@statistics_api_instance).to be_instance_of(Bandwidth::StatisticsApi)
    end
  end

  # Get Account Statistics
  describe 'get_statistics' do
    it 'gets account statistics' do
      stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/statistics").
      to_return(status: 200, headers: get_statistics_headers_stub, body: get_statistics_body_stub)

      data, status_code, headers = @statistics_api_instance.get_statistics_with_http_info(BW_ACCOUNT_ID)

      expect(status_code).to eq(200)
      expect(headers).to eq(get_statistics_headers_stub)
      expect(data).to be_instance_of(Bandwidth::AccountStatistics)
      expect(data.current_call_queue_size).to eq(current_call_queue_size)
      expect(data.max_call_queue_size).to eq(max_call_queue_size)
    end

    it 'causes an ArgumentError for a missing account_id' do
      expect {
        resp = @statistics_api_instance.get_statistics(nil)
      }.to raise_error(ArgumentError)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bandwidth-sdk-11.3.0 spec/api/statistics_api_spec.rb
bandwidth-sdk-11.2.0 spec/api/statistics_api_spec.rb
bandwidth-sdk-11.1.1 spec/api/statistics_api_spec.rb
bandwidth-sdk-11.1.0 spec/api/statistics_api_spec.rb
bandwidth-sdk-11.0.0 spec/api/statistics_api_spec.rb
bandwidth-sdk-11.0.0.pre.beta.4.0 spec/api/statistics_api_spec.rb
bandwidth-sdk-11.0.0.pre.beta.3.1 spec/api/statistics_api_spec.rb
bandwidth-sdk-11.0.0.pre.beta.3.0 spec/api/statistics_api_spec.rb
bandwidth-sdk-11.0.0.pre.beta.2.0 spec/api/statistics_api_spec.rb