Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 107 additions & 63 deletions AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/paging_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,102 +19,146 @@

# Paging happy path tests
it 'should get single pages' do
result = @client.paging.get_single_pages_async().value!
expect(result.response.status).to eq(200)
expect(result.body.next_link).to be_nil
all_items = @client.paging.get_single_pages()
Copy link
Contributor

@vishrutshah vishrutshah Jul 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be also verifying the type of the result (all_items is of type xxx) ? #Closed

Copy link
Contributor Author

@veronicagg veronicagg Jul 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. #Closed

expect(all_items.count).to eq(1)
expect(all_items.is_a? Array)
expect(all_items.first.is_a? PagingModule::Models::Product)
end

it 'should get multiple pages' do
result = @client.paging.get_multiple_pages_async().value!
expect(result.response.status).to eq(200)
expect(result.body.next_link).not_to be_nil

count = 1
while result.body.next_link != nil do
result = @client.paging.get_multiple_pages_next_async(result.body.next_link).value!
count += 1
end
all_items = @client.paging.get_multiple_pages() #returns items from all the pages
items_count = all_items.count
Copy link
Contributor

@vishrutshah vishrutshah Jul 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well & may be for all the tests #Closed

Copy link
Contributor Author

@veronicagg veronicagg Jul 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. #Closed

expect(items_count).to eq(10)
expect(all_items.is_a? Array)
expect(all_items.first.is_a? PagingModule::Models::Product)
end

expect(count).to eq(10)
it 'should get multiple pages - lazy' do
page = @client.paging.get_multiple_pages_as_lazy()
expect(page.is_a? PagingModule::Models::ProductResult)
expect(page.next_link).not_to be_nil
items = page.values
while page.next_link != nil do
page = page.get_next_page
items.concat(page.values)
end
expect(items.count).to eq(10)
end

it 'should get multiple pages with odata kind nextLink' do
result = @client.paging.get_odata_multiple_pages_async().value!
expect(result.response.status).to eq(200)
expect(result.body.odatanext_link).not_to be_nil
it 'should get multiple pages' do
all_items = @client.paging.get_odata_multiple_pages() #returns items from all the pages
items_count = all_items.count
expect(items_count).to eq(10)
expect(all_items.is_a? Array)
expect(all_items.first.is_a? PagingModule::Models::Product)
end

count = 1
while result.body.odatanext_link != nil do
result = @client.paging.get_odata_multiple_pages_next_async(result.body.odatanext_link).value!
count += 1
it 'should get multiple pages with odata - lazy ' do
page = @client.paging.get_odata_multiple_pages_as_lazy()
expect(page.is_a? PagingModule::Models::OdataProductResult)
expect(page.odatanext_link).not_to be_nil
items = page.values
while page.odatanext_link != nil do
page = page.get_next_page
items.concat(page.values)
end

expect(count).to eq(10)
expect(items.count).to eq(10)
end

it 'should get multiple pages with offset' do
options = PagingModule::Models::PagingGetMultiplePagesWithOffsetOptions.new
options.offset = 100
result = @client.paging.get_multiple_pages_with_offset_async(options).value!
expect(result.response.status).to eq(200)
expect(result.body.next_link).not_to be_nil

count = 1
while result.body.next_link != nil do
result = @client.paging.get_multiple_pages_with_offset_next_async(result.body.next_link).value!
count += 1
end
all_items = @client.paging.get_multiple_pages_with_offset(options)
expect(all_items.count).to eq(10)
expect(all_items.is_a? Array)
expect(all_items.first.is_a? PagingModule::Models::Product)
expect(all_items.last.properties.id).to eq (110)
end

expect(count).to eq(10)
expect(result.body.values.last.properties.id).to eq (110)
it 'should get multiple pages with offset - lazy' do
options = PagingModule::Models::PagingGetMultiplePagesWithOffsetOptions.new
options.offset = 100
page = @client.paging.get_multiple_pages_with_offset_as_lazy(options)
expect(page.is_a? PagingModule::Models::ProductResult)
expect(page.next_link).not_to be_nil
items = page.values
while page.next_link != nil do
page = page.get_next_page
items.concat(page.values)
end
expect(items.count).to eq(10)
expect(page.values.last.properties.id).to eq (110)
end

it 'should get multiple pages retry first' do
result = @client.paging.get_multiple_pages_retry_first_async().value!
expect(result.response.status).to eq(200)
expect(result.body.next_link).not_to be_nil

count = 1
while result.body.next_link != nil do
result = @client.paging.get_multiple_pages_retry_first_next_async(result.body.next_link).value!
count += 1
all_items = @client.paging.get_multiple_pages_retry_first()
expect(all_items.count).to eq(10)
expect(all_items.is_a? Array)
expect(all_items.first.is_a? PagingModule::Models::Product)
end

it 'should get multiple pages retry first - lazy' do
page = @client.paging.get_multiple_pages_retry_first_as_lazy
expect(page.is_a? PagingModule::Models::ProductResult)
expect(page.next_link).not_to be_nil
items = page.values
while page.next_link != nil do
page = page.get_next_page
items.concat(page.values)
end
expect(items.count).to eq(10)

expect(count).to eq(10)
end

it 'should get multiple pages retry second' do
result = @client.paging.get_multiple_pages_retry_second_async().value!
expect(result.response.status).to eq(200)
expect(result.body.next_link).not_to be_nil

count = 1
while result.body.next_link != nil do
result = @client.paging.get_multiple_pages_retry_second_next_async(result.body.next_link).value!
count += 1
end
all_items = @client.paging.get_multiple_pages_retry_second()
expect(all_items.count).to eq(10)
expect(all_items.is_a? Array)
expect(all_items.first.is_a? PagingModule::Models::Product)
end

expect(count).to eq(10)
it 'should get multiple pages retry second - lazy' do
page = @client.paging.get_multiple_pages_retry_second_as_lazy
expect(page.is_a? PagingModule::Models::ProductResult)
expect(page.next_link).not_to be_nil
items = page.values
while page.next_link != nil do
page = page.get_next_page
items.concat(page.values)
end
expect(items.count).to eq(10)
end

# Paging sad path tests
it 'should get single pages failure' do
expect { @client.paging.get_single_pages_failure_async().value! }.to raise_exception(MsRest::HttpOperationError)
expect { @client.paging.get_single_pages_failure_as_lazy }.to raise_exception(MsRest::HttpOperationError)
end

it 'should get single pages failure' do
expect { @client.paging.get_single_pages_failure() }.to raise_exception(MsRest::HttpOperationError)
end

it 'should get multiple pages failure' do
result = @client.paging.get_multiple_pages_failure_async().value!
expect(result.response.status).to eq(200)
expect(result.body.next_link).not_to be_nil
expect { @client.paging.get_multiple_pages_failure()}.to raise_exception(MsRest::HttpOperationError)
end

it 'should get multiple pages failure - lazy' do
page = @client.paging.get_multiple_pages_failure_as_lazy
expect(page.is_a? PagingModule::Models::ProductResult)
expect(page.next_link).not_to be_nil

expect { @client.paging.get_multiple_pages_failure_next_async(result.body.next_link).value! }.to raise_exception(MsRest::HttpOperationError)
expect { page.get_next_page }.to raise_exception(MsRest::HttpOperationError)
end

it 'should get multiple pages failure URI' do
result = @client.paging.get_multiple_pages_failure_uri_async().value!
expect(result.response.status).to eq(200)
expect(result.body.next_link).not_to be_nil
expect { @client.paging.get_multiple_pages_failure_uri()}.to raise_exception(MsRest::HttpOperationError)
end

it 'should get multiple pages failure URI - lazy' do
page = @client.paging.get_multiple_pages_failure_uri_as_lazy
expect(page.is_a? PagingModule::Models::ProductResult)
expect(page.next_link).not_to be_nil

expect { @client.paging.get_multiple_pages_failure_uri_next_async(result.body.next_link).value! }.to raise_exception(MsRest::HttpOperationError)
expect { page.get_next_page }.to raise_exception(MsRest::HttpOperationError)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@
<Compile Include="TemplateModels\AzureParameterTemplateModel.cs" />
<Compile Include="TemplateModels\AzureRequirementsTemplateModel.cs" />
<Compile Include="TemplateModels\AzureServiceClientTemplateModel.cs" />
<Compile Include="TemplateModels\PageTemplateModel.cs" />
<Compile Include="Templates\AzureMethodGroupTemplate.cs">
<DependentUpon>AzureMethodGroupTemplate.cshtml</DependentUpon>
</Compile>
<Compile Include="Templates\AzureMethodTemplate.cs">
<DependentUpon>AzureMethodTemplate.cshtml</DependentUpon>
</Compile>
<Compile Include="Templates\PageModelTemplate.cs">
<DependentUpon>PageModelTemplate.cshtml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
Expand All @@ -62,6 +66,7 @@
</ItemGroup>
<ItemGroup>
<None Include="Templates\AzureMethodGroupTemplate.cshtml" />
<None Include="Templates\PageModelTemplate.cshtml" />
<None Include="Templates\AzureMethodTemplate.cshtml" />
</ItemGroup>
<ItemGroup>
Expand Down
Loading