diff --git a/.gitignore b/.gitignore index fd17499cc..9b0952418 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,4 @@ gemfiles/Gemfile-1.9.lock .DS_Store .idea/ vendor/bundle -test/.lorem.txt +test/lorem.txt diff --git a/.rubocop.yml b/.rubocop.yml index abd400593..401509725 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,9 +1,23 @@ inherit_from: .rubocop_todo.yml +plugins: + - rubocop-minitest + # Opt-in new cops AllCops: NewCops: enable # +# Minitest +# +# minitest 6 dropped the Object monkeypatch that made bare `foo.must_equal bar` +# resolve, so expectations have to be written as `_(foo).must_equal bar`. +# Enable just the cop that guards that; the rest of the Minitest department is +# not part of this baseline yet. +Minitest: + Enabled: false +Minitest/GlobalExpectations: + Enabled: true +# # Overrides # Layout/HashAlignment: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5e09f1a22..528cb005a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,7 +6,7 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 11 +# Offense count: 14 # Configuration parameters: EnforcedStyle, AllowedGems. # SupportedStyles: Gemfile, gems.rb, gemspec Gemspec/DevelopmentDependencies: @@ -1010,23 +1010,6 @@ Lint/UnusedMethodArgument: - 'lib/fog/openstack/storage/requests/put_object.rb' - 'lib/fog/openstack/workflow/v2.rb' -# Offense count: 13 -Lint/UriEscapeUnescape: - Exclude: - - 'lib/fog/openstack/compute/requests/delete_service.rb' - - 'lib/fog/openstack/compute/requests/disable_service.rb' - - 'lib/fog/openstack/compute/requests/disable_service_log_reason.rb' - - 'lib/fog/openstack/compute/requests/enable_service.rb' - - 'lib/fog/openstack/storage/requests/delete_multiple_objects.rb' - - 'lib/fog/openstack/workflow/v2/requests/delete_action.rb' - - 'lib/fog/openstack/workflow/v2/requests/delete_cron_trigger.rb' - - 'lib/fog/openstack/workflow/v2/requests/delete_environment.rb' - - 'lib/fog/openstack/workflow/v2/requests/delete_workbook.rb' - - 'lib/fog/openstack/workflow/v2/requests/get_action.rb' - - 'lib/fog/openstack/workflow/v2/requests/get_cron_trigger.rb' - - 'lib/fog/openstack/workflow/v2/requests/get_environment.rb' - - 'lib/fog/openstack/workflow/v2/requests/get_workbook.rb' - # Offense count: 19 # This cop supports safe autocorrection (--autocorrect). Lint/UselessAssignment: @@ -1070,7 +1053,7 @@ Lint/Void: Exclude: - 'spec/image_v2_spec.rb' -# Offense count: 133 +# Offense count: 134 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max. Metrics/AbcSize: Exclude: @@ -1191,6 +1174,7 @@ Metrics/AbcSize: - 'spec/shared_context.rb' - 'spec/volume_spec.rb' - 'test/helpers/collection_helper.rb' + - 'test/requests/storage/object_tests.rb' # Offense count: 33 # Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. @@ -1604,6 +1588,18 @@ Style/ClassVars: - 'test/requests/compute/address_tests.rb' - 'test/requests/compute/server_tests.rb' +# Offense count: 6 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +Style/CollectionCompact: + Exclude: + - 'lib/fog/openstack/compute/models/server.rb' + - 'lib/fog/openstack/image/v1/requests/create_image.rb' + - 'lib/fog/openstack/image/v1/requests/update_image.rb' + - 'lib/fog/openstack/storage/models/file.rb' + - 'lib/fog/openstack/storage/requests/get_container.rb' + - 'lib/fog/openstack/storage/requests/get_containers.rb' + # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). Style/CommentedKeyword: @@ -1810,6 +1806,19 @@ Style/HashEachMethods: - 'lib/fog/openstack/network/requests/update_router.rb' - 'test/requests/orchestration/stack_files_util_tests.rb' +# Offense count: 8 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/HashSlice: + Exclude: + - 'lib/fog/openstack/compute/models/address.rb' + - 'lib/fog/openstack/compute/models/key_pair.rb' + - 'lib/fog/openstack/compute/requests/list_images.rb' + - 'lib/fog/openstack/compute/requests/list_images_detail.rb' + - 'lib/fog/openstack/compute/requests/list_servers.rb' + - 'lib/fog/openstack/container_infra/models/bay.rb' + - 'lib/fog/openstack/container_infra/models/cluster.rb' + - 'lib/fog/openstack/image/v2/requests/update_image_member.rb' + # Offense count: 38 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. @@ -1972,6 +1981,16 @@ Style/NumericLiterals: - 'lib/fog/openstack/metering/requests/get_samples.rb' - 'lib/fog/openstack/network.rb' +# Offense count: 8 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'lib/fog/openstack/identity/v3/models/domains.rb' + - 'lib/fog/openstack/identity/v3/models/projects.rb' + # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AlwaysCorrectToMultiline. @@ -2068,14 +2087,19 @@ Style/RandomWithOffset: - 'lib/fog/openstack/volume/v2/requests/get_volume_details.rb' - 'lib/fog/openstack/volume/v3/requests/get_volume_details.rb' -# Offense count: 4 +# Offense count: 29 # This cop supports safe autocorrection (--autocorrect). Style/RedundantBegin: Exclude: - 'lib/fog/openstack/compute/models/image.rb' - 'lib/fog/openstack/compute/models/server.rb' - 'lib/fog/openstack/storage/models/directory.rb' + - 'spec/identity_v3_spec.rb' - 'spec/image_v2_spec.rb' + - 'spec/monitoring_spec.rb' + - 'spec/network_spec.rb' + - 'spec/shared_file_system_spec.rb' + - 'spec/volume_spec.rb' # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). @@ -2175,6 +2199,31 @@ Style/RescueStandardError: - 'spec/identity_v3_spec.rb' - 'spec/image_v2_spec.rb' +# Offense count: 61 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'lib/fog/openstack/compute/models/metadata.rb' + - 'lib/fog/openstack/compute/requests/create_server.rb' + - 'lib/fog/openstack/identity/v2/models/ec2_credentials.rb' + - 'lib/fog/openstack/image/v1/requests/create_image.rb' + - 'lib/fog/openstack/image/v1/requests/update_image.rb' + - 'lib/fog/openstack/network/requests/create_router.rb' + - 'lib/fog/openstack/orchestration/models/stack.rb' + - 'lib/fog/openstack/orchestration/requests/list_events.rb' + - 'lib/fog/openstack/orchestration/requests/list_resources.rb' + - 'spec/identity_v3_spec.rb' + - 'spec/image_v2_spec.rb' + - 'spec/image_v2_upload_spec.rb' + - 'spec/monitoring_spec.rb' + - 'spec/network_spec.rb' + - 'spec/volume_spec.rb' + - 'test/models/compute/security_group_tests.rb' + - 'test/models/compute/server_tests.rb' + - 'test/requests/image/image_tests.rb' + # Offense count: 11 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowModifier. diff --git a/fog-openstack.gemspec b/fog-openstack.gemspec index 2d7a8256a..6b5452eea 100644 --- a/fog-openstack.gemspec +++ b/fog-openstack.gemspec @@ -32,9 +32,11 @@ Gem::Specification.new do |spec| spec.add_development_dependency "mime-types" spec.add_development_dependency "mime-types-data" spec.add_development_dependency 'minitest' + spec.add_development_dependency 'minitest-mock' spec.add_development_dependency 'pry-byebug' spec.add_development_dependency 'rake', '>= 12.3.3' spec.add_development_dependency 'rubocop' + spec.add_development_dependency 'rubocop-minitest' spec.add_development_dependency 'shindo', '~> 0.3' spec.add_development_dependency 'vcr' spec.add_development_dependency 'webmock', '~> 3.16.2' diff --git a/lib/fog/openstack/volume.rb b/lib/fog/openstack/volume.rb index bb738329b..c14b23886 100644 --- a/lib/fog/openstack/volume.rb +++ b/lib/fog/openstack/volume.rb @@ -16,18 +16,23 @@ class Volume < Fog::Service :openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id, :openstack_identity_api_version] - # Fog::OpenStack::Image.new() will return a Fog::OpenStack::Volume::V3 or a Fog::OpenStack::Volume::V2 or a + # Fog::OpenStack::Volume.new() will return a Fog::OpenStack::Volume::V3 or a Fog::OpenStack::Volume::V2 or a # Fog::OpenStack::Volume::V1, choosing the V3 by default, as V2 is deprecated since OpenStackWallaby and V1 is # deprecated since OpenStack Juno def self.new(args = {}) @openstack_auth_uri = URI.parse(args[:openstack_auth_url]) if args[:openstack_auth_url] - if inspect == 'Fog::OpenStack::Volume' - Fog::OpenStack::Volume::V3.new(args) \ - || Fog::OpenStack::Volume::V2.new(args) \ - || Fog::OpenStack::Volume::V1.new(args) - else - super + return super unless inspect == 'Fog::OpenStack::Volume' + + # Each version resolves a different catalog entry: "volumev3", "volumev2" + # and "volume" respectively. Try them newest first and move on when the + # catalog does not advertise one, re-raising when none of them match. + last_error = nil + [V3, V2, V1].each do |version| + return version.new(args) + rescue Fog::OpenStack::Auth::Catalog::ServiceTypeError => e + last_error = e end + raise last_error end end end diff --git a/spec/dns_v2_spec.rb b/spec/dns_v2_spec.rb index a7cf05297..ed351a708 100644 --- a/spec/dns_v2_spec.rb +++ b/spec/dns_v2_spec.rb @@ -22,30 +22,30 @@ begin # create zone example_zone = @service.zones.create(:name => zone_name, :email => "hostmaster@#{zone}") - example_zone.status.must_equal 'PENDING' - example_zone.action.must_equal 'CREATE' + _(example_zone.status).must_equal 'PENDING' + _(example_zone.action).must_equal 'CREATE' example_id = example_zone.id # add a description example_zone.update(:description => zone_description) - example_zone.reload.description.must_equal zone_description + _(example_zone.reload.description).must_equal zone_description # get by ID example_zone_by_id = @service.zones.find_by_id example_id - example_zone_by_id.wont_equal nil - example_zone_by_id.description.must_equal zone_description + _(example_zone_by_id).wont_equal nil + _(example_zone_by_id.description).must_equal zone_description # get by filtering list by name zones = @service.zones.all(:name => zone_name) - zones.length.must_equal 1 - zones.first.id.must_equal example_id + _(zones.length).must_equal 1 + _(zones.first.id).must_equal example_id ensure # delete the zone(s) @service.zones.all(:name => zone_name).each(&:destroy) # check delete action @service.zones.all(:name => zone_name).each do |z| - z.action.must_equal 'DELETE' + _(z.action).must_equal 'DELETE' end end end @@ -75,17 +75,17 @@ # change record host_record.update(:records => records_updated) - host_record.reload.records.must_equal records_updated + _(host_record.reload.records).must_equal records_updated # get by ID host_record_by_id = @service.recordsets.find_by_id(example_id, host_id) - host_record_by_id.wont_equal nil - host_record_by_id.records.must_equal records_updated + _(host_record_by_id).wont_equal nil + _(host_record_by_id.records).must_equal records_updated # get by filtering list by name recordsets = @service.recordsets.all(:zone_id => example_id, :name => recordset_name) - recordsets.length.must_equal 1 - recordsets.first.id.must_equal host_id + _(recordsets.length).must_equal 1 + _(recordsets.first.id).must_equal host_id ensure # delete the recordset(s) @service.recordsets.all(:zone_id => example_id, :name => recordset_name).each(&:destroy) diff --git a/spec/identity_v3_spec.rb b/spec/identity_v3_spec.rb index 3e23178e4..f5cb8db34 100644 --- a/spec/identity_v3_spec.rb +++ b/spec/identity_v3_spec.rb @@ -74,7 +74,7 @@ :openstack_userid => @openstack_vcr.user_id, :openstack_api_key => @openstack_vcr.password ) - @fog.wont_equal nil + _(@fog).wont_equal nil end end end @@ -96,9 +96,9 @@ } @fog2 = Fog::OpenStack::Identity::V3.new(auth_params) - @fog2.wont_equal nil + _(@fog2).wont_equal nil token = @fog2.credentials[:openstack_auth_token] - token.wont_equal nil + _(token).wont_equal nil end end @@ -137,32 +137,32 @@ # We can use the unscoped token to validate the scoped token validated_token = id_v3.tokens.validate(token) - validated_token.wont_equal nil + _(validated_token).wont_equal nil id_v3.tokens.check(token) - proc { id_v3.tokens.check('random-token') }.must_raise Fog::OpenStack::Identity::NotFound + _(proc { id_v3.tokens.check('random-token') }).must_raise Fog::OpenStack::Identity::NotFound end end it "find specific user, lists users" do VCR.use_cassette('idv3_users') do - proc { @service.users.find_by_id 'u-random-blah' }.must_raise Fog::OpenStack::Identity::NotFound + _(proc { @service.users.find_by_id 'u-random-blah' }).must_raise Fog::OpenStack::Identity::NotFound admin_user = @service.users.find_by_name @openstack_vcr.username - admin_user.length.must_equal 1 + _(admin_user.length).must_equal 1 users = @service.users - users.wont_equal nil - users.length.wont_equal 0 + _(users).wont_equal nil + _(users.length).wont_equal 0 users_all = @service.users.all - users_all.wont_equal nil - users_all.length.wont_equal 0 + _(users_all).wont_equal nil + _(users_all.length).wont_equal 0 admin_by_id = @service.users.find_by_id admin_user.first.id - admin_by_id.wont_equal nil + _(admin_by_id).wont_equal nil - @service.users.find_by_name('pimpernel').length.must_equal 0 + _(@service.users.find_by_name('pimpernel').length).must_equal 0 end end @@ -176,42 +176,42 @@ user.destroy end end - @service.users.find_by_name('foobar').length.must_equal 0 - @service.users.find_by_name('baz').length.must_equal 0 + _(@service.users.find_by_name('foobar').length).must_equal 0 + _(@service.users.find_by_name('baz').length).must_equal 0 # Create a user called foobar foobar_user = @service.users.create(:name => 'foobar', :email => 'foobar@example.com', :password => 's3cret!') foobar_id = foobar_user.id - @service.users.find_by_name('foobar').length.must_equal 1 + _(@service.users.find_by_name('foobar').length).must_equal 1 # Rename it to baz and disable it (required so we can delete it) foobar_user.update(:name => 'baz', :enabled => false) - foobar_user.name.must_equal 'baz' + _(foobar_user.name).must_equal 'baz' # Read the user freshly and check the name & enabled state - @service.users.find_by_name('baz').length.must_equal 1 + _(@service.users.find_by_name('baz').length).must_equal 1 baz_user = @service.users.find_by_id foobar_id - baz_user.wont_equal nil - baz_user.name.must_equal 'baz' - baz_user.email.must_equal 'foobar@example.com' - baz_user.enabled.must_equal false + _(baz_user).wont_equal nil + _(baz_user.name).must_equal 'baz' + _(baz_user.email).must_equal 'foobar@example.com' + _(baz_user.enabled).must_equal false # Try to create the user again - proc do + _(proc do @service.users.create(:name => 'baz', :email => 'foobar@example.com', :password => 's3cret!') - end.must_raise Excon::Errors::Conflict + end).must_raise Excon::Errors::Conflict # Delete the user baz_user.destroy # Check that the deletion worked - proc { @service.users.find_by_id foobar_id }.must_raise Fog::OpenStack::Identity::NotFound - @service.users.all.select { |user| %w[foobar baz].include? user.name }.length.must_equal 0 - @service.users.find_by_name('foobar').length.must_equal 0 - @service.users.find_by_name('baz').length.must_equal 0 + _(proc { @service.users.find_by_id foobar_id }).must_raise Fog::OpenStack::Identity::NotFound + _(@service.users.all.select { |user| %w[foobar baz].include? user.name }.length).must_equal 0 + _(@service.users.find_by_name('foobar').length).must_equal 0 + _(@service.users.find_by_name('baz').length).must_equal 0 end end @@ -219,22 +219,22 @@ VCR.use_cassette('idv3_group_crud_mutation') do # Make sure there are no existing groups called foobar or baz @service.groups.all.select { |group| %w[foobar baz].include? group.name }.each(&:destroy) - @service.groups.all.select { |group| %w[foobar baz].include? group.name }.length.must_equal 0 + _(@service.groups.all.select { |group| %w[foobar baz].include? group.name }.length).must_equal 0 # Create a group called foobar foobar_group = @service.groups.create(:name => 'foobar', :description => "Group of Foobar users") foobar_id = foobar_group.id - @service.groups.all.select { |group| group.name == 'foobar' }.length.must_equal 1 + _(@service.groups.all.select { |group| group.name == 'foobar' }.length).must_equal 1 # Rename it to baz foobar_group.update(:name => 'baz', :description => "Group of Baz users") - foobar_group.name.must_equal 'baz' + _(foobar_group.name).must_equal 'baz' # Read the group freshly and check the name - @service.groups.all.select { |group| group.name == 'baz' }.length.must_equal 1 + _(@service.groups.all.select { |group| group.name == 'baz' }.length).must_equal 1 baz_group = @service.groups.find_by_id foobar_id - baz_group.wont_equal nil - baz_group.name.must_equal 'baz' + _(baz_group).wont_equal nil + _(baz_group.name).must_equal 'baz' # Add users to the group foobar_user1 = @service.users.create(:name => 'foobar1', @@ -244,35 +244,35 @@ :email => 'foobar2@example.com', :password => 's3cret!2') - foobar_user1.groups.length.must_equal 0 - baz_group.users.length.must_equal 0 + _(foobar_user1.groups.length).must_equal 0 + _(baz_group.users.length).must_equal 0 baz_group.add_user(foobar_user1.id) # Check that a user is in the group - foobar_user1.groups.length.must_equal 1 - (baz_group.contains_user? foobar_user1.id).must_equal true + _(foobar_user1.groups.length).must_equal 1 + _((baz_group.contains_user? foobar_user1.id)).must_equal true baz_group.add_user(foobar_user2.id) # List users in the group - baz_group.users.length.must_equal 2 + _(baz_group.users.length).must_equal 2 # Remove a user from the group baz_group.remove_user(foobar_user1.id) - (baz_group.contains_user? foobar_user1.id).must_equal false - baz_group.users.length.must_equal 1 + _((baz_group.contains_user? foobar_user1.id)).must_equal false + _(baz_group.users.length).must_equal 1 # Delete the users and make sure they are no longer in the group foobar_user1.destroy foobar_user2.destroy - (baz_group.contains_user? foobar_user2.id).must_equal false - baz_group.users.length.must_equal 0 + _((baz_group.contains_user? foobar_user2.id)).must_equal false + _(baz_group.users.length).must_equal 0 # Delete the group baz_group.destroy - proc { @service.groups.find_by_id foobar_id }.must_raise Fog::OpenStack::Identity::NotFound - @service.groups.all.select { |group| %w[foobar baz].include? group.name }.length.must_equal 0 + _(proc { @service.groups.find_by_id foobar_id }).must_raise Fog::OpenStack::Identity::NotFound + _(@service.groups.all.select { |group| %w[foobar baz].include? group.name }.length).must_equal 0 end end @@ -301,15 +301,15 @@ } token = @service.tokens.authenticate(auth) - token.wont_equal nil + _(token).wont_equal nil validated_token = @service.tokens.validate token.value - validated_token.wont_equal nil + _(validated_token).wont_equal nil @service.tokens.check(token.value) @service.tokens.revoke(token.value) - proc { @service.tokens.check(token.value) }.must_raise Fog::OpenStack::Identity::NotFound + _(proc { @service.tokens.check(token.value) }).must_raise Fog::OpenStack::Identity::NotFound end end @@ -344,15 +344,15 @@ :openstack_auth_url => auth_url ) - token_check.wont_equal nil + _(token_check).wont_equal nil - proc do + _(proc do Fog::OpenStack::Identity::V3.new( :openstack_auth_token => 'blahblahblah', :openstack_region => @openstack_vcr.region, :openstack_auth_url => auth_url ) - end.must_raise Excon::Errors::NotFound + end).must_raise Excon::Errors::NotFound ensure # Clean up foobar_user ||= @service.users.find_by_name('foobar_385').first @@ -366,17 +366,17 @@ it "lists domains" do VCR.use_cassette('idv3_domain') do domains = @service.domains - domains.wont_equal nil - domains.length.wont_equal 0 + _(domains).wont_equal nil + _(domains.length).wont_equal 0 domains_all = @service.domains.all - domains_all.wont_equal nil - domains_all.length.wont_equal 0 + _(domains_all).wont_equal nil + _(domains_all.length).wont_equal 0 default_domain = @service.domains.find_by_id @openstack_vcr.domain_id - default_domain.wont_equal nil + _(default_domain).wont_equal nil - proc { @service.domains.find_by_id 'atlantis' }.must_raise Fog::OpenStack::Identity::NotFound + _(proc { @service.domains.find_by_id 'atlantis' }).must_raise Fog::OpenStack::Identity::NotFound end end @@ -386,18 +386,18 @@ # Create a domain called foobar foobar_domain = @service.domains.create(:name => 'foobar') foobar_id = foobar_domain.id - @service.domains.all(:name => 'foobar').length.must_equal 1 + _(@service.domains.all(:name => 'foobar').length).must_equal 1 # Rename it to baz and disable it (required so we can delete it) foobar_domain.update(:name => 'baz', :enabled => false) - foobar_domain.name.must_equal 'baz' + _(foobar_domain.name).must_equal 'baz' # Read the domain freshly and check the name & enabled state - @service.domains.all(:name => 'baz').length.must_equal 1 + _(@service.domains.all(:name => 'baz').length).must_equal 1 baz_domain = @service.domains.find_by_id foobar_id - baz_domain.wont_equal nil - baz_domain.name.must_equal 'baz' - baz_domain.enabled.must_equal false + _(baz_domain).wont_equal nil + _(baz_domain.name).must_equal 'baz' + _(baz_domain.enabled).must_equal false ensure # Delete the domains begin @@ -412,9 +412,9 @@ rescue end # Check that the deletion worked - proc { @service.domains.find_by_id foobar_id }.must_raise Fog::OpenStack::Identity::NotFound if foobar_id + _(proc { @service.domains.find_by_id foobar_id }).must_raise Fog::OpenStack::Identity::NotFound if foobar_id %w[foobar baz].each do |domain_name| - @service.domains.all(:name => domain_name).length.must_equal 0 + _(@service.domains.all(:name => domain_name).length).must_equal 0 end end end @@ -430,29 +430,29 @@ :password => 's3cret!') # User has no roles initially - foobar_user.roles.length.must_equal 0 + _(foobar_user.roles.length).must_equal 0 # Create a role and add it to the user in the user's domain foobar_role = @service.roles.create(:name => 'foobar_role') foobar_user.grant_role(foobar_role.id) - foobar_user.roles.length.must_equal 1 + _(foobar_user.roles.length).must_equal 1 assignments = @service.role_assignments.all(:user_id => foobar_user.id) - assignments.length.must_equal 1 - assignments.first.role['id'].must_equal foobar_role.id - assignments.first.user['id'].must_equal foobar_user.id - assignments.first.scope['domain']['id'].must_equal foobar_user.domain_id - assignments.first.links['assignment'].must_match %r{/v3/domains/#{foobar_user.domain_id}/users/#{foobar_user.id}/roles/#{foobar_role.id}} + _(assignments.length).must_equal 1 + _(assignments.first.role['id']).must_equal foobar_role.id + _(assignments.first.user['id']).must_equal foobar_user.id + _(assignments.first.scope['domain']['id']).must_equal foobar_user.domain_id + _(assignments.first.links['assignment']).must_match %r{/v3/domains/#{foobar_user.domain_id}/users/#{foobar_user.id}/roles/#{foobar_role.id}} # Quick test of @service.role_assignments.all while we're at it all_assignments = @service.role_assignments.all - all_assignments.length.must_be :>, 0 + _(all_assignments.length).must_be :>, 0 # Check that the user has the role - foobar_user.check_role(foobar_role.id).must_equal true + _(foobar_user.check_role(foobar_role.id)).must_equal true # Revoke the role from the user foobar_user.revoke_role(foobar_role.id) - foobar_user.check_role(foobar_role.id).must_equal false + _(foobar_user.check_role(foobar_role.id)).must_equal false ensure foobar_user ||= @service.users.find_by_name('foobar_role_user').first foobar_user.destroy if foobar_user @@ -481,39 +481,39 @@ :domain_id => foobar_domain.id) # User has no roles initially - foobar_user.roles.length.must_equal 0 + _(foobar_user.roles.length).must_equal 0 # Create a role and add it to the domain group foobar_role = @service.roles.all.select { |role| role.name == 'foobar_role' }.first foobar_role.destroy if foobar_role foobar_role = @service.roles.create(:name => 'foobar_role') foobar_group.grant_role foobar_role.id - foobar_group.roles.length.must_equal 1 + _(foobar_group.roles.length).must_equal 1 # Add user to the group and check that it inherits the role - foobar_user.check_role foobar_role.id.wont_equal nil - @service.role_assignments.all(:user_id => foobar_user.id, :effective => true).length.must_equal 0 + foobar_user.check_role _(foobar_role.id).wont_equal nil + _(@service.role_assignments.all(:user_id => foobar_user.id, :effective => true).length).must_equal 0 foobar_group.add_user foobar_user.id - foobar_user.check_role(foobar_role.id).must_equal false # Still false in absolute assignment terms + _(foobar_user.check_role(foobar_role.id)).must_equal false # Still false in absolute assignment terms assignments = @service.role_assignments.all(:user_id => foobar_user.id, :effective => true) - assignments.length.must_equal 1 - assignments.first.role['id'].must_equal foobar_role.id - assignments.first.user['id'].must_equal foobar_user.id - assignments.first.scope['domain']['id'].must_equal foobar_user.domain_id - assignments.first.links['assignment'].must_match %r{/v3/domains/#{foobar_domain.id}/groups/#{foobar_group.id}/roles/#{foobar_role.id}} - assignments.first.links['membership'].must_match %r{/v3/groups/#{foobar_group.id}/users/#{foobar_user.id}} + _(assignments.length).must_equal 1 + _(assignments.first.role['id']).must_equal foobar_role.id + _(assignments.first.user['id']).must_equal foobar_user.id + _(assignments.first.scope['domain']['id']).must_equal foobar_user.domain_id + _(assignments.first.links['assignment']).must_match %r{/v3/domains/#{foobar_domain.id}/groups/#{foobar_group.id}/roles/#{foobar_role.id}} + _(assignments.first.links['membership']).must_match %r{/v3/groups/#{foobar_group.id}/users/#{foobar_user.id}} group_assignments = @service.role_assignments.all(:group_id => foobar_group.id) - group_assignments.length.must_equal 1 - group_assignments.first.role['id'].must_equal foobar_role.id - group_assignments.first.group['id'].must_equal foobar_group.id - group_assignments.first.scope['domain']['id'].must_equal foobar_user.domain_id - group_assignments.first.links['assignment'].must_match %r{/v3/domains/#{foobar_domain.id}/groups/#{foobar_group.id}/roles/#{foobar_role.id}} + _(group_assignments.length).must_equal 1 + _(group_assignments.first.role['id']).must_equal foobar_role.id + _(group_assignments.first.group['id']).must_equal foobar_group.id + _(group_assignments.first.scope['domain']['id']).must_equal foobar_user.domain_id + _(group_assignments.first.links['assignment']).must_match %r{/v3/domains/#{foobar_domain.id}/groups/#{foobar_group.id}/roles/#{foobar_role.id}} # Revoke the role from the group and check the user no longer has it foobar_group.revoke_role foobar_role.id - @service.role_assignments.all(:user_id => foobar_user.id, :effective => true).length.must_equal 0 + _(@service.role_assignments.all(:user_id => foobar_user.id, :effective => true).length).must_equal 0 ensure # Clean up foobar_user ||= @service.users.find_by_name('u-foobar_foobar').first @@ -534,17 +534,17 @@ it "lists roles" do VCR.use_cassette('idv3_role') do roles = @service.roles - roles.wont_equal nil - roles.length.wont_equal 0 + _(roles).wont_equal nil + _(roles.length).wont_equal 0 roles_all = @service.roles.all - roles_all.wont_equal nil - roles_all.length.wont_equal 0 + _(roles_all).wont_equal nil + _(roles_all.length).wont_equal 0 role_by_id = @service.roles.find_by_id roles_all.first.id - role_by_id.wont_equal nil + _(role_by_id).wont_equal nil - proc { @service.roles.find_by_id 'atlantis' }.must_raise Fog::OpenStack::Identity::NotFound + _(proc { @service.roles.find_by_id 'atlantis' }).must_raise Fog::OpenStack::Identity::NotFound end end @@ -554,23 +554,23 @@ # Create a role called foobar foobar_role = @service.roles.create(:name => 'foobar23') foobar_id = foobar_role.id - @service.roles.all(:name => 'foobar23').length.must_equal 1 + _(@service.roles.all(:name => 'foobar23').length).must_equal 1 # Rename it to baz foobar_role.update(:name => 'baz23') - foobar_role.name.must_equal 'baz23' + _(foobar_role.name).must_equal 'baz23' # Read the role freshly and check the name & enabled state - @service.roles.all(:name => 'baz23').length.must_equal 1 + _(@service.roles.all(:name => 'baz23').length).must_equal 1 baz_role = @service.roles.find_by_id foobar_id - baz_role.wont_equal nil - baz_role.name.must_equal 'baz23' + _(baz_role).wont_equal nil + _(baz_role.name).must_equal 'baz23' baz_role.destroy baz_role = nil # Check that the deletion worked - proc { @service.roles.find_by_id foobar_id }.must_raise Fog::OpenStack::Identity::NotFound if foobar_id + _(proc { @service.roles.find_by_id foobar_id }).must_raise Fog::OpenStack::Identity::NotFound if foobar_id %w[foobar23 baz23].each do |role_name| - @service.roles.all(:name => role_name).length.must_equal 0 + _(@service.roles.all(:name => role_name).length).must_equal 0 end ensure # Delete the roles @@ -585,17 +585,17 @@ it "lists projects" do VCR.use_cassette('idv3_project') do projects = @service.projects - projects.wont_equal nil + _(projects).wont_equal nil # TO DO: fix along the two other skipped tests # projects.length.wont_equal 0 projects_all = @service.projects.all - projects_all.wont_equal nil - projects_all.length.wont_equal 0 + _(projects_all).wont_equal nil + _(projects_all.length).wont_equal 0 project_byid = @service.projects.find_by_id projects_all.first.id - project_byid.wont_equal nil + _(project_byid).wont_equal nil - proc { @service.projects.find_by_id 'atlantis' }.must_raise Fog::OpenStack::Identity::NotFound + _(proc { @service.projects.find_by_id 'atlantis' }).must_raise Fog::OpenStack::Identity::NotFound end end @@ -607,27 +607,27 @@ # Create a project called foobar - should not work without domain id? foobar_project = @service.projects.create(:name => 'p-foobar46') foobar_id = foobar_project.id - @service.projects.all(:name => 'p-foobar46').length.must_equal 1 - foobar_project.domain_id.must_equal default_domain.id + _(@service.projects.all(:name => 'p-foobar46').length).must_equal 1 + _(foobar_project.domain_id).must_equal default_domain.id # Rename it to baz and disable it (required so we can delete it) foobar_project.update(:name => 'p-baz46', :enabled => false) - foobar_project.name.must_equal 'p-baz46' + _(foobar_project.name).must_equal 'p-baz46' # Read the project freshly and check the name & enabled state - @service.projects.all(:name => 'p-baz46').length.must_equal 1 + _(@service.projects.all(:name => 'p-baz46').length).must_equal 1 baz_project = @service.projects.find_by_id foobar_id - baz_project.wont_equal nil - baz_project.name.must_equal 'p-baz46' - baz_project.enabled.must_equal false + _(baz_project).wont_equal nil + _(baz_project.name).must_equal 'p-baz46' + _(baz_project.enabled).must_equal false ensure # Delete the project baz_project.destroy # Check that the deletion worked - proc { @service.projects.find_by_id foobar_id }.must_raise Fog::OpenStack::Identity::NotFound + _(proc { @service.projects.find_by_id foobar_id }).must_raise Fog::OpenStack::Identity::NotFound ['p-foobar46', 'p-baz46'].each do |project_name| - @service.projects.all(:name => project_name).length.must_equal 0 + _(@service.projects.all(:name => project_name).length).must_equal 0 end end end @@ -644,12 +644,12 @@ baz_project = @service.projects.create(:name => 'p-baz67', :parent_id => foobar_id) baz_id = baz_project.id - baz_project.parent_id.must_equal foobar_id + _(baz_project.parent_id).must_equal foobar_id # Read the project freshly and check the parent_id fresh_baz_project = @service.projects.all(:name => 'p-baz67').first - fresh_baz_project.wont_equal nil - fresh_baz_project.parent_id.must_equal foobar_id + _(fresh_baz_project).wont_equal nil + _(fresh_baz_project.parent_id).must_equal foobar_id # Create another sub-project called boo boo_project = @service.projects.create(:name => 'p-boo67', :parent_id => foobar_id) @@ -667,41 +667,41 @@ # Get the children of foobar, as a tree of IDs foobar_kids = @service.projects.find_by_id(foobar_id, :subtree_as_ids).subtree - foobar_kids.keys.length.must_equal 2 + _(foobar_kids.keys.length).must_equal 2 boo_index = foobar_kids.keys.index boo_id - boo_index.wont_equal nil + _(boo_index).wont_equal nil foobar_child_id = foobar_kids.keys[boo_index] - foobar_kids[foobar_child_id].length.must_equal 1 + _(foobar_kids[foobar_child_id].length).must_equal 1 foobar_grandchild_id = foobar_kids[foobar_child_id].keys.first - foobar_grandchild_id.must_equal booboo_id + _(foobar_grandchild_id).must_equal booboo_id # Get the children of foobar, as a list of objects foobar_kids = @service.projects.find_by_id(foobar_id, :subtree_as_list).subtree - foobar_kids.length.must_equal 3 - [foobar_kids[0].id, foobar_kids[1].id, foobar_kids[2].id].sort.must_equal [baz_id, boo_id, booboo_id].sort + _(foobar_kids.length).must_equal 3 + _([foobar_kids[0].id, foobar_kids[1].id, foobar_kids[2].id].sort).must_equal [baz_id, boo_id, booboo_id].sort # Create a another sub-project of boo called fooboo and check that it appears in the parent's subtree fooboo_project = @service.projects.create(:name => 'p-fooboo67', :parent_id => boo_id) fooboo_id = fooboo_project.id fooboo_project.grant_role_to_user(prj_role.id, @service.current_user_id) foobar_new_kids = @service.projects.find_by_id(foobar_id, :subtree_as_list).subtree - foobar_new_kids.length.must_equal 4 + _(foobar_new_kids.length).must_equal 4 # Get the parents of booboo, as a tree of IDs booboo_parents = @service.projects.find_by_id(booboo_id, :parents_as_ids).parents - booboo_parents.keys.length.must_equal 1 + _(booboo_parents.keys.length).must_equal 1 booboo_parent_id = booboo_parents.keys.first - booboo_parents[booboo_parent_id].length.must_equal 1 + _(booboo_parents[booboo_parent_id].length).must_equal 1 booboo_grandparent_id = booboo_parents[booboo_parent_id].keys.first - booboo_grandparent_id.must_equal foobar_id + _(booboo_grandparent_id).must_equal foobar_id assert_nil booboo_parents[booboo_parent_id][booboo_grandparent_id] # Get the parents of booboo, as a list of objects booboo_parents = @service.projects.find_by_id(booboo_id, :parents_as_list).parents - booboo_parents.length.must_equal 2 - [booboo_parents[0].id, booboo_parents[1].id].sort.must_equal [foobar_id, boo_id].sort + _(booboo_parents.length).must_equal 2 + _([booboo_parents[0].id, booboo_parents[1].id].sort).must_equal [foobar_id, boo_id].sort ensure # Delete the projects fooboo_project.destroy if fooboo_project @@ -712,11 +712,11 @@ prj_role ||= @service.roles.all(:name => 'r-project67').first prj_role.destroy if prj_role # Check that the deletion worked - proc { @service.projects.find_by_id foobar_id }.must_raise Fog::OpenStack::Identity::NotFound if foobar_id + _(proc { @service.projects.find_by_id foobar_id }).must_raise Fog::OpenStack::Identity::NotFound if foobar_id ['p-booboo67', 'p-fooboo67', 'p-boo67', 'p-baz67', 'p-foobar67'].each do |project_name| prj = @service.projects.all(:name => project_name).first prj.destroy if prj - @service.projects.all(:name => project_name).length.must_equal 0 + _(@service.projects.all(:name => project_name).length).must_equal 0 end end end @@ -729,7 +729,7 @@ project.update(:enabled => false) project.destroy end - @service.projects.all(:name => 'p-foobar69').length.must_equal 0 + _(@service.projects.all(:name => 'p-foobar69').length).must_equal 0 begin # Create a project called foobar @@ -752,53 +752,53 @@ foobar_group.add_user foobar_user.id # User has no projects initially - foobar_user.projects.length.must_equal 0 - @service.role_assignments.all(:user_id => foobar_user.id, - :project_id => foobar_project.id, - :effective => true).length.must_equal 0 - foobar_project.user_roles(foobar_user.id).length.must_equal 0 + _(foobar_user.projects.length).must_equal 0 + _(@service.role_assignments.all(:user_id => foobar_user.id, + :project_id => foobar_project.id, + :effective => true).length).must_equal 0 + _(foobar_project.user_roles(foobar_user.id).length).must_equal 0 # Grant role to the user in the new project - this assigns the project to the user foobar_project.grant_role_to_user(baz_role.id, foobar_user.id) - foobar_user.projects.length.must_equal 1 - foobar_project.check_user_role(foobar_user.id, baz_role.id).must_equal true - foobar_project.user_roles(foobar_user.id).length.must_equal 1 + _(foobar_user.projects.length).must_equal 1 + _(foobar_project.check_user_role(foobar_user.id, baz_role.id)).must_equal true + _(foobar_project.user_roles(foobar_user.id).length).must_equal 1 # Revoke role from the user in the new project - this removes the user from the project foobar_project.revoke_role_from_user(baz_role.id, foobar_user.id) - foobar_user.projects.length.must_equal 0 - foobar_project.check_user_role(foobar_user.id, baz_role.id).must_equal false + _(foobar_user.projects.length).must_equal 0 + _(foobar_project.check_user_role(foobar_user.id, baz_role.id)).must_equal false # Group initially has no roles in project - foobar_project.group_roles(foobar_group.id).length.must_equal 0 + _(foobar_project.group_roles(foobar_group.id).length).must_equal 0 - @service.role_assignments.all(:user_id => foobar_user.id, - :project_id => foobar_project.id, - :effective => true).length.must_equal 0 + _(@service.role_assignments.all(:user_id => foobar_user.id, + :project_id => foobar_project.id, + :effective => true).length).must_equal 0 # Grant role to the group in the new project - this assigns the project to the group foobar_project.grant_role_to_group(baz_role.id, foobar_group.id) - foobar_project.check_group_role(foobar_group.id, baz_role.id).must_equal true - foobar_project.group_roles(foobar_group.id).length.must_equal 1 + _(foobar_project.check_group_role(foobar_group.id, baz_role.id)).must_equal true + _(foobar_project.group_roles(foobar_group.id).length).must_equal 1 # Now we check that a user has the role in that project assignments = @service.role_assignments.all(:user_id => foobar_user.id, :project_id => foobar_project.id, :effective => true) - assignments.length.must_equal 1 - assignments.first.role['id'].must_equal baz_role.id - assignments.first.user['id'].must_equal foobar_user.id - assignments.first.scope['project']['id'].must_equal foobar_project.id - assignments.first.links['assignment'].must_match %r{/v3/projects/#{foobar_project.id}/groups/#{foobar_group.id}/roles/#{baz_role.id}} - assignments.first.links['membership'].must_match %r{/v3/groups/#{foobar_group.id}/users/#{foobar_user.id}} + _(assignments.length).must_equal 1 + _(assignments.first.role['id']).must_equal baz_role.id + _(assignments.first.user['id']).must_equal foobar_user.id + _(assignments.first.scope['project']['id']).must_equal foobar_project.id + _(assignments.first.links['assignment']).must_match %r{/v3/projects/#{foobar_project.id}/groups/#{foobar_group.id}/roles/#{baz_role.id}} + _(assignments.first.links['membership']).must_match %r{/v3/groups/#{foobar_group.id}/users/#{foobar_user.id}} # and we check that the user is in the project because of group membership - foobar_user.projects.length.must_equal 1 + _(foobar_user.projects.length).must_equal 1 # Revoke role from the group in the new project - this removes the group from the project foobar_project.revoke_role_from_group(baz_role.id, foobar_group.id) - foobar_user.projects.length.must_equal 0 - foobar_project.check_group_role(foobar_group.id, baz_role.id).must_equal false + _(foobar_user.projects.length).must_equal 0 + _(foobar_project.check_group_role(foobar_group.id, baz_role.id)).must_equal false ensure # Clean up foobar_user.destroy if foobar_user @@ -815,17 +815,17 @@ it "lists services" do VCR.use_cassette('idv3_service') do services = @service.services - services.wont_equal nil - services.length.wont_equal 0 + _(services).wont_equal nil + _(services.length).wont_equal 0 services_all = @service.services.all - services_all.wont_equal nil - services_all.length.wont_equal 0 + _(services_all).wont_equal nil + _(services_all.length).wont_equal 0 some_service = @service.services.find_by_id services_all.first.id - some_service.wont_equal nil + _(some_service).wont_equal nil - proc { @service.services.find_by_id 'atlantis' }.must_raise Fog::OpenStack::Identity::NotFound + _(proc { @service.services.find_by_id 'atlantis' }).must_raise Fog::OpenStack::Identity::NotFound end end @@ -837,25 +837,25 @@ # Create a service called foobar foobar_service = @service.services.create(:type => 'volume', :name => 'foobar') foobar_id = foobar_service.id - @service.services.all(:type => 'volume').select { |service| service.name == 'foobar' }.length.must_equal 1 + _(@service.services.all(:type => 'volume').select { |service| service.name == 'foobar' }.length).must_equal 1 # Rename it to baz foobar_service.update(:name => 'baz') - foobar_service.name.must_equal 'baz' + _(foobar_service.name).must_equal 'baz' # Read the service freshly and check the name - @service.services.all.select { |service| service.name == 'baz' }.length.must_equal 1 + _(@service.services.all.select { |service| service.name == 'baz' }.length).must_equal 1 baz_service = @service.services.find_by_id foobar_id - baz_service.wont_equal nil - baz_service.name.must_equal 'baz' - baz_service.type.must_equal 'volume' + _(baz_service).wont_equal nil + _(baz_service.name).must_equal 'baz' + _(baz_service.type).must_equal 'volume' ensure # Delete the service baz_service.destroy if baz_service # Check that the deletion worked - proc { @service.services.find_by_id foobar_id }.must_raise Fog::OpenStack::Identity::NotFound if foobar_id - @service.services.all.select { |service| %w[foobar baz].include? service.name }.length.must_equal 0 + _(proc { @service.services.find_by_id foobar_id }).must_raise Fog::OpenStack::Identity::NotFound if foobar_id + _(@service.services.all.select { |service| %w[foobar baz].include? service.name }.length).must_equal 0 end end end @@ -863,17 +863,17 @@ it "lists endpoints" do VCR.use_cassette('idv3_endpoint') do endpoints = @service.endpoints - endpoints.wont_equal nil - endpoints.length.wont_equal 0 + _(endpoints).wont_equal nil + _(endpoints.length).wont_equal 0 endpoints_all = @service.endpoints.all - endpoints_all.wont_equal nil - endpoints_all.length.wont_equal 0 + _(endpoints_all).wont_equal nil + _(endpoints_all.length).wont_equal 0 some_endpoint = @service.endpoints.find_by_id endpoints_all.first.id - some_endpoint.wont_equal nil + _(some_endpoint).wont_equal nil - proc { @service.endpoints.find_by_id 'atlantis' }.must_raise Fog::OpenStack::Identity::NotFound + _(proc { @service.endpoints.find_by_id 'atlantis' }).must_raise Fog::OpenStack::Identity::NotFound end end @@ -890,31 +890,31 @@ :url => 'http://example.com/foobar', :enabled => false) foobar_id = foobar_endpoint.id - @service.endpoints.all(:interface => 'internal').select do |endpoint| + _(@service.endpoints.all(:interface => 'internal').select do |endpoint| endpoint.name == 'foobar' - end.length.must_equal 1 + end.length).must_equal 1 # Rename it to baz foobar_endpoint.update(:name => 'baz', :url => 'http://example.com/baz') - foobar_endpoint.name.must_equal 'baz' - foobar_endpoint.url.must_equal 'http://example.com/baz' + _(foobar_endpoint.name).must_equal 'baz' + _(foobar_endpoint.url).must_equal 'http://example.com/baz' # Read the endpoint freshly and check the name - @service.endpoints.all(:interface => 'internal').select do |endpoint| + _(@service.endpoints.all(:interface => 'internal').select do |endpoint| endpoint.name == 'baz' - end.length.must_equal 1 + end.length).must_equal 1 baz_endpoint = @service.endpoints.find_by_id foobar_id - baz_endpoint.wont_equal nil - baz_endpoint.name.must_equal 'baz' - baz_endpoint.url.must_equal 'http://example.com/baz' - baz_endpoint.interface.must_equal 'internal' + _(baz_endpoint).wont_equal nil + _(baz_endpoint.name).must_equal 'baz' + _(baz_endpoint.url).must_equal 'http://example.com/baz' + _(baz_endpoint.interface).must_equal 'internal' ensure # Delete the endpoint baz_endpoint.destroy # Check that the deletion worked - proc { @service.endpoints.find_by_id foobar_id }.must_raise Fog::OpenStack::Identity::NotFound - @service.endpoints.all.select { |endpoint| %w[foobar baz].include? endpoint.name }.length.must_equal 0 + _(proc { @service.endpoints.find_by_id foobar_id }).must_raise Fog::OpenStack::Identity::NotFound + _(@service.endpoints.all.select { |endpoint| %w[foobar baz].include? endpoint.name }.length).must_equal 0 end end end @@ -922,12 +922,12 @@ it "lists OS credentials" do VCR.use_cassette('idv3_credential') do credentials = @service.os_credentials - credentials.wont_equal nil + _(credentials).wont_equal nil credentials_all = @service.os_credentials.all - credentials_all.wont_equal nil + _(credentials_all).wont_equal nil - proc { @service.os_credentials.find_by_id 'atlantis' }.must_raise Fog::OpenStack::Identity::NotFound + _(proc { @service.os_credentials.find_by_id 'atlantis' }).must_raise Fog::OpenStack::Identity::NotFound end end @@ -951,9 +951,9 @@ @service.os_credentials.all.select do |credential| credential.type == 'foo' || credential.type == 'ec2' end.each(&:destroy) - @service.os_credentials.all.select do |credential| + _(@service.os_credentials.all.select do |credential| credential.type == 'ec2' - end.length.must_equal 0 + end.length).must_equal 0 # Create a credential foo_credential = @service.os_credentials.create(:type => 'ec2', @@ -961,21 +961,21 @@ :user_id => foobar_user.id, :blob => blob_json) credential_id = foo_credential.id - @service.os_credentials.all.select { |credential| credential.type == 'ec2' }.length.must_equal 1 + _(@service.os_credentials.all.select { |credential| credential.type == 'ec2' }.length).must_equal 1 # Update secret key new_secret_key = '62307bcd-ca3c-47ae-a114-27a6cadb5bc9' new_blob_json = {:access => access_key, :secret => new_secret_key}.to_json foo_credential.update(:blob => new_blob_json) - JSON.parse(foo_credential.blob)['secret'].must_equal new_secret_key + _(JSON.parse(foo_credential.blob)['secret']).must_equal new_secret_key # Read the credential freshly and check the secret key - @service.os_credentials.all.select { |credential| credential.type == 'ec2' }.length.must_equal 1 + _(@service.os_credentials.all.select { |credential| credential.type == 'ec2' }.length).must_equal 1 updated_credential = @service.os_credentials.find_by_id credential_id - updated_credential.wont_equal nil - updated_credential.type.must_equal 'ec2' - JSON.parse(updated_credential.blob)['secret'].must_equal new_secret_key + _(updated_credential).wont_equal nil + _(updated_credential.type).must_equal 'ec2' + _(JSON.parse(updated_credential.blob)['secret']).must_equal new_secret_key ensure foobar_user ||= @service.users.find_by_name('u-foobar_cred').first foobar_user.destroy if foobar_user @@ -989,9 +989,9 @@ # Check that the deletion worked if credential_id - proc { @service.os_credentials.find_by_id credential_id }.must_raise Fog::OpenStack::Identity::NotFound + _(proc { @service.os_credentials.find_by_id credential_id }).must_raise Fog::OpenStack::Identity::NotFound end - @service.os_credentials.all.select { |credential| credential.type == 'ec2' }.length.must_equal 0 + _(@service.os_credentials.all.select { |credential| credential.type == 'ec2' }.length).must_equal 0 end end end @@ -999,14 +999,14 @@ it "lists policies" do VCR.use_cassette('idv3_policy') do policies = @service.policies - policies.wont_equal nil - policies.length.must_equal 0 + _(policies).wont_equal nil + _(policies.length).must_equal 0 policies_all = @service.policies.all - policies_all.wont_equal nil - policies_all.length.must_equal 0 + _(policies_all).wont_equal nil + _(policies_all.length).must_equal 0 - proc { @service.policies.find_by_id 'atlantis' }.must_raise Fog::OpenStack::Identity::NotFound + _(proc { @service.policies.find_by_id 'atlantis' }).must_raise Fog::OpenStack::Identity::NotFound end end @@ -1015,32 +1015,32 @@ blob = {'foobar_user' => ['role:compute-user']}.to_json # Make sure there are no existing policies - @service.policies.all.select { |policy| policy.type == 'application/json' }.length.must_equal 0 + _(@service.policies.all.select { |policy| policy.type == 'application/json' }.length).must_equal 0 # Create a policy foo_policy = @service.policies.create(:type => 'application/json', :blob => blob) policy_id = foo_policy.id - @service.policies.all.select { |policy| policy.type == 'application/json' }.length.must_equal 1 + _(@service.policies.all.select { |policy| policy.type == 'application/json' }.length).must_equal 1 # Update policy blob new_blob = {'baz_user' => ['role:compute-user']}.to_json foo_policy.update(:blob => new_blob) - foo_policy.blob.must_equal new_blob + _(foo_policy.blob).must_equal new_blob # Read the policy freshly and check the secret key - @service.policies.all.select { |policy| policy.type == 'application/json' }.length.must_equal 1 + _(@service.policies.all.select { |policy| policy.type == 'application/json' }.length).must_equal 1 updated_policy = @service.policies.find_by_id policy_id - updated_policy.wont_equal nil - updated_policy.type.must_equal 'application/json' - updated_policy.blob.must_equal new_blob + _(updated_policy).wont_equal nil + _(updated_policy.type).must_equal 'application/json' + _(updated_policy.blob).must_equal new_blob # Delete the policy updated_policy.destroy # Check that the deletion worked - proc { @service.policies.find_by_id policy_id }.must_raise Fog::OpenStack::Identity::NotFound - @service.policies.all.select { |policy| policy.type == 'application/json' }.length.must_equal 0 + _(proc { @service.policies.find_by_id policy_id }).must_raise Fog::OpenStack::Identity::NotFound + _(@service.policies.all.select { |policy| policy.type == 'application/json' }.length).must_equal 0 end end end diff --git a/spec/image_v1_spec.rb b/spec/image_v1_spec.rb index 3e6fc6192..529559b5e 100644 --- a/spec/image_v1_spec.rb +++ b/spec/image_v1_spec.rb @@ -20,7 +20,7 @@ it 'finds image' do existing_image_id = 'ea20c966-d2fb-4287-a2eb-7bece9af4263' VCR.use_cassette('images_v1_find_by_id') do - @service.images.find_by_id(existing_image_id).id.must_equal existing_image_id + _(@service.images.find_by_id(existing_image_id).id).must_equal existing_image_id end end @@ -34,7 +34,7 @@ existing_image_id = 'ea20c966-d2fb-4287-a2eb-7bece9af4263' expected_value = 'bar' VCR.use_cassette('images_v1_find_by_id') do - @service.images.find_by_id(existing_image_id).properties['foo'].must_equal expected_value + _(@service.images.find_by_id(existing_image_id).properties['foo']).must_equal expected_value end end end diff --git a/spec/image_v2_spec.rb b/spec/image_v2_spec.rb index f132fbb5e..6b2451660 100644 --- a/spec/image_v2_spec.rb +++ b/spec/image_v2_spec.rb @@ -27,8 +27,8 @@ def cleanup_image(image, image_name = nil, image_id = nil) @service.images.all(:name => image_name).each(&:destroy) end # Check that the deletion worked - proc { @service.images.find_by_id(image_id).must_equal nil } if image_id - @service.images.all(:name => image_name).length.must_equal 0 if image_name + proc { _(@service.images.find_by_id(image_id)).must_be_nil } if image_id + _(@service.images.all(:name => image_name).length).must_equal 0 if image_name end it "CRUD & list images" do @@ -36,33 +36,33 @@ def cleanup_image(image, image_name = nil, image_id = nil) image_name = 'foobar' image_rename = 'baz' - @service.images.all.wont_equal nil + _(@service.images.all).wont_equal nil begin # Create an image called foobar foobar_image = @service.images.create(:name => image_name) foobar_id = foobar_image.id - @service.images.all(:name => image_name).length.must_equal 1 - foobar_image.status.must_equal 'queued' + _(@service.images.all(:name => image_name).length).must_equal 1 + _(foobar_image.status).must_equal 'queued' # Rename it to baz # see "Patch images" test below - for now this will be a simple synthesis of a JSON patch with op = 'replace' foobar_image.update(:name => image_rename) - foobar_image.name.must_equal image_rename + _(foobar_image.name).must_equal image_rename baz_image = @service.images.find_by_id foobar_id - baz_image.wont_equal nil - baz_image.id.must_equal foobar_id - baz_image.name.must_equal image_rename + _(baz_image).wont_equal nil + _(baz_image.id).must_equal foobar_id + _(baz_image.name).must_equal image_rename # Read the image freshly by listing images filtered by the new name images = @service.images.all(:name => image_rename) - images.length.must_equal 1 - images.first.id.must_equal baz_image.id + _(images.length).must_equal 1 + _(images.first.id).must_equal baz_image.id ensure cleanup_image baz_image @service.images.all.select { |image| [image_name, image_rename].include? image.name }.each(&:destroy) # Check that the deletion worked - @service.images.all.count { |image| [image_name, image_rename].include? image.name }.must_equal 0 + _(@service.images.all.count { |image| [image_name, image_rename].include? image.name }).must_equal 0 end end end @@ -78,12 +78,12 @@ def cleanup_image(image, image_name = nil, image_id = nil) # Create an image with a specified ID foobar_image = @service.images.create(:name => 'foobar_id', :id => identifier) foobar_id = foobar_image.id - @service.images.all(:name => image_name).length.must_equal 1 - foobar_image.status.must_equal 'queued' - foobar_id.must_equal identifier + _(@service.images.all(:name => image_name).length).must_equal 1 + _(foobar_image.status).must_equal 'queued' + _(foobar_id).must_equal identifier get_image = @service.images.find_by_id(identifier) - get_image.name.must_equal image_name + _(get_image.name).must_equal image_name ensure cleanup_image foobar_image, image_name, foobar_id end @@ -103,11 +103,11 @@ def cleanup_image(image, image_name = nil, image_id = nil) ) foobar_image.save - foobar_image.status.must_equal 'queued' - foobar_image.id.must_equal identifier - foobar_image.name.must_equal 'original_name' - foobar_image.property_to_delete.must_equal 'bar' - foobar_image.respond_to?(:property_to_add).must_equal false + _(foobar_image.status).must_equal 'queued' + _(foobar_image.id).must_equal identifier + _(foobar_image.name).must_equal 'original_name' + _(foobar_image.property_to_delete).must_equal 'bar' + _(foobar_image.respond_to?(:property_to_add)).must_equal false get_image = @service.images.find_by_id(identifier) get_image.name = 'updated_name' @@ -116,9 +116,9 @@ def cleanup_image(image, image_name = nil, image_id = nil) get_image.save updated_image = @service.images.find_by_id(identifier) - updated_image.name.must_equal 'updated_name' - updated_image.property_to_add.must_equal 'bar' - updated_image.respond_to?(:property_to_delete).must_equal false + _(updated_image.name).must_equal 'updated_name' + _(updated_image.property_to_add).must_equal 'bar' + _(updated_image.respond_to?(:property_to_delete)).must_equal false ensure cleanup_image nil, nil, identifier end @@ -141,17 +141,17 @@ def cleanup_image(image, image_name = nil, image_id = nil) found_image.name = image_name + '_updated' found_image.save - created_image.name.must_equal image_name + '_original', + _(created_image.name).must_equal image_name + '_original', created_image.reload - created_image.name.must_equal image_name + '_updated' + _(created_image.name).must_equal image_name + '_updated' # verify an image provided by `find_by_id` can be reloaded created_image.name = image_name + '_updated_again' created_image.save - found_image.name.must_equal image_name + '_updated' + _(found_image.name).must_equal image_name + '_updated' found_image.reload - found_image.name.must_equal image_name + '_updated_again' + _(found_image.name).must_equal image_name + '_updated_again' ensure cleanup_image nil, image_name end @@ -180,23 +180,23 @@ def cleanup_image(image, image_name = nil, image_id = nil) foobar_id = foobar_image.id # Status should be queued - @service.images.find_by_id(foobar_id).status.must_match(/queued/) + _(@service.images.find_by_id(foobar_id).status).must_match(/queued/) # Upload data from File or IO object foobar_image.upload_data File.new(image_path, 'r') # Status should be saving or active - @service.images.find_by_id(foobar_id).status.must_match(/saving|active/) + _(@service.images.find_by_id(foobar_id).status).must_match(/saving|active/) # Get an IO object from which to download image data - wait until finished saving though while @service.images.find_by_id(foobar_id).status == 'saving' sleep 1 end - @service.images.find_by_id(foobar_id).status.must_equal 'active' + _(@service.images.find_by_id(foobar_id).status).must_equal 'active' # Bulk download downloaded_data = foobar_image.download_data - downloaded_data.size.must_equal File.size(image_path) + _(downloaded_data.size).must_equal File.size(image_path) ensure cleanup_image foobar_image, image_name end @@ -221,7 +221,7 @@ def cleanup_image(image, image_name = nil, image_id = nil) end foobar_image.deactivate - proc { foobar_image.download_data }.must_raise Excon::Errors::Forbidden + _(proc { foobar_image.download_data }).must_raise Excon::Errors::Forbidden foobar_image.reactivate foobar_image.download_data @@ -242,16 +242,16 @@ def cleanup_image(image, image_name = nil, image_id = nil) foobar_id = foobar_image.id foobar_image.add_tag 'tag1' - @service.images.find_by_id(foobar_id).tags.must_include 'tag1' + _(@service.images.find_by_id(foobar_id).tags).must_include 'tag1' foobar_image.add_tags %w[tag2 tag3 tag4] - @service.images.find_by_id(foobar_id).tags.must_equal %w[tag4 tag1 tag2 tag3] + _(@service.images.find_by_id(foobar_id).tags).must_equal %w[tag4 tag1 tag2 tag3] foobar_image.remove_tag 'tag2' - @service.images.find_by_id(foobar_id).tags.must_equal %w[tag4 tag1 tag3] + _(@service.images.find_by_id(foobar_id).tags).must_equal %w[tag4 tag1 tag3] foobar_image.remove_tags %w[tag1 tag3] - @service.images.find_by_id(foobar_id).tags.must_include 'tag4' + _(@service.images.find_by_id(foobar_id).tags).must_include 'tag4' ensure cleanup_image foobar_image, image_name end @@ -266,20 +266,20 @@ def cleanup_image(image, image_name = nil, image_id = nil) # Create an image called foobar foobar_image = @service.images.create(:name => image_name) - foobar_image.members.size.must_equal 0 + _(foobar_image.members.size).must_equal 0 foobar_image.add_member tenant_id - foobar_image.members.size.must_equal 1 + _(foobar_image.members.size).must_equal 1 member = foobar_image.member tenant_id - member.wont_equal nil - member['status'].must_equal 'pending' + _(member).wont_equal nil + _(member['status']).must_equal 'pending' member['status'] = 'accepted' foobar_image.update_member member - foobar_image.member(tenant_id)['status'].must_equal 'accepted' + _(foobar_image.member(tenant_id)['status']).must_equal 'accepted' foobar_image.remove_member member['member_id'] - foobar_image.members.size.must_equal 0 + _(foobar_image.members.size).must_equal 0 ensure cleanup_image foobar_image, image_name end @@ -338,7 +338,7 @@ def cleanup_image(image, image_name = nil, image_id = nil) it 'finds image' do existing_image_id = 'fe05659e-d433-4e09-aa78-19e0b7f5e497' VCR.use_cassette('images_v2_find_by_id') do - @service.images.find_by_id(existing_image_id).id.must_equal existing_image_id + _(@service.images.find_by_id(existing_image_id).id).must_equal existing_image_id end end diff --git a/spec/image_v2_upload_spec.rb b/spec/image_v2_upload_spec.rb index 33d475d52..cea4b2f4c 100644 --- a/spec/image_v2_upload_spec.rb +++ b/spec/image_v2_upload_spec.rb @@ -47,14 +47,14 @@ while @service.images.find_by_id(foobar_id).status == 'saving' sleep 1 end - @service.images.find_by_id(foobar_id).status.must_equal 'active' + _(@service.images.find_by_id(foobar_id).status).must_equal 'active' size = 0 read_block = lambda do |chunk, _remaining, _total| size += chunk.size end foobar_image.download_data(:response_block => read_block) - size.must_equal File.size(image_path) + _(size).must_equal File.size(image_path) ensure # Delete the image foobar_image.destroy if foobar_image @@ -63,11 +63,11 @@ # Check that the deletion worked if foobar_id - proc do + _(proc do @service.images.find_by_id foobar_id - end.must_raise Fog::OpenStack::Image::NotFound + end).must_raise Fog::OpenStack::Image::NotFound end - @service.images.all(:name => 'foobar_up2').length.must_equal 0 + _(@service.images.all(:name => 'foobar_up2').length).must_equal 0 end end end diff --git a/spec/monitoring_spec.rb b/spec/monitoring_spec.rb index aa06eca84..db12f81c2 100644 --- a/spec/monitoring_spec.rb +++ b/spec/monitoring_spec.rb @@ -24,7 +24,7 @@ :value => 42, :value_meta => {"meta_key1" => "meta_value1"}) - metric_0.wont_be_nil + _(metric_0).wont_be_nil # create multiple metrics @@ -54,30 +54,30 @@ # list metrics filtered by name and search for previuosly created metrics by unique identifier of name,dimensions [metric_0_identity, metric_1_identity, metric_2_identity].each do |metric_identity| metrics_all = @service.metrics.all(:name => metric_identity[:name]) - metrics_all.wont_be_nil - metrics_all.wont_be_empty + _(metrics_all).wont_be_nil + _(metrics_all).wont_be_empty metrics_all_identities = metrics_all.collect do |_metric| {:name => metric_identity[:name], :dimensions => metric_identity[:dimensions]} end - metrics_all_identities.must_include(metric_identity) + _(metrics_all_identities).must_include(metric_identity) end # list all metric names metrics_name_list = @service.metrics.list_metric_names - metrics_name_list.wont_be_nil - metrics_name_list.wont_be_empty + _(metrics_name_list).wont_be_nil + _(metrics_name_list).wont_be_empty # failure cases - proc do + _(proc do @service.metrics.create(:name => "this won't be created due to insufficient args") - end.must_raise ArgumentError + end).must_raise ArgumentError - proc do + _(proc do @service.metrics.create(:name => "this wont't be created due to invalid timestamp", :timestamp => 1234) - end.must_raise ArgumentError + end).must_raise ArgumentError end end @@ -87,14 +87,14 @@ :start_time => '2016-04-01T14:43:00Z', :merge_metrics => true) - measurement_list.wont_be_nil - measurement_list.wont_be_empty + _(measurement_list).wont_be_nil + _(measurement_list).wont_be_empty # should return an empty list measurement_list_empty = @service.measurements.find(:name => 'non.existing.metric_name', :start_time => '2016-04-01T14:43:00Z') - measurement_list_empty.must_be_empty + _(measurement_list_empty).must_be_empty end end @@ -105,8 +105,8 @@ :statistics => 'avg,min,max,sum,count', :merge_metrics => true) - statistics_list.wont_be_nil - statistics_list.wont_be_empty + _(statistics_list).wont_be_nil + _(statistics_list).wont_be_empty end end @@ -122,13 +122,13 @@ # list all notification methods notification_methods_all = @service.notification_methods.all - notification_methods_all.wont_be_nil - notification_methods_all.wont_be_empty + _(notification_methods_all).wont_be_nil + _(notification_methods_all).wont_be_empty # find a notification method by id notification_method_by_id = @service.notification_methods.find_by_id(notification_method.id) - notification_method.must_equal notification_method_by_id + _(notification_method).must_equal notification_method_by_id # update specific an existing notification notification_method.update(:name => notification_method.name, @@ -136,22 +136,22 @@ :type => notification_method.type, :period => 0) - notification_method.address.must_equal 'notification_methods@example.com' - notification_method.period.must_equal 0 + _(notification_method.address).must_equal 'notification_methods@example.com' + _(notification_method.period).must_equal 0 # Delete the notification method and make sure it is no longer found in the list notification_method.destroy - (@service.notification_methods.all.include? notification_method).must_equal false + _((@service.notification_methods.all.include? notification_method)).must_equal false notification_method = nil # failure cases - proc do + _(proc do @service.notification_methods.create(:name => "this won't be created due to insufficient args") - end.must_raise ArgumentError + end).must_raise ArgumentError - proc do + _(proc do @service.notification_methods.find_by_id('bogus_id') - end.must_raise Fog::OpenStack::Monitoring::NotFound + end).must_raise Fog::OpenStack::Monitoring::NotFound ensure notification_method.destroy if notification_method end @@ -172,16 +172,16 @@ # list all alarm definitions alarm_definitions_all = @service.alarm_definitions.all - alarm_definitions_all.wont_be_nil - alarm_definitions_all.wont_be_empty + _(alarm_definitions_all).wont_be_nil + _(alarm_definitions_all).wont_be_empty # find an alarm-definition by id alarm_definition_by_id = @service.alarm_definitions.find_by_id(alarm_definition.id) - alarm_definition.id.must_equal alarm_definition_by_id.id - alarm_definition.name.must_equal alarm_definition_by_id.name - alarm_definition.expression.must_equal alarm_definition_by_id.expression - alarm_definition.deterministic.must_equal false + _(alarm_definition.id).must_equal alarm_definition_by_id.id + _(alarm_definition.name).must_equal alarm_definition_by_id.name + _(alarm_definition.expression).must_equal alarm_definition_by_id.expression + _(alarm_definition.deterministic).must_equal false # create a notification method for the following test notification_method = @service.notification_methods.create(:name => 'important notification', @@ -201,22 +201,22 @@ :actions_enabled => true ) - alarm_definition_replaced.id.must_equal alarm_definition.id - alarm_definition_replaced.name.must_equal 'CPU percent greater than 15' - alarm_definition_replaced.description.must_equal 'Replaced alarm-definition expression' - alarm_definition_replaced.expression.must_equal '(avg(cpu.user_perc{hostname=devstack}) > 15)' + _(alarm_definition_replaced.id).must_equal alarm_definition.id + _(alarm_definition_replaced.name).must_equal 'CPU percent greater than 15' + _(alarm_definition_replaced.description).must_equal 'Replaced alarm-definition expression' + _(alarm_definition_replaced.expression).must_equal '(avg(cpu.user_perc{hostname=devstack}) > 15)' # # patch specific attributes of alarm_definition alarm_definition_updated = alarm_definition.patch(:description => 'An updated alarm-definition.') - alarm_definition.id.must_equal alarm_definition_updated.id - alarm_definition_updated.description.must_equal 'An updated alarm-definition.' + _(alarm_definition.id).must_equal alarm_definition_updated.id + _(alarm_definition_updated.description).must_equal 'An updated alarm-definition.' # delete alarm definition alarm_definition.destroy # ensure the alarm definition does not exist any more - (@service.alarm_definitions.all.include? alarm_definition).must_equal false + _((@service.alarm_definitions.all.include? alarm_definition)).must_equal false alarm_definition = nil # delete the notification method @@ -224,9 +224,9 @@ notification_method = nil # failure cases - proc do + _(proc do @service.alarm_definitions.create(:name => "this won't be created due to insufficient args") - end.must_raise ArgumentError + end).must_raise ArgumentError ensure alarm_definition.destroy if alarm_definition notification_method.destroy if notification_method @@ -250,20 +250,20 @@ # list all alarms alarms_all = @service.alarms.all - alarms_all.wont_be_nil - alarms_all.wont_be_empty + _(alarms_all).wont_be_nil + _(alarms_all).wont_be_empty # list all alarms in ALARM state alarms_all_state_filter = @service.alarms.all(:state => 'OK') - alarms_all_state_filter.wont_be_nil - alarms_all_state_filter.wont_be_empty + _(alarms_all_state_filter).wont_be_nil + _(alarms_all_state_filter).wont_be_empty # get an alarm by name using list all alarms with filter alarm_list_by_name_filter = @service.alarms.all(:metric_name => 'cpu.idle_perc') alarm_by_name = alarm_list_by_name_filter.first - alarm_by_name.wont_be_nil + _(alarm_by_name).wont_be_nil # get the id of this alarm alarm_id = alarm_by_name.id @@ -271,44 +271,44 @@ # find alarm by id alarm_by_id = @service.alarms.find_by_id(alarm_id) - alarm_by_name.id.must_equal alarm_by_id.id - alarm_by_name.state.must_equal alarm_by_id.state - alarm_by_name.lifecycle_state.must_equal alarm_by_id.lifecycle_state + _(alarm_by_name.id).must_equal alarm_by_id.id + _(alarm_by_name.state).must_equal alarm_by_id.state + _(alarm_by_name.lifecycle_state).must_equal alarm_by_id.lifecycle_state # replace the entire state of the specified alarm alarm_by_id.update(:state => 'ALARM', :lifecycle_state => 'OPEN', :link => 'http://pagerduty.com/') - alarm_by_id.state.must_equal 'ALARM' - alarm_by_id.lifecycle_state.must_equal 'OPEN' - alarm_by_id.link.must_equal 'http://pagerduty.com/' + _(alarm_by_id.state).must_equal 'ALARM' + _(alarm_by_id.lifecycle_state).must_equal 'OPEN' + _(alarm_by_id.link).must_equal 'http://pagerduty.com/' # check the link of an alarm before patching - alarm_by_id.link.wont_equal 'http://somesite.com/this-alarm-info' + _(alarm_by_id.link).wont_equal 'http://somesite.com/this-alarm-info' # patch specific attributes of an existing alarm alarm_by_id.patch(:link => 'http://somesite.com/this-alarm-info') # check the link afterwards - alarm_by_id.link.must_equal 'http://somesite.com/this-alarm-info' + _(alarm_by_id.link).must_equal 'http://somesite.com/this-alarm-info' # list alarm state history for all alarms but limit history to 5 alarm_state_history_all = @service.alarm_states.all(:limit => 5) - alarm_state_history_all.wont_be_nil - alarm_state_history_all.length.must_equal 5 + _(alarm_state_history_all).wont_be_nil + _(alarm_state_history_all.length).must_equal 5 # list alarm state history alarm_state_history_for_alarm = @service.alarm_states.list_alarm_state_history(alarm_id) - alarm_state_history_for_alarm.wont_be_nil - alarm_state_history_for_alarm.wont_be_empty + _(alarm_state_history_for_alarm).wont_be_nil + _(alarm_state_history_for_alarm).wont_be_empty # delete an existing alarm alarm_by_id.destroy - (@service.alarms.all.include? alarm_by_id).must_equal false + _((@service.alarms.all.include? alarm_by_id)).must_equal false alarm_definition = nil notification_method = nil @@ -325,8 +325,8 @@ # get the alarm state history for all alarms alarm_state_history_all = @service.alarm_states.all - alarm_state_history_all.wont_be_nil - alarm_state_history_all.wont_be_empty + _(alarm_state_history_all).wont_be_nil + _(alarm_state_history_all).wont_be_empty # get an alarm by name using list all alarms with filter alarm_by_name = @service.alarms.all(:name => 'cpu.user_perc') @@ -340,8 +340,8 @@ # get alarm state history for specific alarm alarm_state_history_for_alarm = @service.alarm_states.list_alarm_state_history(alarm_id) - alarm_state_history_for_alarm.wont_be_nil - alarm_state_history_for_alarm.wont_be_empty + _(alarm_state_history_for_alarm).wont_be_nil + _(alarm_state_history_for_alarm).wont_be_empty end end @@ -350,10 +350,10 @@ # list dimension values dimension_values_by_key = @service.metrics.list_dimension_values('hostname').first - dimension_values_by_key.wont_be_nil - dimension_values_by_key.dimension_name.must_equal 'hostname' - dimension_values_by_key.id.wont_be_nil - dimension_values_by_key.values.wont_be_empty + _(dimension_values_by_key).wont_be_nil + _(dimension_values_by_key.dimension_name).must_equal 'hostname' + _(dimension_values_by_key.id).wont_be_nil + _(dimension_values_by_key.values).wont_be_empty end end @@ -361,12 +361,12 @@ VCR.use_cassette('list_notification_method_types') do notification_method_types = @service.notification_methods.list_types - notification_method_types.wont_be_nil - notification_method_types.wont_be_empty + _(notification_method_types).wont_be_nil + _(notification_method_types).wont_be_empty - notification_method_types.must_include :EMAIL - notification_method_types.must_include :PAGERDUTY - notification_method_types.must_include :WEBHOOK + _(notification_method_types).must_include :EMAIL + _(notification_method_types).must_include :PAGERDUTY + _(notification_method_types).must_include :WEBHOOK end end diff --git a/spec/network_spec.rb b/spec/network_spec.rb index 659e129d1..1b7c91aff 100644 --- a/spec/network_spec.rb +++ b/spec/network_spec.rb @@ -29,7 +29,7 @@ :ip_version => 4, :gateway_ip => nil ) - subnet.name.must_equal 'my-network' + _(subnet.name).must_equal 'my-network' ensure subnet.destroy if subnet foonet.destroy if foonet @@ -52,23 +52,23 @@ :target_tenant => other_project.id, :action => 'access_as_shared' ) - rbac.target_tenant.must_equal other_project.id - foonet.reload.shared.must_equal false - @service.rbac_policies.all(:object_id => foonet.id).length.must_equal 1 + _(rbac.target_tenant).must_equal other_project.id + _(foonet.reload.shared).must_equal false + _(@service.rbac_policies.all(:object_id => foonet.id).length).must_equal 1 # get - @service.rbac_policies.find_by_id(rbac.id).wont_equal nil + _(@service.rbac_policies.find_by_id(rbac.id)).wont_equal nil # change share target to own project rbac.target_tenant = own_project.id rbac.save - foonet.reload.shared.must_equal true + _(foonet.reload.shared).must_equal true # delete the sharing rbac.destroy rbac = nil - @service.rbac_policies.all(:object_id => foonet.id).length.must_equal 0 - foonet.reload.shared.must_equal false + _(@service.rbac_policies.all(:object_id => foonet.id).length).must_equal 0 + _(foonet.reload.shared).must_equal false ensure rbac.destroy if rbac foonet.destroy if foonet @@ -97,12 +97,12 @@ service.instance_variable_set("@auth_token", @network_token.reverse) # with token if index == 0 - err = -> { service.security_groups.all(:limit => 2) }.must_raise Excon::Errors::Unauthorized - err.message.must_match(/Authentication required/) + err = _(-> { service.security_groups.all(:limit => 2) }).must_raise Excon::Errors::Unauthorized + _(err.message).must_match(/Authentication required/) # with username+password else @after = service.security_groups.all(:limit => 2).first.tenant_id - @before.must_equal @after + _(@before).must_equal @after end end end diff --git a/spec/shared_file_system_spec.rb b/spec/shared_file_system_spec.rb index 7db91ce67..9c5f0d1a0 100644 --- a/spec/shared_file_system_spec.rb +++ b/spec/shared_file_system_spec.rb @@ -48,27 +48,27 @@ :description => share_description, :share_network_id => share_network.id ) - example_share.status.must_equal 'creating' + _(example_share.status).must_equal 'creating' example_id = example_share.id # update display description example_share.update(:display_description => share_updated_description) - example_share.reload.description.must_equal share_updated_description + _(example_share.reload.description).must_equal share_updated_description # get by ID example_share_by_id = @service.shares.find_by_id example_id - example_share_by_id.wont_equal nil - example_share_by_id.name.must_equal share_name + _(example_share_by_id).wont_equal nil + _(example_share_by_id.name).must_equal share_name # get by filtering list by name shares = @service.shares.all(:name => share_name) - shares.length.must_equal 1 - shares.first.id.must_equal example_id + _(shares.length).must_equal 1 + _(shares.first.id).must_equal example_id ensure # delete the share(s) @service.shares.all(:name => share_name).each(&:destroy) # check delete action - @service.shares.all(:name => share_name).length.must_equal 0 + _(@service.shares.all(:name => share_name).length).must_equal 0 # delete the share network @service.networks.all(:name => share_net_name).each(&:destroy) @@ -92,27 +92,27 @@ :name => share_net_name, :description => share_net_description ) - share_network.description.must_equal share_net_description + _(share_network.description).must_equal share_net_description share_net_id = share_network.id # update description share_network.update(:description => share_net_updated_description) - share_network.reload.description.must_equal share_net_updated_description + _(share_network.reload.description).must_equal share_net_updated_description # get by ID share_net_by_id = @service.networks.find_by_id share_net_id - share_net_by_id.wont_equal nil - share_net_by_id.name.must_equal share_net_name + _(share_net_by_id).wont_equal nil + _(share_net_by_id.name).must_equal share_net_name # get by filtering list by name share_nets = @service.networks.all(:name => share_net_name) - share_nets.length.must_equal 1 - share_nets.first.id.must_equal share_net_id + _(share_nets.length).must_equal 1 + _(share_nets.first.id).must_equal share_net_id ensure # delete the share network @service.networks.all(:name => share_net_name).each(&:destroy) # check delete action - @service.networks.all(:name => share_net_name).length.must_equal 0 + _(@service.networks.all(:name => share_net_name).length).must_equal 0 end end end @@ -153,29 +153,29 @@ :name => snap_name ) - snap.name.must_equal snap_name + _(snap.name).must_equal snap_name snap_id = snap.id snap.wait_for { ready? } # get by ID snap_by_id = @service.snapshots.find_by_id snap_id - snap_by_id.wont_equal nil - snap_by_id.name.must_equal snap_name + _(snap_by_id).wont_equal nil + _(snap_by_id.name).must_equal snap_name # update name via display_name snap_by_id.update(:display_name => snap_updated_name) - snap_by_id.reload.name.must_equal snap_updated_name + _(snap_by_id.reload.name).must_equal snap_updated_name # get by filtering list by name snaps = @service.snapshots.all(:name => snap_updated_name) - snaps.length.must_equal 1 - snaps.first.id.must_equal snap_id + _(snaps.length).must_equal 1 + _(snaps.first.id).must_equal snap_id ensure # delete the snapshot(s) @service.snapshots.all(:name => snap_updated_name).each(&:destroy) # check delete action @service.snapshots.all(:name => snap_updated_name).each do |s| - s.status.must_equal 'deleting' + _(s.status).must_equal 'deleting' end # only can go on when the snapshots are gone @@ -232,27 +232,27 @@ share.wait_for { ready? } # modify share sizes - share.size.must_equal share_size_small + _(share.size).must_equal share_size_small share.extend(share_size_big) share.wait_for { ready? } - share.size.must_equal share_size_big + _(share.size).must_equal share_size_big share.shrink(share_size_small) share.wait_for { ready? } - share.size.must_equal share_size_small + _(share.size).must_equal share_size_small # modify share access - share.access_rules.length.must_equal 0 + _(share.access_rules.length).must_equal 0 access_rule = share.access_rules.create( :access_type => share_access_type, :access_to => '10.0.0.2', :access_level => 'ro' ) rules = share.access_rules - rules.length.must_equal 1 + _(rules.length).must_equal 1 new_rule = rules.first new_rule.wait_for { ready? } - new_rule.access_type.must_equal share_access_type - new_rule.id.must_equal access_rule.id + _(new_rule.access_type).must_equal share_access_type + _(new_rule.id).must_equal access_rule.id share.revoke_access(access_rule.id) Fog.wait_for { share.access_rules.empty? } ensure diff --git a/spec/volume_spec.rb b/spec/volume_spec.rb index 2c3896798..8219810c0 100644 --- a/spec/volume_spec.rb +++ b/spec/volume_spec.rb @@ -1,8 +1,11 @@ require 'spec_helper' require_relative './shared_context' +# NOTE: Fog::OpenStack::Volume, the version-negotiating entry point, is covered +# by unit/volume_test.rb rather than here. It authenticates once per version it +# tries, and these cassettes recorded exactly one token request each, so they +# cannot represent version negotiation. [ - Fog::OpenStack::Volume, Fog::OpenStack::Volume::V1, Fog::OpenStack::Volume::V2 ].delete_if { |the_class| ENV['TEST_CLASS'] && ENV['TEST_CLASS'] != the_class.name }.each do |service_class| @@ -38,7 +41,7 @@ def setup_test_object(options) puts "Checking for leftovers..." if ENV['DEBUG_VERBOSE'] volume_name = options[@name_param] # if this fails, cleanup this object (it was left over from a failed test run) - @service.volumes.all(@name_param => volume_name).length.must_equal 0 + _(@service.volumes.all(@name_param => volume_name).length).must_equal 0 puts "Creating volume #{volume_name}..." if ENV['DEBUG_VERBOSE'] return @service.volumes.create(options) @@ -47,7 +50,7 @@ def setup_test_object(options) puts "Checking for leftovers..." if ENV['DEBUG_VERBOSE'] transfer_name = options[:name] # if this fails, cleanup this object (it was left over from a failed test run) - @service.transfers.all(:name => transfer_name).length.must_equal 0 + _(@service.transfers.all(:name => transfer_name).length).must_equal 0 puts "Creating transfer #{transfer_name}..." if ENV['DEBUG_VERBOSE'] return @service.transfers.create(options) @@ -56,7 +59,7 @@ def setup_test_object(options) puts "Checking for leftovers..." if ENV['DEBUG_VERBOSE'] snapshot_name = options[@name_param] # if this fails, cleanup this object (it was left over from a failed test run) - @service.snapshots.all(@name_param => snapshot_name).length.must_equal 0 + _(@service.snapshots.all(@name_param => snapshot_name).length).must_equal 0 puts "Creating snapshot #{snapshot_name}..." if ENV['DEBUG_VERBOSE'] return @service.snapshots.create(options) @@ -110,20 +113,20 @@ def cleanup_test_object(collection, id) @description_param => volume_description, :size => volume_size).id - @service.volumes.all(@name_param => volume_name).length.must_equal 1 + _(@service.volumes.all(@name_param => volume_name).length).must_equal 1 # check retrieval of volume by ID puts "Retrieving volume by ID..." if ENV['DEBUG_VERBOSE'] volume = @service.volumes.get(volume_id) - volume.must_be_kind_of Fog::OpenStack::Volume::Volume + _(volume).must_be_kind_of Fog::OpenStack::Volume::Volume - volume.id.must_equal volume_id - volume.display_name.must_equal volume_name unless v2? - volume.name.must_equal volume_name if v2? - volume.display_description.must_equal volume_description unless v2? - volume.description.must_equal volume_description if v2? - volume.size.must_equal volume_size + _(volume.id).must_equal volume_id + _(volume.display_name).must_equal volume_name unless v2? + _(volume.name).must_equal volume_name if v2? + _(volume.display_description).must_equal volume_description unless v2? + _(volume.description).must_equal volume_description if v2? + _(volume.size).must_equal volume_size puts "Waiting for volume to be available..." if ENV['DEBUG_VERBOSE'] volume.wait_for { ready? } @@ -132,25 +135,25 @@ def cleanup_test_object(collection, id) puts "Retrieving volume by name..." if ENV['DEBUG_VERBOSE'] volumes = @service.volumes.all(@name_param => volume_name) - volumes.length.must_equal 1 + _(volumes.length).must_equal 1 volume = volumes[0] - volume.must_be_kind_of Fog::OpenStack::Volume::Volume + _(volume).must_be_kind_of Fog::OpenStack::Volume::Volume - volume.id.must_equal volume_id - volume.display_name.must_equal volume_name unless v2? - volume.name.must_equal volume_name if v2? - volume.display_description.must_equal volume_description unless v2? - volume.description.must_equal volume_description if v2? - volume.size.must_equal volume_size + _(volume.id).must_equal volume_id + _(volume.display_name).must_equal volume_name unless v2? + _(volume.name).must_equal volume_name if v2? + _(volume.display_description).must_equal volume_description unless v2? + _(volume.description).must_equal volume_description if v2? + _(volume.size).must_equal volume_size # Update the volume's name volume.update(@name_param => volume_new_name) volumes = @service.volumes.all(@name_param => volume_new_name) volume = volumes.first - volume.must_be_kind_of Fog::OpenStack::Volume::Volume - volume.display_name.must_equal volume_new_name unless v2? - volume.name.must_equal volume_new_name if v2? + _(volume).must_be_kind_of Fog::OpenStack::Volume::Volume + _(volume.display_name).must_equal volume_new_name unless v2? + _(volume.name).must_equal volume_new_name if v2? # Check that save does an update volume.description = volume_new_description if v2? @@ -158,8 +161,8 @@ def cleanup_test_object(collection, id) volume.save volume = @service.volumes.get(volume_id) - volume.display_description.must_equal volume_new_description unless v2? - volume.description.must_equal volume_new_description if v2? + _(volume.display_description).must_equal volume_new_description unless v2? + _(volume.description).must_equal volume_new_description if v2? ensure # delete volume cleanup_test_object(@service.volumes, volume_id) @@ -173,9 +176,9 @@ def cleanup_test_object(collection, id) puts "Listing volume types..." if ENV['DEBUG_VERBOSE'] types = @service.volume_types.all - types.length.must_be :>, 0 + _(types.length).must_be :>, 0 types.each do |type| - type.name.must_be_kind_of String + _(type.name).must_be_kind_of String end type_id = types[0].id @@ -185,17 +188,17 @@ def cleanup_test_object(collection, id) puts "Retrieving volume type by ID..." if ENV['DEBUG_VERBOSE'] type = @service.volume_types.get(type_id) - type.must_be_kind_of Fog::OpenStack::Volume::VolumeType - type.id.must_equal type_id - type.name.must_equal type_name + _(type).must_be_kind_of Fog::OpenStack::Volume::VolumeType + _(type.id).must_equal type_id + _(type.name).must_equal type_name # get a single volume type by name puts "Retrieving volume type by name..." if ENV['DEBUG_VERBOSE'] type = @service.volume_types.all(type_name).first - type.must_be_kind_of Fog::OpenStack::Volume::VolumeType - type.id.must_equal type_id - type.name.must_equal type_name + _(type).must_be_kind_of Fog::OpenStack::Volume::VolumeType + _(type.id).must_equal type_id + _(type.name).must_equal type_name end end @@ -216,21 +219,23 @@ def cleanup_test_object(collection, id) volume.wait_for do status == 'error_extending' || (ready? && size == volume_size_large) end - volume.status.wont_equal 'error_extending' + _(volume.status).wont_equal 'error_extending' # shrinking is not allowed in OpenStack puts "Shrinking volume should fail..." if ENV['DEBUG_VERBOSE'] - proc do + error = _(proc do volume.extend(volume_size_small) - end.must_raise(Excon::Errors::BadRequest, - /Invalid input received: New size for extend must be greater than current size./) + end).must_raise(Excon::Errors::BadRequest) + _(error.message).must_match( + /Invalid input received: New size for extend must be greater than current size./ + ) ensure # delete volume cleanup_test_object(@service.volumes, volume.nil? ? nil : volume.id) # check that extending a non-existing volume fails puts "Extending deleted volume should fail..." if ENV['DEBUG_VERBOSE'] - proc { @service.extend_volume(volume.id, volume_size_small) }.must_raise Fog::OpenStack::Volume::NotFound + _(proc { @service.extend_volume(volume.id, volume_size_small) }).must_raise Fog::OpenStack::Volume::NotFound end end end @@ -259,23 +264,23 @@ def cleanup_test_object(collection, id) puts 'Retrieving transfer by ID...' if ENV['DEBUG_VERBOSE'] transfer = @service.transfers.get(transfer_id) - transfer.must_be_kind_of Fog::OpenStack::Volume::Transfer + _(transfer).must_be_kind_of Fog::OpenStack::Volume::Transfer - transfer.id.must_equal transfer_id - transfer.name.must_equal transfer_name - transfer.volume_id.must_equal volume.id + _(transfer.id).must_equal transfer_id + _(transfer.name).must_equal transfer_name + _(transfer.volume_id).must_equal volume.id # check retrieval of transfer by name puts 'Retrieving transfer by name...' if ENV['DEBUG_VERBOSE'] transfers = @service.transfers.all(:name => transfer_name) - transfers.length.must_equal 1 + _(transfers.length).must_equal 1 transfer = transfers[0] - transfer.must_be_kind_of Fog::OpenStack::Volume::Transfer + _(transfer).must_be_kind_of Fog::OpenStack::Volume::Transfer - transfer.id.must_equal transfer_id - transfer.name.must_equal transfer_name - transfer.volume_id.must_equal volume.id + _(transfer.id).must_equal transfer_id + _(transfer.name).must_equal transfer_name + _(transfer.volume_id).must_equal volume.id # to accept the transfer, we need a second connection to a different project puts 'Checking object visibility from different projects...' if ENV['DEBUG_VERBOSE'] other_service = service_class.new( @@ -289,7 +294,7 @@ def cleanup_test_object(collection, id) # check that recipient cannot see the transfer object assert_nil other_service.transfers.get(transfer.id) - other_service.transfers.all(:name => transfer_name).length.must_equal 0 + _(other_service.transfers.all(:name => transfer_name).length).must_equal 0 # # check that recipient cannot see the volume before transfer # proc { other_service.volumes.get(volume.id) }.must_raise Fog::OpenStack::Compute::NotFound @@ -297,25 +302,25 @@ def cleanup_test_object(collection, id) # The recipient can inexplicably see the volume even before the # transfer, so to confirm that the transfer happens, we record its tenant ID. - volume.tenant_id.must_match(/^[0-9a-f-]+$/) # should look like a UUID + _(volume.tenant_id).must_match(/^[0-9a-f-]+$/) # should look like a UUID source_tenant_id = volume.tenant_id # check that accept_transfer fails without valid transfer ID and auth key bogus_uuid = 'ec8ff7e8-81e2-4e12-b9fb-3e8890612c2d' # from Fog::UUID.uuid, but fixed to play nice with VCR - proc { other_service.transfers.accept(bogus_uuid, auth_key) }.must_raise Fog::OpenStack::Volume::NotFound - proc { other_service.transfers.accept(transfer_id, 'invalidauthkey') }.must_raise Excon::Errors::BadRequest + _(proc { other_service.transfers.accept(bogus_uuid, auth_key) }).must_raise Fog::OpenStack::Volume::NotFound + _(proc { other_service.transfers.accept(transfer_id, 'invalidauthkey') }).must_raise Excon::Errors::BadRequest # accept transfer puts 'Accepting transfer...' if ENV['DEBUG_VERBOSE'] transfer = other_service.transfers.accept(transfer.id, auth_key) - transfer.must_be_kind_of Fog::OpenStack::Volume::Transfer + _(transfer).must_be_kind_of Fog::OpenStack::Volume::Transfer - transfer.id.must_equal transfer_id - transfer.name.must_equal transfer_name + _(transfer.id).must_equal transfer_id + _(transfer.name).must_equal transfer_name # check that recipient can see the volume volume = other_service.volumes.get(volume.id) - volume.must_be_kind_of Fog::OpenStack::Volume::Volume + _(volume).must_be_kind_of Fog::OpenStack::Volume::Volume # # check that sender cannot see the volume anymore # proc { @service.volumes.get(volume.id) }.must_raise Fog::OpenStack::Compute::NotFound @@ -323,13 +328,13 @@ def cleanup_test_object(collection, id) # As noted above, both users seem to be able to see the volume at all times. # Check change of ownership by looking at the tenant_id, instead. - volume.tenant_id.must_match(/^[0-9a-f-]+$/) # should look like a UUID - volume.tenant_id.wont_equal(source_tenant_id) + _(volume.tenant_id).must_match(/^[0-9a-f-]+$/) # should look like a UUID + _(volume.tenant_id).wont_equal(source_tenant_id) # check that the transfer object is gone on both sides [@service, other_service].each do |service| assert_nil service.transfers.get(transfer.id) - service.transfers.all(:name => transfer_name).length.must_equal 0 + _(service.transfers.all(:name => transfer_name).length).must_equal 0 end ensure # cleanup volume @@ -373,7 +378,7 @@ def cleanup_test_object(collection, id) # check that transfer cannot be accepted when it has been deleted puts 'Checking that accepting a deleted transfer fails...' if ENV['DEBUG_VERBOSE'] - proc { other_service.transfers.accept(transfer_id, auth_key) }.must_raise Fog::OpenStack::Volume::NotFound + _(proc { other_service.transfers.accept(transfer_id, auth_key) }).must_raise Fog::OpenStack::Volume::NotFound ensure # cleanup volume cleanup_test_object(@service.volumes, volume.id) if volume @@ -402,7 +407,7 @@ def cleanup_test_object(collection, id) Fog.wait_for do begin object = @service.snapshots.get(snapshot.id) - object.wont_be_nil + _(object).wont_be_nil puts "Current status: #{object ? object.status : 'deleted'}" if ENV['DEBUG_VERBOSE'] object.nil? || (%w[available error].include? object.status.downcase) end @@ -412,8 +417,8 @@ def cleanup_test_object(collection, id) snapshot.update(@description_param => 'Updated description') updated_snapshot = @service.snapshots.get(snapshot.id) - updated_snapshot.description.must_equal 'Updated description' if v2? - updated_snapshot.display_description.must_equal 'Updated description' unless v2? + _(updated_snapshot.description).must_equal 'Updated description' if v2? + _(updated_snapshot.display_description).must_equal 'Updated description' unless v2? # delete snapshot snapshot.destroy @@ -451,9 +456,9 @@ def cleanup_test_object(collection, id) updated_volume = @service.volumes.get(volume.id) check_metadata = updated_volume.metadata - check_metadata.size.must_equal 2 - check_metadata['some_metadata'].must_equal 'this is meta' - check_metadata['more_metadata'].must_equal 'even more meta' + _(check_metadata.size).must_equal 2 + _(check_metadata['some_metadata']).must_equal 'this is meta' + _(check_metadata['more_metadata']).must_equal 'even more meta' # update metadata volume.update_metadata('some_metadata' => 'this is updated', @@ -461,10 +466,10 @@ def cleanup_test_object(collection, id) updated_volume = @service.volumes.get(volume.id) check_metadata = updated_volume.metadata - check_metadata.size.must_equal 3 - check_metadata['some_metadata'].must_equal 'this is updated' - check_metadata['more_metadata'].must_equal 'even more meta' - check_metadata['new_metadata'].must_equal 'this is new' + _(check_metadata.size).must_equal 3 + _(check_metadata['some_metadata']).must_equal 'this is updated' + _(check_metadata['more_metadata']).must_equal 'even more meta' + _(check_metadata['new_metadata']).must_equal 'this is new' # replace metadata volume.replace_metadata('some_metadata' => 'this is updated again', @@ -472,17 +477,17 @@ def cleanup_test_object(collection, id) updated_volume = @service.volumes.get(volume.id) check_metadata = updated_volume.metadata - check_metadata.size.must_equal 2 - check_metadata['some_metadata'].must_equal 'this is updated again' - check_metadata['newer_metadata'].must_equal 'this is newer' + _(check_metadata.size).must_equal 2 + _(check_metadata['some_metadata']).must_equal 'this is updated again' + _(check_metadata['newer_metadata']).must_equal 'this is newer' # delete metadata volume.delete_metadata('some_metadata') updated_volume = @service.volumes.get(volume.id) check_metadata = updated_volume.metadata - check_metadata.size.must_equal 1 - check_metadata['newer_metadata'].must_equal 'this is newer' + _(check_metadata.size).must_equal 1 + _(check_metadata['newer_metadata']).must_equal 'this is newer' ensure # cleanup volume cleanup_test_object(@service.volumes, volume.id) if volume @@ -512,7 +517,7 @@ def cleanup_test_object(collection, id) Fog.wait_for do begin object = @service.snapshots.get(snapshot_id) - object.wont_be_nil + _(object).wont_be_nil puts "Current status: #{object ? object.status : 'deleted'}" if ENV['DEBUG_VERBOSE'] object.nil? || (%w[available error].include? object.status.downcase) end @@ -520,7 +525,7 @@ def cleanup_test_object(collection, id) updated_snapshot = @service.snapshots.get(snapshot_id) check_metadata = updated_snapshot.metadata - check_metadata.size.must_equal 0 + _(check_metadata.size).must_equal 0 # update metadata snapshot.update_metadata('some_snapshot_metadata' => 'this is data', @@ -528,17 +533,17 @@ def cleanup_test_object(collection, id) updated_snapshot = @service.snapshots.get(snapshot_id) check_metadata = updated_snapshot.metadata - check_metadata.size.must_equal 2 - check_metadata['some_snapshot_metadata'].must_equal 'this is data' - check_metadata['new_snapshot_metadata'].must_equal 'this is new' + _(check_metadata.size).must_equal 2 + _(check_metadata['some_snapshot_metadata']).must_equal 'this is data' + _(check_metadata['new_snapshot_metadata']).must_equal 'this is new' # delete metadata snapshot.delete_metadata('some_snapshot_metadata') updated_snapshot = @service.snapshots.get(snapshot_id) check_metadata = updated_snapshot.metadata - check_metadata.size.must_equal 1 - check_metadata['new_snapshot_metadata'].must_equal 'this is new' + _(check_metadata.size).must_equal 1 + _(check_metadata['new_snapshot_metadata']).must_equal 'this is new' ensure # cleanup volume cleanup_test_object(@service.snapshots, snapshot.id) if snapshot @@ -549,7 +554,7 @@ def cleanup_test_object(collection, id) # TODO: tests for snapshots it 'responds to list_snapshots_detailed' do - @service.respond_to?(:list_snapshots_detailed).must_equal true + _(@service.respond_to?(:list_snapshots_detailed)).must_equal true end # TODO: tests for quotas diff --git a/test/authenticate_tests.rb b/test/authenticate_tests.rb index ebc9dab21..81f6d314a 100644 --- a/test/authenticate_tests.rb +++ b/test/authenticate_tests.rb @@ -134,9 +134,9 @@ :openstack_service_type => %w[network], :openstack_api_key => 'secret', :openstack_username => 'user') - proc do + _(proc do service.send(:authenticate) - end.must_raise Fog::OpenStack::Auth::Catalog::ServiceTypeError + end).must_raise Fog::OpenStack::Auth::Catalog::ServiceTypeError end it "v2 missing storage service" do @@ -155,9 +155,9 @@ :openstack_username => 'user', :openstack_service_type => 'object-store') - proc do + _(proc do service.send(:authenticate) - end.must_raise Fog::OpenStack::Auth::Catalog::ServiceTypeError + end).must_raise Fog::OpenStack::Auth::Catalog::ServiceTypeError end it "v2 auth with two compute services" do @@ -192,9 +192,9 @@ :openstack_username => 'user', :openstack_service_type => 'compute') - proc do + _(proc do service.send(:authenticate) - end.must_raise Fog::OpenStack::Auth::Catalog::EndpointError, 'Multiple endpoints found' + end).must_raise Fog::OpenStack::Auth::Catalog::EndpointError, 'Multiple endpoints found' end after do diff --git a/test/helpers/collection_helper.rb b/test/helpers/collection_helper.rb index 85260ad65..f59aa04bd 100644 --- a/test/helpers/collection_helper.rb +++ b/test/helpers/collection_helper.rb @@ -10,13 +10,13 @@ def collection_tests(collection, params = {}) it "#new(#{params.inspect})" do unless Fog.mocking? - collection.new(params).must_equal 200 + _(collection.new(params)).must_equal 200 end end it "#create(#{params.inspect})" do unless Fog.mocking? - @instance.must_be_kind_of Fog::OpenStack::Network::SecurityGroup + _(@instance).must_be_kind_of Fog::OpenStack::Network::SecurityGroup end end @@ -27,13 +27,13 @@ def collection_tests(collection, params = {}) it "#all" do unless Fog.mocking? - collection.all.must_be_kind_of Fog::OpenStack::Network::SecurityGroups + _(collection.all).must_be_kind_of Fog::OpenStack::Network::SecurityGroups end end it "#get(#{@identity})" do unless Fog.mocking? - collection.get(@identity).must_be_kind_of Fog::OpenStack::Network::SecurityGroup + _(collection.get(@identity)).must_be_kind_of Fog::OpenStack::Network::SecurityGroup end end @@ -52,7 +52,7 @@ def collection_tests(collection, params = {}) it "##{enum_method}" do block_called = false collection.send(enum_method) { block_called = true } - block_called.must_equal true + _(block_called).must_equal true end end end @@ -65,7 +65,7 @@ def collection_tests(collection, params = {}) block_called = true return 0 end - block_called.must_equal true + _(block_called).must_equal true end end end @@ -95,7 +95,7 @@ def collection_tests(collection, params = {}) it "#get(@identity" do unless Fog.mocking? - collection.get(@identity).must_equal nil + _(collection.get(@identity)).must_be_nil end end end diff --git a/test/helpers/model_helper.rb b/test/helpers/model_helper.rb index 35cf25a56..ea31b20c3 100644 --- a/test/helpers/model_helper.rb +++ b/test/helpers/model_helper.rb @@ -10,13 +10,13 @@ def model_tests(collection, params = {}) it "#save" do unless Fog.mocking? - @instance.save.must_equal true + _(@instance.save).must_equal true end end it "#destroy" do unless Fog.mocking? - @instance.destroy.must_equal 200 + _(@instance.destroy).must_equal 200 end end end diff --git a/test/microversion_test.rb b/test/microversion_test.rb index 8cc4d00dd..ed0862b2d 100644 --- a/test/microversion_test.rb +++ b/test/microversion_test.rb @@ -9,7 +9,7 @@ describe "is nil" do it "should not appear in headers" do merged_headers = @microversion_tester.send(:headers, {}) - merged_headers.key?("X-Test-Header").must_equal false + _(merged_headers.key?("X-Test-Header")).must_equal false end end @@ -18,8 +18,8 @@ @microversion_tester.instance_variable_set(:@microversion, "2.15") @microversion_tester.instance_variable_set(:@microversion_key, "X-Test-Header") merged_headers = @microversion_tester.send(:headers, {}) - merged_headers.key?("X-Test-Header").must_equal true - merged_headers["X-Test-Header"].must_equal "2.15" + _(merged_headers.key?("X-Test-Header")).must_equal true + _(merged_headers["X-Test-Header"]).must_equal "2.15" end end @@ -28,7 +28,7 @@ @microversion_tester.instance_variable_set(:@microversion, "") @microversion_tester.instance_variable_set(:@microversion_key, "X-Test-Header") merged_headers = @microversion_tester.send(:headers, {}) - merged_headers.key?("X-Test-Header").must_equal false + _(merged_headers.key?("X-Test-Header")).must_equal false end end end diff --git a/test/models/compute/images_tests.rb b/test/models/compute/images_tests.rb index 81e599882..448918c44 100644 --- a/test/models/compute/images_tests.rb +++ b/test/models/compute/images_tests.rb @@ -6,11 +6,11 @@ let (:fog) { Fog::OpenStack::Compute.new } it "must be an Array" do - fog.images.all.must_be_kind_of Array + _(fog.images.all).must_be_kind_of Array end it "wont be nil" do - fog.images.all.wont_be_nil + _(fog.images.all).wont_be_nil end end end diff --git a/test/models/compute/security_group_tests.rb b/test/models/compute/security_group_tests.rb index ca287e30e..54c870c5e 100644 --- a/test/models/compute/security_group_tests.rb +++ b/test/models/compute/security_group_tests.rb @@ -16,19 +16,19 @@ describe "#create" do it "name" do - security_group.name.must_equal 'my_group' + _(security_group.name).must_equal 'my_group' end it "description" do - security_group.description.must_equal 'my group' + _(security_group.description).must_equal 'my group' end it "security_group_rules" do - security_group.security_group_rules.must_equal [] + _(security_group.security_group_rules).must_equal [] end it "tenant_id" do - security_group.tenant_id.wont_be_nil + _(security_group.tenant_id).wont_be_nil end end @@ -42,9 +42,9 @@ :to_port => 1234, :ip_range => {"cidr" => "0.0.0.0/0"} ) - security_group.security_group_rules.count.must_equal(rules_count + 1) + _(security_group.security_group_rules.count).must_equal(rules_count + 1) security_group_rule = security_group.security_group_rules.find { |r| r.id == rule.id } - security_group_rule.attributes.must_equal rule.attributes + _(security_group_rule.attributes).must_equal rule.attributes end it "#destroy" do @@ -58,7 +58,7 @@ :ip_range => {"cidr" => "0.0.0.0/0"} ) rule.destroy - rule.reload.must_equal nil + _(rule.reload).must_be_nil end end end diff --git a/test/models/compute/server_group_tests.rb b/test/models/compute/server_group_tests.rb index 91fbdeb2d..8c71154a5 100644 --- a/test/models/compute/server_group_tests.rb +++ b/test/models/compute/server_group_tests.rb @@ -4,7 +4,7 @@ describe "validate_server_group_policy" do it "contains only allowed policies" do ['affinity', 'anti-affinity', 'soft-affinity', 'soft-anti-affinity'].each do |policy| - Fog::OpenStack::Compute::ServerGroup.validate_server_group_policy(policy).must_equal true + _(Fog::OpenStack::Compute::ServerGroup.validate_server_group_policy(policy)).must_equal true end end diff --git a/test/models/compute/server_tests.rb b/test/models/compute/server_tests.rb index 841a63685..49bc64f5c 100644 --- a/test/models/compute/server_tests.rb +++ b/test/models/compute/server_tests.rb @@ -21,7 +21,7 @@ server.associate_address(ip1.fixed_ip_address) server.reload - server.floating_ip_addresses.must_equal(["192.168.11.3"]) + _(server.floating_ip_addresses).must_equal(["192.168.11.3"]) end describe "#security_groups" do @@ -64,15 +64,15 @@ end it "groups size" do - found_groups.length.must_equal 1 + _(found_groups.length).must_equal 1 end it "name" do - group.name.must_equal 'my_group' + _(group.name).must_equal 'my_group' end it "" do - group.service.must_equal server.service + _(group.service).must_equal server.service end end @@ -87,7 +87,7 @@ :image_ref => image, :state => 'success' ) - server.failed?.must_equal false + _(server.failed?).must_equal false end it "fails server creation" do @@ -97,7 +97,7 @@ :image_ref => image, :state => 'ERROR' ) - server.failed?.must_equal true + _(server.failed?).must_equal true end end @@ -127,7 +127,7 @@ server.save - server.metadata.length.must_equal 1 + _(server.metadata.length).must_equal 1 server.metadata.each do |datum| datum.value = 'foo' @@ -218,20 +218,20 @@ end it "volume size" do - volumes.length.must_equal 1 + _(volumes.length).must_equal 1 end it "name" do - volumes.first.name.must_equal 'test volume' + _(volumes.first.name).must_equal 'test volume' end it "volume_attachments size" do - volume_attachments.length.must_equal 1 + _(volume_attachments.length).must_equal 1 end it "volume_attachments device" do attachment = volume_attachments.first - attachment['device'].must_equal '/dev/vdc' + _(attachment['device']).must_equal '/dev/vdc' end describe "detach volume" do @@ -242,12 +242,12 @@ it "has no volumes" do found_volumes = server.volumes - found_volumes.length.must_equal 0 + _(found_volumes.length).must_equal 0 end it "has no volume_attachments" do found_attachments = server.volume_attachments - found_attachments.length.must_equal 0 + _(found_attachments.length).must_equal 0 end end end diff --git a/test/models/compute/service_tests.rb b/test/models/compute/service_tests.rb index d692bdadc..bebd176bd 100644 --- a/test/models/compute/service_tests.rb +++ b/test/models/compute/service_tests.rb @@ -8,16 +8,16 @@ end it "#all" do - @service.state.must_equal "up" + _(@service.state).must_equal "up" end it "#get" do service = Fog::OpenStack::Compute.new.services.get(@service.id) - %w(id binary host).all? do |attr| + _(%w(id binary host).all? do |attr| attr1 = service.send(attr.to_sym) attr2 = @service.send(attr.to_sym) attr1 == attr2 - end.must_equal true + end).must_equal true end end end diff --git a/test/models/container_infra/bay_model_tests.rb b/test/models/container_infra/bay_model_tests.rb index a71cf4742..391a61b69 100644 --- a/test/models/container_infra/bay_model_tests.rb +++ b/test/models/container_infra/bay_model_tests.rb @@ -17,16 +17,16 @@ end it "#create" do - @instance.uuid.wont_be_nil + _(@instance.uuid).wont_be_nil end it "#update" do @instance.name = 'rename-test-bay-model' - @instance.update.name.must_equal 'rename-test-bay-model' + _(@instance.update.name).must_equal 'rename-test-bay-model' end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/container_infra/bay_tests.rb b/test/models/container_infra/bay_tests.rb index 409735be2..ec51ee273 100644 --- a/test/models/container_infra/bay_tests.rb +++ b/test/models/container_infra/bay_tests.rb @@ -11,16 +11,16 @@ end it "#create" do - @instance.uuid.wont_be_nil + _(@instance.uuid).wont_be_nil end it "#update" do @instance.name = 'rename-test-cluster' - @instance.update.name.must_equal "rename-test-cluster" + _(@instance.update.name).must_equal "rename-test-cluster" end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/container_infra/certificate_tests.rb b/test/models/container_infra/certificate_tests.rb index 4457a103e..db374c415 100644 --- a/test/models/container_infra/certificate_tests.rb +++ b/test/models/container_infra/certificate_tests.rb @@ -11,12 +11,12 @@ end it "#create" do - @instance.pem.wont_be_nil + _(@instance.pem).wont_be_nil end it "#get" do @instance = container_infra.certificates.get("0562d357-8641-4759-8fed-8173f02c9633") - @instance.pem.wont_be_nil + _(@instance.pem).wont_be_nil end end end diff --git a/test/models/container_infra/cluster_template_tests.rb b/test/models/container_infra/cluster_template_tests.rb index 828e3df5f..ebba7c74e 100644 --- a/test/models/container_infra/cluster_template_tests.rb +++ b/test/models/container_infra/cluster_template_tests.rb @@ -18,16 +18,16 @@ end it "#create" do - @instance.uuid.wont_be_nil + _(@instance.uuid).wont_be_nil end it "#update" do @instance.name = 'rename-test-cluster-template' - @instance.update.name.must_equal 'rename-test-cluster-template' + _(@instance.update.name).must_equal 'rename-test-cluster-template' end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/container_infra/cluster_tests.rb b/test/models/container_infra/cluster_tests.rb index 349a92d20..7d08a55c0 100644 --- a/test/models/container_infra/cluster_tests.rb +++ b/test/models/container_infra/cluster_tests.rb @@ -11,16 +11,16 @@ end it "#create" do - @instance.uuid.wont_be_nil + _(@instance.uuid).wont_be_nil end it "#update" do @instance.name = 'rename-test-cluster' - @instance.update.name.must_equal "rename-test-cluster" + _(@instance.update.name).must_equal "rename-test-cluster" end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/identity/ec2_credential_tests.rb b/test/models/identity/ec2_credential_tests.rb index 09b97863f..bd1df6c26 100644 --- a/test/models/identity/ec2_credential_tests.rb +++ b/test/models/identity/ec2_credential_tests.rb @@ -30,15 +30,15 @@ describe "success" do it "#destroy" do - @ec2_credential.destroy.must_equal(true) + _(@ec2_credential.destroy).must_equal(true) end end describe "failure" do it "#save" do - proc do + _(proc do @ec2_credential.save - end.must_raise(Fog::Errors::Error) + end).must_raise(Fog::Errors::Error) end end end diff --git a/test/models/identity/ec2_credentials_tests.rb b/test/models/identity/ec2_credentials_tests.rb index 8f673d020..0538422ed 100644 --- a/test/models/identity/ec2_credentials_tests.rb +++ b/test/models/identity/ec2_credentials_tests.rb @@ -30,32 +30,32 @@ ec2_credential = @user.ec2_credentials.find_by_access_key(@ec2_credential.access) - ec2_credential.access.must_equal @ec2_credential.access + _(ec2_credential.access).must_equal @ec2_credential.access end it "#create" do - @user.ec2_credentials.create.tenant_id.wont_be_empty + _(@user.ec2_credentials.create.tenant_id).wont_be_empty end it "#destroy" do - @user.ec2_credentials.destroy(@ec2_credential.access).must_equal true + _(@user.ec2_credentials.destroy(@ec2_credential.access)).must_equal true end end describe "fails" do it "#find_by_access_key" do unless Fog.mocking? - proc do + _(proc do @user.ec2_credentials.find_by_access_key('fake') - end.must_raise(Fog::OpenStack::Identity::NotFound) + end).must_raise(Fog::OpenStack::Identity::NotFound) end end it "#destroy" do unless Fog.mocking? - proc do + _(proc do @user.ec2_credentials.destroy('fake') - end.must_raise(Fog::OpenStack::Identity::NotFound) + end).must_raise(Fog::OpenStack::Identity::NotFound) end end end diff --git a/test/models/identity/role_tests.rb b/test/models/identity/role_tests.rb index b46adf880..49e6a74f5 100644 --- a/test/models/identity/role_tests.rb +++ b/test/models/identity/role_tests.rb @@ -24,19 +24,19 @@ describe "success" do it "#save" do - @instance_saved.must_equal true + _(@instance_saved).must_equal true end it "#add_to_user(@user.id, @tenant.id)" do - @instance.add_to_user(@user.id, @tenant.id).must_equal true + _(@instance.add_to_user(@user.id, @tenant.id)).must_equal true end it "#remove_to_user(@user.id, @tenant.id)" do - @instance.remove_to_user(@user.id, @tenant.id).must_equal true + _(@instance.remove_to_user(@user.id, @tenant.id)).must_equal true end it "#destroy" do - @instance.destroy.must_equal(true) + _(@instance.destroy).must_equal(true) end end end diff --git a/test/models/identity/roles_tests.rb b/test/models/identity/roles_tests.rb index cef09c724..7d6a999a6 100644 --- a/test/models/identity/roles_tests.rb +++ b/test/models/identity/roles_tests.rb @@ -17,11 +17,11 @@ describe "success" do it "#all" do - @roles.all.must_be_kind_of Fog::OpenStack::Identity::V2::Roles + _(@roles.all).must_be_kind_of Fog::OpenStack::Identity::V2::Roles end it "#get" do - @roles.get(@roles.first.id).body.wont_be_nil + _(@roles.get(@roles.first.id).body).wont_be_nil end end end diff --git a/test/models/identity/tenant_tests.rb b/test/models/identity/tenant_tests.rb index a883ea219..4ed214249 100644 --- a/test/models/identity/tenant_tests.rb +++ b/test/models/identity/tenant_tests.rb @@ -16,7 +16,7 @@ it "#users" do instance = @identity.tenants.first - instance.users.count.wont_equal @identity.users.count + _(instance.users.count).wont_equal @identity.users.count end end @@ -26,16 +26,16 @@ end it "#create" do - @instance.id.nil?.wont_be_nil + _(@instance.id.nil?).wont_be_nil end it "#update" do @instance.update(:name => 'test2') - @instance.name.must_equal 'test2' + _(@instance.name).must_equal 'test2' end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/identity/tenants_tests.rb b/test/models/identity/tenants_tests.rb index 17f1a3948..57d0ea78b 100644 --- a/test/models/identity/tenants_tests.rb +++ b/test/models/identity/tenants_tests.rb @@ -9,28 +9,28 @@ describe "success" do it "#find_by_id" do tenant = @identity.tenants.find_by_id(@instance.id) - tenant.id.must_equal @instance.id + _(tenant.id).must_equal @instance.id end it "#destroy" do - @identity.tenants.destroy(@instance.id).must_equal true + _(@identity.tenants.destroy(@instance.id)).must_equal true end end describe "failure" do it "#find_by_id" do unless Fog.mocking? - proc do + _(proc do @identity.tenants.find_by_id('fake') - end.must_raise(Fog::OpenStack::Identity::NotFound) + end).must_raise(Fog::OpenStack::Identity::NotFound) end end it "#destroy" do unless Fog.mocking? - proc do + _(proc do @identity.tenants.destroy('fake') - end.must_raise(Fog::OpenStack::Identity::NotFound) + end).must_raise(Fog::OpenStack::Identity::NotFound) end end end diff --git a/test/models/identity/user_tests.rb b/test/models/identity/user_tests.rb index e4774fe7d..a24492414 100644 --- a/test/models/identity/user_tests.rb +++ b/test/models/identity/user_tests.rb @@ -19,41 +19,41 @@ end it "#save" do - @instance_saved.must_equal true + _(@instance_saved).must_equal true end it "#roles" do - @instance.roles.must_be_empty + _(@instance.roles).must_be_empty end it "#update" do - @instance.update(:name => 'updatename', :email => 'new@email.com'). + _(@instance.update(:name => 'updatename', :email => 'new@email.com')). must_equal true end it "#update_password" do - @instance.update_password('swordfish').must_equal true + _(@instance.update_password('swordfish')).must_equal true end it "#update_tenant" do - @instance.update_tenant(@tenant_id).must_equal true + _(@instance.update_tenant(@tenant_id)).must_equal true end it "#update_enabled" do - @instance.update_enabled(true).must_equal true + _(@instance.update_enabled(true)).must_equal true end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end describe "failure" do it "#save" do skip - proc do + _(proc do @instance.save - end.must_raise(Fog::Errors::Error) + end).must_raise(Fog::Errors::Error) end end end diff --git a/test/models/identity/users_tests.rb b/test/models/identity/users_tests.rb index bc1c750c4..943ac0f5b 100644 --- a/test/models/identity/users_tests.rb +++ b/test/models/identity/users_tests.rb @@ -16,41 +16,41 @@ describe "success" do it "#find_by_id" do user = @identity.users.find_by_id(@instance.id) - user.id.must_equal @instance.id + _(user.id).must_equal @instance.id end it "#find_by_name" do user = @identity.users.find_by_name(@instance.name) - user.name.must_equal @instance.name + _(user.name).must_equal @instance.name end it "#destroy" do - @identity.users.destroy(@instance.id).must_equal true + _(@identity.users.destroy(@instance.id)).must_equal true end end describe "fails" do it "#find_by_id" do unless Fog.mocking? - proc do + _(proc do Fog::Identity[:openstack].users.find_by_id('fake') - end.must_raise(Fog::OpenStack::Identity::NotFound) + end).must_raise(Fog::OpenStack::Identity::NotFound) end end it "#find_by_name" do unless Fog.mocking? - proc do + _(proc do Fog::Identity[:openstack].users.find_by_name('fake') - end.must_raise(Fog::OpenStack::Identity::NotFound) + end).must_raise(Fog::OpenStack::Identity::NotFound) end end it "#destroy" do unless Fog.mocking? - proc do + _(proc do Fog::Identity[:openstack].users.destroy('fake') - end.must_raise(Fog::OpenStack::Identity::NotFound) + end).must_raise(Fog::OpenStack::Identity::NotFound) end end end diff --git a/test/models/image/image_tests.rb b/test/models/image/image_tests.rb index 79e61b544..b3b6fe791 100644 --- a/test/models/image/image_tests.rb +++ b/test/models/image/image_tests.rb @@ -7,33 +7,33 @@ end it "#create" do - @instance.id.nil?.wont_be_nil + _(@instance.id.nil?).wont_be_nil end it "#update" do @instance.name = 'edit test image' @instance.update - @instance.name.must_equal 'edit test image' + _(@instance.name).must_equal 'edit test image' end it "#get image metadata" do - @instance.metadata["X-Image-Meta-Status"].must_equal "active" + _(@instance.metadata["X-Image-Meta-Status"]).must_equal "active" end it "#add member" do - [200, 204].must_include(@instance.add_member(@instance.owner).status) + _([200, 204]).must_include(@instance.add_member(@instance.owner).status) end it "#show members" do - @instance.members[0]["member_id"].wont_be_empty + _(@instance.members[0]["member_id"]).wont_be_empty end it "#remove member" do - [200, 204].must_include(@instance.remove_member(@instance.owner).status) + _([200, 204]).must_include(@instance.remove_member(@instance.owner).status) end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/image/images_tests.rb b/test/models/image/images_tests.rb index 8b5f3eaf0..cfa258e3b 100644 --- a/test/models/image/images_tests.rb +++ b/test/models/image/images_tests.rb @@ -7,16 +7,16 @@ describe "success" do it "#find_by_id" do image = Fog::OpenStack::Image.new.images.find_by_id(@instance['image']['id']) - image.id.must_equal @instance['image']['id'] + _(image.id).must_equal @instance['image']['id'] end it "#get" do image = Fog::OpenStack::Image.new.images.get(@instance['image']['id']) - image.id.must_equal @instance['image']['id'] + _(image.id).must_equal @instance['image']['id'] end it "#destroy" do - Fog::OpenStack::Image.new.images.destroy(@instance['image']['id']).must_equal true + _(Fog::OpenStack::Image.new.images.destroy(@instance['image']['id'])).must_equal true end end end diff --git a/test/models/network/floating_ip_tests.rb b/test/models/network/floating_ip_tests.rb index bf0656819..a287afdb6 100644 --- a/test/models/network/floating_ip_tests.rb +++ b/test/models/network/floating_ip_tests.rb @@ -14,12 +14,12 @@ end it "#create" do - instance.id.wont_be_nil + _(instance.id).wont_be_nil end it "#update" do instance.port_id = 'p0000000-0000-0000-0000-000000000000' - instance.update.port_id.must_equal "p0000000-0000-0000-0000-000000000000" + _(instance.update.port_id).must_equal "p0000000-0000-0000-0000-000000000000" end describe "#associate" do @@ -28,11 +28,11 @@ let(:associate) { instance.associate(port_id, fixed_ip_address) } it "must match port_id" do - associate.port_id.must_equal port_id + _(associate.port_id).must_equal port_id end it "must match fixed_ip_address" do - associate.fixed_ip_address.must_equal fixed_ip_address + _(associate.fixed_ip_address).must_equal fixed_ip_address end end @@ -41,11 +41,11 @@ let(:disassociate) { instance.disassociate(fixed_ip_address) } it "resets port_id" do - disassociate.port_id.must_equal nil + _(disassociate.port_id).must_be_nil end it "resets fixed_ip_address" do - disassociate.fixed_ip_address.must_equal nil + _(disassociate.fixed_ip_address).must_be_nil end end diff --git a/test/models/network/floating_ips_tests.rb b/test/models/network/floating_ips_tests.rb index ed349ad5b..49feb7f67 100644 --- a/test/models/network/floating_ips_tests.rb +++ b/test/models/network/floating_ips_tests.rb @@ -15,14 +15,14 @@ describe "success" do it "#all" do - @floating_ips.all[0].id.wont_be_nil + _(@floating_ips.all[0].id).wont_be_nil end it "#get" do # Something wrong here - Test fails when there are several floating ips # not properly garbage collected skip - @floating_ips.get(@floating_ip.id).id.must_equal @floating_ip.id + _(@floating_ips.get(@floating_ip.id).id).must_equal @floating_ip.id end end end diff --git a/test/models/network/ike_policies_tests.rb b/test/models/network/ike_policies_tests.rb index 0149ffcc9..e84f22abe 100644 --- a/test/models/network/ike_policies_tests.rb +++ b/test/models/network/ike_policies_tests.rb @@ -27,11 +27,11 @@ describe "success" do it "#all" do - @ike_policies.all[0].description.must_equal "Test VPN IKE Policy" + _(@ike_policies.all[0].description).must_equal "Test VPN IKE Policy" end it "#get" do - @ike_policies.get(@ike_policy.id).name.must_equal 'test-ike-policy' + _(@ike_policies.get(@ike_policy.id).name).must_equal 'test-ike-policy' end end end diff --git a/test/models/network/ike_policy_tests.rb b/test/models/network/ike_policy_tests.rb index fb82f19f8..506116b4e 100644 --- a/test/models/network/ike_policy_tests.rb +++ b/test/models/network/ike_policy_tests.rb @@ -21,7 +21,7 @@ end it "#create" do - @instance.id.wont_be_nil + _(@instance.id).wont_be_nil end it "#update" do @@ -34,11 +34,11 @@ @phase1_negotiation_mode = 'main' @ike_version = 'v1' @lifetime = {'units' => 'seconds', 'value' => 3600} - @instance.update.name.must_equal "rename-test-ike-policy" + _(@instance.update.name).must_equal "rename-test-ike-policy" end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/network/ipsec_policies_tests.rb b/test/models/network/ipsec_policies_tests.rb index 4a9911406..8009742a9 100644 --- a/test/models/network/ipsec_policies_tests.rb +++ b/test/models/network/ipsec_policies_tests.rb @@ -25,11 +25,11 @@ describe "success" do it "#all" do - @ipsec_policies.all[0].description.must_equal 'Test VPN ipsec Policy' + _(@ipsec_policies.all[0].description).must_equal 'Test VPN ipsec Policy' end it "#get" do - @ipsec_policies.get(@ipsec_policy.id).name.must_equal "test-ipsec-policy" + _(@ipsec_policies.get(@ipsec_policy.id).name).must_equal "test-ipsec-policy" end end end diff --git a/test/models/network/ipsec_policy_tests.rb b/test/models/network/ipsec_policy_tests.rb index bef9e84f4..e3f7a9f2f 100644 --- a/test/models/network/ipsec_policy_tests.rb +++ b/test/models/network/ipsec_policy_tests.rb @@ -21,7 +21,7 @@ end it "#create" do - @instance.id.wont_be_nil + _(@instance.id).wont_be_nil end it "#update" do @@ -34,11 +34,11 @@ @instance.transform_protocol = 'espn' @instance.encapsulation_mode = 'tunnel' @instance.lifetime = {'units' => 'seconds', 'value' => 3600} - @instance.update.name.must_equal 'rename-test-ipsec-policy' + _(@instance.update.name).must_equal 'rename-test-ipsec-policy' end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/network/ipsec_site_connection_tests.rb b/test/models/network/ipsec_site_connection_tests.rb index 025a45160..3dba7a8bf 100644 --- a/test/models/network/ipsec_site_connection_tests.rb +++ b/test/models/network/ipsec_site_connection_tests.rb @@ -28,7 +28,7 @@ end it "#create" do - @instance.id.wont_be_nil + _(@instance.id).wont_be_nil end it "#update" do @@ -48,11 +48,11 @@ "timeout" => 120 } - @instance.update.name.must_equal "rename-test-ipsec-site-connection" + _(@instance.update.name).must_equal "rename-test-ipsec-site-connection" end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/network/ipsec_site_connections_tests.rb b/test/models/network/ipsec_site_connections_tests.rb index 02ff78e44..3053a4a9c 100644 --- a/test/models/network/ipsec_site_connections_tests.rb +++ b/test/models/network/ipsec_site_connections_tests.rb @@ -30,11 +30,11 @@ describe "success" do it "#all" do - @ipsec_site_connections.all[0].status.must_equal "ACTIVE" + _(@ipsec_site_connections.all[0].status).must_equal "ACTIVE" end it "#get" do - @ipsec_site_connections.get(@ipsec_site_connection.id).status.must_equal "ACTIVE" + _(@ipsec_site_connections.get(@ipsec_site_connection.id).status).must_equal "ACTIVE" end end end diff --git a/test/models/network/lb_health_monitor_tests.rb b/test/models/network/lb_health_monitor_tests.rb index 8aa96723e..1512ff6d8 100644 --- a/test/models/network/lb_health_monitor_tests.rb +++ b/test/models/network/lb_health_monitor_tests.rb @@ -28,7 +28,7 @@ end it "#create" do - @instance.id.wont_be_nil + _(@instance.id).wont_be_nil end it "#update" do @@ -39,19 +39,19 @@ @instance.url_path = '/varz' @instance.expected_codes = '200' @instance.admin_state_up = false - @instance.update.expected_codes.must_equal "200" + _(@instance.update.expected_codes).must_equal "200" end it "#associate_to_pool" do - @instance.associate_to_pool(@lb_pool.id).must_equal true + _(@instance.associate_to_pool(@lb_pool.id)).must_equal true end it "#disassociate_from_pool" do - @instance.disassociate_from_pool(@lb_pool.id).must_equal true + _(@instance.disassociate_from_pool(@lb_pool.id)).must_equal true end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/network/lb_health_monitors_tests.rb b/test/models/network/lb_health_monitors_tests.rb index 0546432cf..239e3f134 100644 --- a/test/models/network/lb_health_monitors_tests.rb +++ b/test/models/network/lb_health_monitors_tests.rb @@ -18,11 +18,11 @@ describe "success" do it "#all" do - @lb_health_monitors.all[0].status.must_equal "ACTIVE" + _(@lb_health_monitors.all[0].status).must_equal "ACTIVE" end it "#get" do - @lb_health_monitors.get(@lb_health_monitor.id).status.must_equal "ACTIVE" + _(@lb_health_monitors.get(@lb_health_monitor.id).status).must_equal "ACTIVE" end end end diff --git a/test/models/network/lb_member_tests.rb b/test/models/network/lb_member_tests.rb index 69da26787..de586f246 100644 --- a/test/models/network/lb_member_tests.rb +++ b/test/models/network/lb_member_tests.rb @@ -15,18 +15,18 @@ end it "#create" do - @instance.id.wont_be_nil + _(@instance.id).wont_be_nil end it "#update" do @instance.pool_id = 'new_pool_id' @instance.weight = 50 @instance.admin_state_up = false - @instance.update.status.must_equal "ACTIVE" + _(@instance.update.status).must_equal "ACTIVE" end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/network/lb_members_tests.rb b/test/models/network/lb_members_tests.rb index c43161936..add881982 100644 --- a/test/models/network/lb_members_tests.rb +++ b/test/models/network/lb_members_tests.rb @@ -18,11 +18,11 @@ describe "success" do it "#all" do - @lb_members.all[0].status.must_equal "ACTIVE" + _(@lb_members.all[0].status).must_equal "ACTIVE" end it "#get" do - @lb_members.get(@lb_member.id).status.must_equal "ACTIVE" + _(@lb_members.get(@lb_member.id).status).must_equal "ACTIVE" end end end diff --git a/test/models/network/lb_pool_tests.rb b/test/models/network/lb_pool_tests.rb index 350ee2f4e..3a7a54c37 100644 --- a/test/models/network/lb_pool_tests.rb +++ b/test/models/network/lb_pool_tests.rb @@ -27,7 +27,7 @@ end it "#create" do - @instance.id.wont_be_nil + _(@instance.id).wont_be_nil end it "#update" do @@ -35,24 +35,24 @@ @instance.description = 'New Test Pool' @instance.lb_method = 'LEAST_CONNECTIONS' @instance.admin_state_up = false - @instance.update.status.must_equal "ACTIVE" + _(@instance.update.status).must_equal "ACTIVE" end it "#stats" do @instance.stats - @instance.active_connections.wont_be_nil + _(@instance.active_connections).wont_be_nil end it "#associate_health_monitor" do - @instance.associate_health_monitor(@lb_health_monitor.id).must_equal true + _(@instance.associate_health_monitor(@lb_health_monitor.id)).must_equal true end it "#disassociate_health_monitor" do - @instance.disassociate_health_monitor(@lb_health_monitor.id).must_equal true + _(@instance.disassociate_health_monitor(@lb_health_monitor.id)).must_equal true end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/network/lb_pools_tests.rb b/test/models/network/lb_pools_tests.rb index 9ade42c74..9198137c8 100644 --- a/test/models/network/lb_pools_tests.rb +++ b/test/models/network/lb_pools_tests.rb @@ -18,11 +18,11 @@ describe "success" do it "#all" do - @lb_pools.all[0].status.must_equal "ACTIVE" + _(@lb_pools.all[0].status).must_equal "ACTIVE" end it "#get" do - @lb_pools.get(@lb_pool.id).status.must_equal "ACTIVE" + _(@lb_pools.get(@lb_pool.id).status).must_equal "ACTIVE" end end end diff --git a/test/models/network/lb_vip_tests.rb b/test/models/network/lb_vip_tests.rb index 37cadd52c..d6c7bc69e 100644 --- a/test/models/network/lb_vip_tests.rb +++ b/test/models/network/lb_vip_tests.rb @@ -25,11 +25,11 @@ end after do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end it "#create" do - @instance.id.wont_be_nil + _(@instance.id).wont_be_nil end it "#update" do @@ -39,7 +39,7 @@ @instance.session_persistence = {"type" => "HTTP_COOKIE"} @instance.connection_limit = 5 @instance.admin_state_up = false - @instance.update.status.must_equal "ACTIVE" + _(@instance.update.status).must_equal "ACTIVE" end end end diff --git a/test/models/network/lb_vips_tests.rb b/test/models/network/lb_vips_tests.rb index 9adf25765..dd1193dff 100644 --- a/test/models/network/lb_vips_tests.rb +++ b/test/models/network/lb_vips_tests.rb @@ -18,11 +18,11 @@ describe "success" do it "#all" do - @lb_vips.all[0].status.must_equal "ACTIVE" + _(@lb_vips.all[0].status).must_equal "ACTIVE" end it "#get" do - @lb_vips.get(@lb_vip.id).status.must_equal "ACTIVE" + _(@lb_vips.get(@lb_vip.id).status).must_equal "ACTIVE" end end end diff --git a/test/models/network/network_tests.rb b/test/models/network/network_tests.rb index 946bb7635..75c1b0b13 100644 --- a/test/models/network/network_tests.rb +++ b/test/models/network/network_tests.rb @@ -13,7 +13,7 @@ end it "#create" do - @instance.id.wont_be_nil + _(@instance.id).wont_be_nil end it "#create+extensions" do @@ -30,9 +30,9 @@ :provider_segmentation_id => 22 ) - net.status.must_equal "ACTIVE" + _(net.status).must_equal "ACTIVE" net.destroy - net.provider_network_type.must_equal 'gre' + _(net.provider_network_type).must_equal 'gre' end describe "The network model should respond to" do @@ -53,18 +53,18 @@ it "attributes" do @attributes.each do |attribute| - @instance.respond_to?(attribute).must_equal true + _(@instance.respond_to?(attribute)).must_equal true end end end it "#update" do @instance.name = 'new_net_name' - @instance.update.status.must_equal "ACTIVE" + _(@instance.update.status).must_equal "ACTIVE" end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/network/networks_tests.rb b/test/models/network/networks_tests.rb index abdb6214e..6a5de108f 100644 --- a/test/models/network/networks_tests.rb +++ b/test/models/network/networks_tests.rb @@ -19,11 +19,11 @@ describe "success" do it "#all" do - @networks.all[0].status.must_equal "ACTIVE" + _(@networks.all[0].status).must_equal "ACTIVE" end it "#get" do - @networks.get(@network.id).status.must_equal "ACTIVE" + _(@networks.get(@network.id).status).must_equal "ACTIVE" end end end diff --git a/test/models/network/port_tests.rb b/test/models/network/port_tests.rb index e1f996ad6..0bb60c675 100644 --- a/test/models/network/port_tests.rb +++ b/test/models/network/port_tests.rb @@ -17,16 +17,16 @@ end it "#create" do - @instance.id.wont_be_nil + _(@instance.id).wont_be_nil end it "#update" do @instance.name = 'new_port_name' - @instance.update.status.must_equal "ACTIVE" + _(@instance.update.status).must_equal "ACTIVE" end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/network/ports_tests.rb b/test/models/network/ports_tests.rb index 2a7f7eb55..f768a40ec 100644 --- a/test/models/network/ports_tests.rb +++ b/test/models/network/ports_tests.rb @@ -23,11 +23,11 @@ describe "success" do it "#all" do - @ports.all[0].status.must_equal "ACTIVE" + _(@ports.all[0].status).must_equal "ACTIVE" end it "#get" do - @ports.get(@port.id).status.must_equal "ACTIVE" + _(@ports.get(@port.id).status).must_equal "ACTIVE" end end end diff --git a/test/models/network/router_tests.rb b/test/models/network/router_tests.rb index a1bf17621..ddc9ca753 100644 --- a/test/models/network/router_tests.rb +++ b/test/models/network/router_tests.rb @@ -11,14 +11,14 @@ end it "#create" do - @instance.id.wont_be_nil + _(@instance.id).wont_be_nil end describe '#update' do it "router name" do @instance.name = 'new_name' @instance.update - @instance.name.must_equal 'new_name' + _(@instance.name).must_equal 'new_name' end # Needs code from issue #1598 @@ -36,7 +36,7 @@ end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/network/routers_tests.rb b/test/models/network/routers_tests.rb index cbd0cae0b..b81305133 100644 --- a/test/models/network/routers_tests.rb +++ b/test/models/network/routers_tests.rb @@ -17,11 +17,11 @@ describe "success" do it "#all" do - @routers.all[0].status.must_equal "ACTIVE" + _(@routers.all[0].status).must_equal "ACTIVE" end it "#get" do - @routers.get(@router.id).status.must_equal "ACTIVE" + _(@routers.get(@router.id).status).must_equal "ACTIVE" end end end diff --git a/test/models/network/security_group_rule_tests.rb b/test/models/network/security_group_rule_tests.rb index 39dbfaba3..efb336f75 100644 --- a/test/models/network/security_group_rule_tests.rb +++ b/test/models/network/security_group_rule_tests.rb @@ -27,11 +27,11 @@ end it "#create" do - @secgrouprule.id.wont_be_nil + _(@secgrouprule.id).wont_be_nil end it "#destroy" do - @secgrouprule.destroy.must_equal true + _(@secgrouprule.destroy).must_equal true end end end diff --git a/test/models/network/security_group_rules_tests.rb b/test/models/network/security_group_rules_tests.rb index 8cb149e64..6ffc3e2de 100644 --- a/test/models/network/security_group_rules_tests.rb +++ b/test/models/network/security_group_rules_tests.rb @@ -29,7 +29,7 @@ it "#all(filter)" do secgrouprule = network.security_group_rules.all(:direction => "ingress") - secgrouprule.first.direction.must_equal "ingress" + _(secgrouprule.first.direction).must_equal "ingress" @secgrouprule.destroy end end diff --git a/test/models/network/security_group_tests.rb b/test/models/network/security_group_tests.rb index d48319259..d7f85a91b 100644 --- a/test/models/network/security_group_tests.rb +++ b/test/models/network/security_group_tests.rb @@ -13,16 +13,16 @@ end it "#create" do - @secgroup.id.wont_be_nil + _(@secgroup.id).wont_be_nil end it "#update" do @secgroup.name = 'new_sg_name' - @secgroup.name.must_equal 'new_sg_name' + _(@secgroup.name).must_equal 'new_sg_name' end it "#destroy" do - @secgroup.destroy.must_equal true + _(@secgroup.destroy).must_equal true end end end diff --git a/test/models/network/security_groups_tests.rb b/test/models/network/security_groups_tests.rb index 06eda8e40..7b2a70afa 100644 --- a/test/models/network/security_groups_tests.rb +++ b/test/models/network/security_groups_tests.rb @@ -26,7 +26,7 @@ it "#all(filter)" do secgroup = network.security_groups.all(:name => "fogsecgroup") - secgroup.first.name.wont_be_empty + _(secgroup.first.name).wont_be_empty end end end diff --git a/test/models/network/subnet_pools_tests.rb b/test/models/network/subnet_pools_tests.rb index 1aabc0d6b..77f6942f1 100644 --- a/test/models/network/subnet_pools_tests.rb +++ b/test/models/network/subnet_pools_tests.rb @@ -21,11 +21,11 @@ end it '#all' do - @subnet_pools.all[0].id.wont_be_empty + _(@subnet_pools.all[0].id).wont_be_empty end it '#get' do - @subnet_pools.get(@subnet_pool.id).id.wont_be_empty + _(@subnet_pools.get(@subnet_pool.id).id).wont_be_empty end end end diff --git a/test/models/network/subnet_tests.rb b/test/models/network/subnet_tests.rb index b4b217332..5759890c7 100644 --- a/test/models/network/subnet_tests.rb +++ b/test/models/network/subnet_tests.rb @@ -19,16 +19,16 @@ end it "#create" do - @instance.id.wont_be_nil + _(@instance.id).wont_be_nil end it "#update" do @instance.name = 'new_subnet_name' - @instance.update.name.must_equal 'new_subnet_name' + _(@instance.update.name).must_equal 'new_subnet_name' end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/network/subnets_tests.rb b/test/models/network/subnets_tests.rb index 0f92c49e7..afdda6ff7 100644 --- a/test/models/network/subnets_tests.rb +++ b/test/models/network/subnets_tests.rb @@ -25,11 +25,11 @@ end it "#all" do - @subnets.all[0].id.wont_be_empty + _(@subnets.all[0].id).wont_be_empty end it "#get" do - @subnets.get(@subnet.id).id.wont_be_empty + _(@subnets.get(@subnet.id).id).wont_be_empty end end end diff --git a/test/models/network/vpn_service_tests.rb b/test/models/network/vpn_service_tests.rb index af9b7dc3b..af0e8036f 100644 --- a/test/models/network/vpn_service_tests.rb +++ b/test/models/network/vpn_service_tests.rb @@ -15,7 +15,7 @@ end it "#create" do - @instance.status.must_equal "ACTIVE" + _(@instance.status).must_equal "ACTIVE" end it "#update" do @@ -25,11 +25,11 @@ @instance.description = 'new' @instance.admin_state_up = false @instance.tenant_id = 'baz' - @instance.update.status.must_equal "ACTIVE" + _(@instance.update.status).must_equal "ACTIVE" end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end end end diff --git a/test/models/network/vpn_services_tests.rb b/test/models/network/vpn_services_tests.rb index 35af8740f..c448a8a7d 100644 --- a/test/models/network/vpn_services_tests.rb +++ b/test/models/network/vpn_services_tests.rb @@ -21,11 +21,11 @@ describe "success" do it "#all" do - @vpn_services.all[0].status.must_equal "ACTIVE" + _(@vpn_services.all[0].status).must_equal "ACTIVE" end it "#get" do - @vpn_services.get(@vpn_service.id).status.must_equal "ACTIVE" + _(@vpn_services.get(@vpn_service.id).status).must_equal "ACTIVE" end end end diff --git a/test/models/nfv/vnf_tests.rb b/test/models/nfv/vnf_tests.rb index afe9a5bd6..39f57b811 100644 --- a/test/models/nfv/vnf_tests.rb +++ b/test/models/nfv/vnf_tests.rb @@ -15,19 +15,19 @@ end it "#create" do - @vnfs.status.must_equal "ACTIVE" + _(@vnfs.status).must_equal "ACTIVE" end it "#update" do @vnfs.vnf = {:attributes => {:config => "vdus:\n vdu1: \n\n"}} - @vnfs.update.status.must_equal "ACTIVE" + _(@vnfs.update.status).must_equal "ACTIVE" end it "#destroy" do sleep(10) unless Fog.mocking? @vnfs.destroy - @vnfd.destroy.must_equal true + _(@vnfd.destroy).must_equal true end end end diff --git a/test/models/nfv/vnfd_tests.rb b/test/models/nfv/vnfd_tests.rb index 2bed51fa6..c20f4d724 100644 --- a/test/models/nfv/vnfd_tests.rb +++ b/test/models/nfv/vnfd_tests.rb @@ -9,11 +9,11 @@ end it "#create" do - @vnfd.id.wont_be_empty + _(@vnfd.id).wont_be_empty end it "#destroy" do - @vnfd.destroy.must_equal true + _(@vnfd.destroy).must_equal true end end end diff --git a/test/models/nfv/vnfds_tests.rb b/test/models/nfv/vnfds_tests.rb index 05c0a9a0b..ba487d2d7 100644 --- a/test/models/nfv/vnfds_tests.rb +++ b/test/models/nfv/vnfds_tests.rb @@ -10,16 +10,16 @@ it "#find_by_id" do vnf = @nfv.vnfds.find_by_id(@vnfd.id) - vnf.id.must_equal @vnfd.id + _(vnf.id).must_equal @vnfd.id end it "#get" do vnf = @nfv.vnfds.get(@vnfd.id) - vnf.id.must_equal @vnfd.id + _(vnf.id).must_equal @vnfd.id end it "#destroy" do - @nfv.vnfds.destroy(@vnfd.id).must_equal true + _(@nfv.vnfds.destroy(@vnfd.id)).must_equal true end end end diff --git a/test/models/nfv/vnfs_tests.rb b/test/models/nfv/vnfs_tests.rb index 65a5f6cd5..b4b75fe39 100644 --- a/test/models/nfv/vnfs_tests.rb +++ b/test/models/nfv/vnfs_tests.rb @@ -14,19 +14,19 @@ it "#find_by_id" do vnf = @nfv.vnfs.find_by_id(@vnfs.id) - vnf.id.must_equal @vnfs.id + _(vnf.id).must_equal @vnfs.id end it "#get" do vnf = @nfv.vnfs.get(@vnfs.id) - vnf.id.must_equal @vnfs.id + _(vnf.id).must_equal @vnfs.id end it "#destroy" do sleep(10) unless Fog.mocking? @nfv.vnfs.destroy(@vnfs.id) - @nfv.vnfds.destroy(@vnfd.id).must_equal true + _(@nfv.vnfds.destroy(@vnfd.id)).must_equal true end end end diff --git a/test/models/planning/plan_tests.rb b/test/models/planning/plan_tests.rb index 1a2bcf8a6..3493686e6 100644 --- a/test/models/planning/plan_tests.rb +++ b/test/models/planning/plan_tests.rb @@ -9,55 +9,55 @@ end it "#add_role" do - @instance.add_role(@role['uuid']).body["roles"][0]["uuid"].must_equal @role['uuid'] + _(@instance.add_role(@role['uuid']).body["roles"][0]["uuid"]).must_equal @role['uuid'] end it "#templates" do - @instance.templates.wont_be_empty + _(@instance.templates).wont_be_empty end it "#master_template" do - @instance.master_template.must_be_kind_of String + _(@instance.master_template).must_be_kind_of String end it "#environment" do - @instance.environment.must_be_kind_of String + _(@instance.environment).must_be_kind_of String end it "#provider_resource_templates" do - @instance.provider_resource_templates["provider-compute-1.yaml"].wont_be_empty + _(@instance.provider_resource_templates["provider-compute-1.yaml"]).wont_be_empty end it "#patch" do parameter = @instance.parameters.first - @instance.patch( + _(@instance.patch( :parameters => [ { "name" => parameter['name'], "value" => 'new_value' } ] - )["uuid"].must_be_kind_of String + )["uuid"]).must_be_kind_of String end it "#remove_role" do - @instance.remove_role(@role['uuid']).status.must_equal 200 + _(@instance.remove_role(@role['uuid']).status).must_equal 200 end it "#save" do - @instance.save.must_be_kind_of Fog::OpenStack::Planning::Plan + _(@instance.save).must_be_kind_of Fog::OpenStack::Planning::Plan end it "#update" do - @instance.update.uuid.wont_be_empty + _(@instance.update.uuid).wont_be_empty end it "#destroy" do - @instance.destroy.must_equal true + _(@instance.destroy).must_equal true end it "#create" do - @instance.create.must_be_kind_of Fog::OpenStack::Planning::Plan + _(@instance.create).must_be_kind_of Fog::OpenStack::Planning::Plan end end end diff --git a/test/models/planning/plans_tests.rb b/test/models/planning/plans_tests.rb index dba84e72b..61ef3ec37 100644 --- a/test/models/planning/plans_tests.rb +++ b/test/models/planning/plans_tests.rb @@ -8,16 +8,16 @@ end it "#all" do - @instance.uuid.wont_be_empty + _(@instance.uuid).wont_be_empty end it "#get" do - @planning.plans.get(@instance.uuid).uuid.must_equal @instance.uuid + _(@planning.plans.get(@instance.uuid).uuid).must_equal @instance.uuid end it "#find_by_*" do plan = @planning.plans.find_by_name(@instance.name) - plan.name.must_equal @instance.name + _(plan.name).must_equal @instance.name end end end diff --git a/test/models/planning/role_tests.rb b/test/models/planning/role_tests.rb index 1ee5d2600..e89162954 100644 --- a/test/models/planning/role_tests.rb +++ b/test/models/planning/role_tests.rb @@ -8,11 +8,11 @@ end it "#add_role" do - @instance.add_to_plan(@plan['uuid']).status.must_equal 201 + _(@instance.add_to_plan(@plan['uuid']).status).must_equal 201 end it "#remove_role" do - @instance.remove_from_plan(@plan['uuid']).status.must_equal 200 + _(@instance.remove_from_plan(@plan['uuid']).status).must_equal 200 end end end diff --git a/test/models/storage/file_tests.rb b/test/models/storage/file_tests.rb index 48ca223c5..366fcc05e 100644 --- a/test/models/storage/file_tests.rb +++ b/test/models/storage/file_tests.rb @@ -44,7 +44,7 @@ def clear_metadata model_tests(@directory.files, @file_attributes, Fog.mocking?) do it "#metadata should load empty metadata" do - @instance.metadata.must_equal {} + _(@instance.metadata).must_equal {} end describe "#save" do @@ -60,17 +60,17 @@ def clear_metadata end it "should update metadata" do - object_meta_attributes['X-Object-Meta-Foo'].must_equal 'bar' + _(object_meta_attributes['X-Object-Meta-Foo']).must_equal 'bar' end it "should cache metadata" do - @instance.metadata[:foo].must_equal 'bar' + _(@instance.metadata[:foo]).must_equal 'bar' end it "should remove empty metadata" do @instance.metadata[:foo] = nil @instance.save - object_meta_attributes.must_equal {} + _(object_meta_attributes).must_equal {} end end @@ -89,7 +89,7 @@ def clear_metadata end it "sets Cache-Control on create" do - object_attributes(@instance)["Cache-Control"].must_equal "public, max-age=31536000" + _(object_attributes(@instance)["Cache-Control"]).must_equal "public, max-age=31536000" end end @@ -108,7 +108,7 @@ def clear_metadata end it "sets Content-Disposition on create" do - object_attributes(@instance)["Content-Disposition"].must_equal "ho-ho-ho" + _(object_attributes(@instance)["Content-Disposition"]).must_equal "ho-ho-ho" end end @@ -121,45 +121,45 @@ def clear_metadata it "should support compound key names" do @instance.metadata[:foo_bar] = 'baz' @instance.save - object_meta_attributes['X-Object-Meta-Foo-Bar'].must_equal 'baz' + _(object_meta_attributes['X-Object-Meta-Foo-Bar']).must_equal 'baz' end it "should support string keys" do @instance.metadata['foo'] = 'bar' @instance.save - object_meta_attributes['X-Object-Meta-Foo'].must_equal 'bar' + _(object_meta_attributes['X-Object-Meta-Foo']).must_equal 'bar' end it "should support compound string key names" do @instance.metadata['foo_bar'] = 'baz' @instance.save - object_meta_attributes['X-Object-Meta-Foo-Bar'].must_equal 'baz' + _(object_meta_attributes['X-Object-Meta-Foo-Bar']).must_equal 'baz' end it "should support hyphenated keys" do @instance.metadata['foo-bar'] = 'baz' @instance.save - object_meta_attributes['X-Object-Meta-Foo-Bar'].must_equal 'baz' + _(object_meta_attributes['X-Object-Meta-Foo-Bar']).must_equal 'baz' end it "should only support one value per metadata key" do @instance.metadata['foo-bar'] = 'baz' @instance.metadata[:foo_bar] = 'bref' @instance.save - object_meta_attributes['X-Object-Meta-Foo-Bar'].must_equal 'bref' + _(object_meta_attributes['X-Object-Meta-Foo-Bar']).must_equal 'bref' end end end describe "#access_control_allow_origin" do it "#access_control_allow_origin should default to nil" do - @instance.access_control_allow_origin.must_equal nil + _(@instance.access_control_allow_origin).must_be_nil end @instance.access_control_allow_origin = 'http://example.com' @instance.save it "#access_control_allow_origin should return access control attribute" do - @instance.access_control_allow_origin.must_equal 'http://example.com' + _(@instance.access_control_allow_origin).must_equal 'http://example.com' end @instance.access_control_allow_origin = 'foo' @@ -167,7 +167,7 @@ def clear_metadata it "#access_control_allow_origin= should update access_control_allow_origin" do @instance.access_control_allow_origin = 'bar' @instance.save - @instance.access_control_allow_origin.must_equal 'bar' + _(@instance.access_control_allow_origin).must_equal 'bar' end it "#access_control_allow_origin= should not blow up on nil" do @@ -180,13 +180,13 @@ def clear_metadata @delete_at_time = (Time.now + 300).to_i it "#delete_at should default to nil" do - @instance.delete_at.must_equal nil + _(@instance.delete_at).must_be_nil end @instance.delete_at = @delete_at_time @instance.save it "#delete_at should return delete_at attribute" do - @instance.delete_at.must_equal @delete_at_time + _(@instance.delete_at).must_equal @delete_at_time end @instance.delete_at = @delete_at_time @@ -194,7 +194,7 @@ def clear_metadata it "#delete_at= should update delete_at" do @instance.delete_at = @delete_at_time + 100 @instance.save - @instance.delete_at.must_equal(@delete_at_time + 100) + _(@instance.delete_at).must_equal(@delete_at_time + 100) end it "#delete_at= should not blow up on nil" do @@ -208,13 +208,13 @@ def clear_metadata describe "#origin" do it "#origin should default to nil" do @instance.save - @instance.origin.must_equal nil + _(@instance.origin).must_be_nil end @instance.origin = 'http://example.com' @instance.save it "#origin should return access control attributes" do - @instance.origin.must_equal('http://example.com') + _(@instance.origin).must_equal('http://example.com') end @instance.attributes.delete('Origin') @@ -223,7 +223,7 @@ def clear_metadata it "#origin= should update origin" do @instance.origin = 'bar' @instance.save - @instance.origin.must_equal 'bar' + _(@instance.origin).must_equal 'bar' end it "#origin= should not blow up on nil" do @@ -235,13 +235,13 @@ def clear_metadata describe "#content_encoding" do it "#content_encoding should default to nil" do @instance.save - @instance.content_encoding.must_equal nil + _(@instance.content_encoding).must_be_nil end @instance.content_encoding = 'gzip' @instance.save it "#content_encoding should return the content encoding" do - @instance.content_encoding.must_equal 'gzip' + _(@instance.content_encoding).must_equal 'gzip' end @instance.attributes.delete('content_encoding') @@ -250,7 +250,7 @@ def clear_metadata it "#content_encoding= should update content_encoding" do @instance.content_encoding = 'bar' @instance.save - @instance.content_encoding.must_equal 'bar' + _(@instance.content_encoding).must_equal 'bar' end it "#content_encoding= should not blow up on nil" do diff --git a/test/requests/baremetal/chassis_tests.rb b/test/requests/baremetal/chassis_tests.rb index b858dc3c0..7c492fc93 100644 --- a/test/requests/baremetal/chassis_tests.rb +++ b/test/requests/baremetal/chassis_tests.rb @@ -26,30 +26,30 @@ end it "#list_chassis" do - @baremetal.list_chassis.body.must_match_schema('chassis' => [@chassis_format]) + _(@baremetal.list_chassis.body).must_match_schema('chassis' => [@chassis_format]) end it "#list_chassis_detailed" do - @baremetal.list_chassis_detailed.body.must_match_schema('chassis' => [@detailed_chassis_format]) + _(@baremetal.list_chassis_detailed.body).must_match_schema('chassis' => [@detailed_chassis_format]) end it "#create_chassis" do - @instance.must_match_schema(@detailed_chassis_format) + _(@instance).must_match_schema(@detailed_chassis_format) end it "#get_chassis" do - @baremetal.get_chassis(@instance['uuid']).body.must_match_schema(@detailed_chassis_format) + _(@baremetal.get_chassis(@instance['uuid']).body).must_match_schema(@detailed_chassis_format) end it "#patch_chassis" do - @baremetal.patch_chassis( + _(@baremetal.patch_chassis( @instance['uuid'], [{'op' => 'replace', 'path' => '/description', 'value' => 'new description'}] - ).body.must_match_schema(@detailed_chassis_format) + ).body).must_match_schema(@detailed_chassis_format) end it "#delete_chassis" do - @baremetal.delete_chassis(@instance['uuid']).status.must_equal 200 + _(@baremetal.delete_chassis(@instance['uuid']).status).must_equal 200 end end end diff --git a/test/requests/baremetal/driver_tests.rb b/test/requests/baremetal/driver_tests.rb index 6c976b9a8..489de617c 100644 --- a/test/requests/baremetal/driver_tests.rb +++ b/test/requests/baremetal/driver_tests.rb @@ -31,15 +31,15 @@ describe "success" do it "#list_drivers" do - @instances.must_match_schema('drivers' => [@driver_format]) + _(@instances).must_match_schema('drivers' => [@driver_format]) end it "#get_driver" do - @baremetal.get_driver(@instance['name']).body.must_match_schema(@driver_format) + _(@baremetal.get_driver(@instance['name']).body).must_match_schema(@driver_format) end it "#get_driver_properties" do - @baremetal.get_driver_properties(@instance['name']).body. + _(@baremetal.get_driver_properties(@instance['name']).body). must_match_schema(@driver_properties_format) end end diff --git a/test/requests/baremetal/node_tests.rb b/test/requests/baremetal/node_tests.rb index 99b61b308..a97e913f5 100644 --- a/test/requests/baremetal/node_tests.rb +++ b/test/requests/baremetal/node_tests.rb @@ -39,11 +39,11 @@ describe "success" do it "#list_nodes" do - @baremetal.list_nodes.body.must_match_schema('nodes' => [@node_format]) + _(@baremetal.list_nodes.body).must_match_schema('nodes' => [@node_format]) end it "#list_nodes_detailed" do - @baremetal.list_nodes_detailed.body. + _(@baremetal.list_nodes_detailed.body). must_match_schema('nodes' => [@detailed_node_format]) end @@ -53,41 +53,41 @@ end it "#create_node" do - @instance.must_match_schema(@detailed_node_format) + _(@instance).must_match_schema(@detailed_node_format) end it "#get_node" do - @baremetal.get_node(@instance['uuid']).body. + _(@baremetal.get_node(@instance['uuid']).body). must_match_schema(@detailed_node_format) end it "#patch_node" do - @baremetal.patch_node( + _(@baremetal.patch_node( @instance['uuid'], [{'op' => 'replace', 'path' => '/driver', 'value' => 'pxe_ssh'}] - ).body.must_match_schema(@detailed_node_format) + ).body).must_match_schema(@detailed_node_format) end it "#set_node_power_state" do - @baremetal.set_node_power_state(@instance['uuid'], 'power off').body. + _(@baremetal.set_node_power_state(@instance['uuid'], 'power off').body). must_match_schema(@detailed_node_format) end it "#set_node_provision_state" do - @baremetal.set_node_provision_state(@instance['uuid'], 'manage').body. + _(@baremetal.set_node_provision_state(@instance['uuid'], 'manage').body). must_match_schema(@detailed_node_format) end it "#set_node_maintenance" do - @baremetal.set_node_maintenance(@instance['uuid']).status.must_equal 202 + _(@baremetal.set_node_maintenance(@instance['uuid']).status).must_equal 202 end it "#unset_node_maintenance" do - @baremetal.unset_node_maintenance(@instance['uuid']).status.must_equal 202 + _(@baremetal.unset_node_maintenance(@instance['uuid']).status).must_equal 202 end it "#delete_node" do - @baremetal.delete_node(@instance['uuid']).status.must_equal 200 + _(@baremetal.delete_node(@instance['uuid']).status).must_equal 200 end end end diff --git a/test/requests/baremetal/port_tests.rb b/test/requests/baremetal/port_tests.rb index 689b7d046..1275311e5 100644 --- a/test/requests/baremetal/port_tests.rb +++ b/test/requests/baremetal/port_tests.rb @@ -22,11 +22,11 @@ describe "success" do it "#list_ports" do - @baremetal.list_ports.body.must_match_schema('ports' => [@port_format]) + _(@baremetal.list_ports.body).must_match_schema('ports' => [@port_format]) end it "#list_ports_detailed" do - @baremetal.list_ports_detailed.body.must_match_schema('ports' => [@detailed_port_format]) + _(@baremetal.list_ports_detailed.body).must_match_schema('ports' => [@detailed_port_format]) end before do @@ -41,23 +41,23 @@ end it "#create_port" do - @port.must_match_schema(@detailed_port_format) + _(@port).must_match_schema(@detailed_port_format) end it "#get_port" do - @baremetal.get_port(@port['uuid']).body.must_match_schema(@detailed_port_format) + _(@baremetal.get_port(@port['uuid']).body).must_match_schema(@detailed_port_format) end it "#patch_port" do - @baremetal.patch_port( + _(@baremetal.patch_port( @port['uuid'], [{'op' => 'add', 'path' => '/extra/name', 'value' => 'eth1'}] - ).body.must_match_schema(@detailed_port_format) + ).body).must_match_schema(@detailed_port_format) end it "#delete_port" do - @baremetal.delete_port(@port['uuid']).status.must_equal 200 - @baremetal.delete_node(@instance['uuid']).status.must_equal 200 + _(@baremetal.delete_port(@port['uuid']).status).must_equal 200 + _(@baremetal.delete_node(@instance['uuid']).status).must_equal 200 end end end diff --git a/test/requests/compute/address_tests.rb b/test/requests/compute/address_tests.rb index 2d855a061..8fcea463b 100644 --- a/test/requests/compute/address_tests.rb +++ b/test/requests/compute/address_tests.rb @@ -61,34 +61,34 @@ def address_pools_format end it "#allocate_address" do - self.class.data.must_match_schema("floating_ip" => address_format) + _(self.class.data).must_match_schema("floating_ip" => address_format) end it "#list_all_addresses" do - compute.list_all_addresses.body. + _(compute.list_all_addresses.body). must_match_schema("floating_ips" => [address_format]) end it "#get_address(address_id)" do - compute.get_address(address_id).body. + _(compute.get_address(address_id).body). must_match_schema("floating_ip" => address_format) end it "#list_address_pools" do - compute.list_address_pools.body. + _(compute.list_address_pools.body). must_match_schema("floating_ip_pools" => [address_pools_format]) end it "#associate_address(server_id, ip_address)" do - compute.associate_address(self.class.server_id, address_ip).body.must_equal "" + _(compute.associate_address(self.class.server_id, address_ip).body).must_equal "" end it "#disassociate_address(server_id, ip_address)" do - compute.disassociate_address(self.class.server_id, address_ip).body.must_equal "" + _(compute.disassociate_address(self.class.server_id, address_ip).body).must_equal "" end it "#release_address(ip_address)" do - compute.release_address(address_id).status.must_equal 202 + _(compute.release_address(address_id).status).must_equal 202 end end end diff --git a/test/requests/compute/aggregate_tests.rb b/test/requests/compute/aggregate_tests.rb index c21ce334a..11f6b12c1 100644 --- a/test/requests/compute/aggregate_tests.rb +++ b/test/requests/compute/aggregate_tests.rb @@ -22,22 +22,22 @@ describe "success" do it "#create_aggregate" do - @aggregate_body.must_match_schema('aggregate' => @aggregate_format) + _(@aggregate_body).must_match_schema('aggregate' => @aggregate_format) end it "#list_aggregates" do - @compute.list_aggregates.body. + _(@compute.list_aggregates.body). must_match_schema('aggregates' => [@metadata_aggregate_format]) end it "#update_aggregate" do @aggregate_attributes = {'name' => 'test_aggregate2'} - @compute.update_aggregate(@aggregate['id'], @aggregate_attributes).body. + _(@compute.update_aggregate(@aggregate['id'], @aggregate_attributes).body). must_match_schema('aggregate' => @aggregate_format) end it "#get_aggregate" do - @compute.get_aggregate(@aggregate['id']).body. + _(@compute.get_aggregate(@aggregate['id']).body). must_match_schema('aggregate' => @detailed_aggregate_format) end @@ -47,20 +47,21 @@ end it "#add_aggregate_host" do - @compute.add_aggregate_host(@aggregate['id'], host_name).status.must_equal 200 + _(@compute.add_aggregate_host(@aggregate['id'], host_name).status).must_equal 200 end it "#remove_aggregate_host" do - @compute.remove_aggregate_host(@aggregate['id'], host_name).status.must_equal 200 + _(@compute.remove_aggregate_host(@aggregate['id'], host_name).status).must_equal 200 end end it "#update_aggregate_metadata" do - @compute.update_aggregate_metadata(@aggregate['id'], 'test' => 'test', 'test2' => 'test2').status.must_equal 200 + metadata = {'test' => 'test', 'test2' => 'test2'} + _(@compute.update_aggregate_metadata(@aggregate['id'], metadata).status).must_equal 200 end it "#delete_aggregate" do - @compute.delete_aggregate(@aggregate['id']).status.must_equal 200 + _(@compute.delete_aggregate(@aggregate['id']).status).must_equal 200 end end end diff --git a/test/requests/compute/availability_zone_tests.rb b/test/requests/compute/availability_zone_tests.rb index 2da624419..6c24485c8 100644 --- a/test/requests/compute/availability_zone_tests.rb +++ b/test/requests/compute/availability_zone_tests.rb @@ -11,12 +11,12 @@ describe "success" do it "#list_zones" do - Fog::OpenStack::Compute.new.list_zones.body. + _(Fog::OpenStack::Compute.new.list_zones.body). must_match_schema('availabilityZoneInfo' => [@flavor_format]) end it "#list_zones_detailed" do - Fog::OpenStack::Compute.new.list_zones_detailed.body. + _(Fog::OpenStack::Compute.new.list_zones_detailed.body). must_match_schema('availabilityZoneInfo' => [@flavor_format]) end end diff --git a/test/requests/compute/flavor_tests.rb b/test/requests/compute/flavor_tests.rb index 27052fd67..ea22ff023 100644 --- a/test/requests/compute/flavor_tests.rb +++ b/test/requests/compute/flavor_tests.rb @@ -23,17 +23,17 @@ describe "success" do it "#get_flavor_details(1)" do - @compute.get_flavor_details("1").body['flavor']. + _(@compute.get_flavor_details("1").body['flavor']). must_match_schema(@flavor_format) end it "#list_flavors" do - @compute.list_flavors.body. + _(@compute.list_flavors.body). must_match_schema('flavors' => [OpenStack::Compute::Formats::SUMMARY]) end it "#list_flavors_detail" do - @compute.list_flavors_detail.body. + _(@compute.list_flavors_detail.body). must_match_schema('flavors' => [@flavor_format]) end @@ -50,86 +50,86 @@ :is_public => false } - @compute.create_flavor(attributes).body. + _(@compute.create_flavor(attributes).body). must_match_schema('flavor' => @flavor_format) end it "add_flavor_access(flavor_ref, tenant_id)" do - @compute.add_flavor_access(100, 1).body. + _(@compute.add_flavor_access(100, 1).body). must_match_schema('flavor_access' => [{'tenant_id' => String, 'flavor_id' => String}]) end it "remove_flavor_access(flavor_ref, tenant_id)" do - @compute.remove_flavor_access(100, 1).body. + _(@compute.remove_flavor_access(100, 1).body). must_match_schema('flavor_access' => []) end it "list_tenants_with_flavor_access(flavor_ref)" do - @compute.list_tenants_with_flavor_access(100).body. + _(@compute.list_tenants_with_flavor_access(100).body). must_match_schema('flavor_access' => [{'tenant_id' => String, 'flavor_id' => String}]) end it "delete_flavor(flavor_id)" do - @compute.delete_flavor('100').status.must_equal 202 + _(@compute.delete_flavor('100').status).must_equal 202 end it "#get_flavor_metadata(flavor_ref)" do - @compute.get_flavor_metadata("1").body. + _(@compute.get_flavor_metadata("1").body). must_match_schema('extra_specs' => {'cpu_arch' => String}) end it "#create_flavor_metadata(flavor_ref, metadata)" do metadata = {:cpu_arch => 'x86_64'} - @compute.create_flavor_metadata("1", metadata).body. + _(@compute.create_flavor_metadata("1", metadata).body). must_match_schema('extra_specs' => {'cpu_arch' => String}) end end describe "failure" do it "#get_flavor_details(0)" do - proc do + _(proc do @compute.get_flavor_details("0") - end.must_raise Fog::OpenStack::Compute::NotFound + end).must_raise Fog::OpenStack::Compute::NotFound end it "add_flavor_access(1234, 1)" do unless Fog.mocking? - proc do + _(proc do @compute.add_flavor_access(1234, 1).body - end.must_raise Fog::OpenStack::Compute::NotFound + end).must_raise Fog::OpenStack::Compute::NotFound end end it "remove_flavor_access(1234, 1)" do unless Fog.mocking? - proc do + _(proc do @compute.remove_flavor_access(1234, 1).body - end.must_raise Fog::OpenStack::Compute::NotFound + end).must_raise Fog::OpenStack::Compute::NotFound end end it "list_tenants_with_flavor_access(1234)" do unless Fog.mocking? - proc do + _(proc do @compute.list_tenants_with_flavor_access(1234) - end.must_raise Fog::OpenStack::Compute::NotFound + end).must_raise Fog::OpenStack::Compute::NotFound end end it "get_flavor_metadata(flavor_ref)" do unless Fog.mocking? - proc do + _(proc do @compute.get_flavor_metadata("1234").body - end.must_raise Fog::OpenStack::Compute::NotFound + end).must_raise Fog::OpenStack::Compute::NotFound end end it "create_flavor_metadata(flavor_ref)" do unless Fog.mocking? - proc do + _(proc do metadata = {:cpu_arch => 'x86_64'} @compute.create_flavor_metadata("1234", metadata).body - end.must_raise Fog::OpenStack::Compute::NotFound + end).must_raise Fog::OpenStack::Compute::NotFound end end end diff --git a/test/requests/compute/image_tests.rb b/test/requests/compute/image_tests.rb index 6577314ca..43e66ba91 100644 --- a/test/requests/compute/image_tests.rb +++ b/test/requests/compute/image_tests.rb @@ -31,18 +31,18 @@ it "#get_image_details(#{@image_id})" do unless Fog.mocking? - @compute.get_image_details(@image_id).body['image']. + _(@compute.get_image_details(@image_id).body['image']). must_match_schema(@image_format) end end it "#list_images" do - @compute.list_images.body. + _(@compute.list_images.body). must_match_schema('images' => [OpenStack::Compute::Formats::SUMMARY]) end it "#list_images_detail" do - @compute.list_images_detail.body. + _(@compute.list_images_detail.body). must_match_schema('images' => [@image_format]) end @@ -56,17 +56,17 @@ describe "failure" do it "#delete_image(0)" do unless Fog.mocking? - proc do + _(proc do @compute.delete_image(0) - end.must_raise Fog::OpenStack::Compute::NotFound + end).must_raise Fog::OpenStack::Compute::NotFound end end it "#get_image_details(0)" do unless Fog.mocking? - proc do + _(proc do @compute.get_image_details(0) - end.must_raise Fog::OpenStack::Compute::NotFound + end).must_raise Fog::OpenStack::Compute::NotFound end end end diff --git a/test/requests/compute/keypair_tests.rb b/test/requests/compute/keypair_tests.rb index 8f5876eb0..88e1a7b79 100644 --- a/test/requests/compute/keypair_tests.rb +++ b/test/requests/compute/keypair_tests.rb @@ -19,17 +19,17 @@ describe "success" do it "#create_key_pair((key_name, public_key = nil))" do - Fog::OpenStack::Compute.new.create_key_pair('from_shindo_test').body. + _(Fog::OpenStack::Compute.new.create_key_pair('from_shindo_test').body). must_match_schema("keypair" => @keypair_format) end it "#list_key_pairs" do - Fog::OpenStack::Compute.new.list_key_pairs.body. + _(Fog::OpenStack::Compute.new.list_key_pairs.body). must_match_schema("keypairs" => [{"keypair" => @keypair_list_format}]) end it "#delete_key_pair(key_name)" do - Fog::OpenStack::Compute.new.delete_key_pair('from_shindo_test').status.must_equal 202 + _(Fog::OpenStack::Compute.new.delete_key_pair('from_shindo_test').status).must_equal 202 end end end diff --git a/test/requests/compute/limit_tests.rb b/test/requests/compute/limit_tests.rb index c827dba8e..6e9d4d42d 100644 --- a/test/requests/compute/limit_tests.rb +++ b/test/requests/compute/limit_tests.rb @@ -44,22 +44,22 @@ describe "success" do describe "#get_limits" do it "format" do - Fog::OpenStack::Compute.new.get_limits.body['limits']. + _(Fog::OpenStack::Compute.new.get_limits.body['limits']). must_match_schema(@limits_format) end it "rate limit format" do - Fog::OpenStack::Compute.new.get_limits.body['limits']['rate']. - first.must_match_schema(@rate_limit_format) + _(Fog::OpenStack::Compute.new.get_limits.body['limits']['rate']. + first).must_match_schema(@rate_limit_format) end it "rate limit usage format" do - Fog::OpenStack::Compute.new.get_limits.body['limits']['rate']. - first['limit'].first.must_match_schema(@rate_limit_usage_format) + _(Fog::OpenStack::Compute.new.get_limits.body['limits']['rate']. + first['limit'].first).must_match_schema(@rate_limit_usage_format) end it "absolute limits format" do - Fog::OpenStack::Compute.new.get_limits.body['limits']['absolute']. + _(Fog::OpenStack::Compute.new.get_limits.body['limits']['absolute']). must_match_schema(@absolute_limits_format) end end diff --git a/test/requests/compute/quota_tests.rb b/test/requests/compute/quota_tests.rb index 584622010..67a30eae2 100644 --- a/test/requests/compute/quota_tests.rb +++ b/test/requests/compute/quota_tests.rb @@ -27,12 +27,12 @@ describe "success" do it "#get_quota_defaults" do - @compute.get_quota_defaults(@tenant_id).body. + _(@compute.get_quota_defaults(@tenant_id).body). must_match_schema('quota_set' => @quota_set_format) end it "#get_quota" do - @quota.must_match_schema(@quota_set_format) + _(@quota).must_match_schema(@quota_set_format) end it "#update_quota" do @@ -41,8 +41,8 @@ 'cores' => @quota['cores'] / 2 ) - @compute.update_quota(@tenant_id, new_values.clone).status.must_equal 200 - @compute.get_quota(@tenant_id).body['quota_set'].must_equal new_values + _(@compute.update_quota(@tenant_id, new_values.clone).status).must_equal 200 + _(@compute.get_quota(@tenant_id).body['quota_set']).must_equal new_values end end end diff --git a/test/requests/compute/security_group_tests.rb b/test/requests/compute/security_group_tests.rb index f776fd523..1a8c74737 100644 --- a/test/requests/compute/security_group_tests.rb +++ b/test/requests/compute/security_group_tests.rb @@ -39,40 +39,40 @@ describe "success" do it "#create_security_group(name, description)" do - @security_group.must_match_schema("security_group" => @security_group_format) + _(@security_group).must_match_schema("security_group" => @security_group_format) end it "#create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id=nil)" do - @security_group_rule.must_match_schema("security_group_rule" => @security_group_rule_format) + _(@security_group_rule).must_match_schema("security_group_rule" => @security_group_rule_format) end it "#list_security_groups" do - @compute.list_security_groups.body. + _(@compute.list_security_groups.body). must_match_schema("security_groups" => [@security_group_format]) end it "#get_security_group(security_group_id)" do - @compute.get_security_group(@security_group_id).body. + _(@compute.get_security_group(@security_group_id).body). must_match_schema("security_group" => @security_group_format) end it "#get_security_group_rule" do @compute.create_security_group_rule(@security_group_id, "tcp", 2222, 3333, "20.20.20.20/24").body - @compute.get_security_group_rule(@security_group_rule_id).body. + _(@compute.get_security_group_rule(@security_group_rule_id).body). must_match_schema("security_group_rule" => @security_group_rule_format) end it "#delete_security_group_rule(security_group_rule_id" do - @compute.delete_security_group_rule(@security_group_rule_id).status.must_equal 202 + _(@compute.delete_security_group_rule(@security_group_rule_id).status).must_equal 202 end it "#delete_security_group(security_group_id" do @compute.delete_security_group(@security_group_id) groups = @compute.list_security_groups.body['security_groups'] - groups.any? do |group| + _(groups.any? do |group| group['id'] == @security_group_id - end.must_equal false + end).must_equal false end end end diff --git a/test/requests/compute/server_tests.rb b/test/requests/compute/server_tests.rb index 3d7b30c3f..fbef6831b 100644 --- a/test/requests/compute/server_tests.rb +++ b/test/requests/compute/server_tests.rb @@ -76,14 +76,14 @@ def compute end it "#create_server('test', nil, #{@flavor_id}) with a block_device_mapping" do - @data.must_match_schema(@create_format, - nil, - :allow_extra_keys => true, - :allow_optional_rules => true) + _(@data).must_match_schema(@create_format, + nil, + :allow_extra_keys => true, + :allow_optional_rules => true) end it "#get_server_details(#{@server_id})" do - compute.get_server_details(@server_id).body['server']. + _(compute.get_server_details(@server_id).body['server']). must_match_schema(@base_server_format, nil, :allow_extra_keys => true, @@ -91,7 +91,7 @@ def compute end it "#block_device_mapping" do - compute.servers.get(@server_id).volumes.first.id.must_equal @volume1_id + _(compute.servers.get(@server_id).volumes.first.id).must_equal @volume1_id end describe "with multiple block_device_mapping_v2" do @@ -126,14 +126,14 @@ def compute end it "#create_server('test', nil, #{@flavor_id})" do - @data.must_match_schema(@create_format, - nil, - :allow_extra_keys => true, - :allow_optional_rules => true) + _(@data).must_match_schema(@create_format, + nil, + :allow_extra_keys => true, + :allow_optional_rules => true) end it "#get_server_details(#{@server_id})" do - compute.get_server_details(@server_id).body['server']. + _(compute.get_server_details(@server_id).body['server']). must_match_schema(@base_server_format, nil, :allow_extra_keys => true, @@ -143,7 +143,7 @@ def compute it "#block_device_mapping_v2" do # Breaks sometimes: "Expected: ["56", "56"] <=> Actual: ["56"]" skip unless Minitest::Test::UNIT_TESTS_CLEAN - compute.servers.get(@server_id).volumes.collect(&:id).sort. + _(compute.servers.get(@server_id).volumes.collect(&:id).sort). must_equal [@volume1_id, @volume2_id].sort end end @@ -157,14 +157,14 @@ def compute end it "#create_server('test', #{@image_id}, 19)" do - @data.must_match_schema(@create_format, - nil, - :allow_extra_keys => true, - :allow_optional_rules => true) + _(@data).must_match_schema(@create_format, + nil, + :allow_extra_keys => true, + :allow_optional_rules => true) end it "#get_server_details(#{@server_id})" do - compute.get_server_details(@server_id).body['server']. + _(compute.get_server_details(@server_id).body['server']). must_match_schema(@server_from_image_format, nil, :allow_extra_keys => true, @@ -190,20 +190,20 @@ def compute end it "#create_server('test', @image_id , 19, {'min_count' => 2, 'return_reservation_id' => 'True'})" do - @data.must_match_schema(@reservation_format, - nil, - :allow_extra_keys => true, - :allow_optional_rules => true) + _(@data).must_match_schema(@reservation_format, + nil, + :allow_extra_keys => true, + :allow_optional_rules => true) end it "#validate_multi_create" do - @multi_create_servers.size.must_equal 2 + _(@multi_create_servers.size).must_equal 2 end end # LIST it "#list_servers" do - compute.list_servers.body. + _(compute.list_servers.body). must_match_schema({'servers' => [OpenStack::Compute::Formats::SUMMARY]}, nil, :allow_extra_keys => true, @@ -212,7 +212,7 @@ def compute # DETAILS it "#list_servers_detail" do - compute.list_servers_detail.body["servers"][0]. + _(compute.list_servers_detail.body["servers"][0]). must_match_schema(@server_from_image_format, nil, :allow_extra_keys => true, @@ -222,25 +222,25 @@ def compute # CHANGE PASSWORD it "#change_server_password(#{@server_id}, 'fogupdatedserver')" do if set_password_enabled - compute.change_server_password(@server_id, 'foggy').status.must_equal 202 + _(compute.change_server_password(@server_id, 'foggy').status).must_equal 202 compute.servers.get(@server_id).wait_for { ready? } unless Fog.mocking? end end # UPDATE SERVER NAME it "#update_server(#{@server_id}, :name => 'fogupdatedserver')" do - compute.update_server(@server_id, :name => 'fogupdatedserver').status.must_equal 200 + _(compute.update_server(@server_id, :name => 'fogupdatedserver').status).must_equal 200 compute.servers.get(@server_id).wait_for { ready? } unless Fog.mocking? end # ADD SECURITY GROUP it "#add_security_group(#{@server_id}, #{@security_group_name})" do - compute.add_security_group(@server_id, @security_group_name).status.must_equal 200 + _(compute.add_security_group(@server_id, @security_group_name).status).must_equal 200 end # REMOVE SECURITY GROUP it "#remove_security_group(#{@server_id}, #{@security_group_name})" do - compute.remove_security_group(@server_id, @security_group_name).status.must_equal 200 + _(compute.remove_security_group(@server_id, @security_group_name).status).must_equal 200 end describe "Create image with metadata" do @@ -251,23 +251,23 @@ def compute end it "#create_image(#{@server_id}, 'fog')" do - @data.must_match_schema('image' => @image_format) + _(@data).must_match_schema('image' => @image_format) end it "#rebuild_server(#{@server_id}, #{@snapshot_id}, 'fog')" do - compute.rebuild_server( + _(compute.rebuild_server( @server_id, @snapshot_id, 'fog', 'newpass', "foo" => "bar" - ).body.must_match_schema({'server' => @server_from_image_format}, - nil, - :allow_extra_keys => true, - :allow_optional_rules => true) + ).body).must_match_schema({'server' => @server_from_image_format}, + nil, + :allow_extra_keys => true, + :allow_optional_rules => true) compute.servers.get(@server_id).wait_for { ready? } unless Fog.mocking? end # RESIZE it "#resize_server(#{@server_id}, #{get_flavor_ref_resize})" do - compute.resize_server(@server_id, get_flavor_ref_resize).status.must_equal 202 + _(compute.resize_server(@server_id, get_flavor_ref_resize).status).must_equal 202 unless Fog.mocking? compute.servers.get(@server_id).wait_for { state == 'VERIFY_RESIZE' } end @@ -275,7 +275,7 @@ def compute # RESIZE CONFIRM it "#resize_confirm(#{@server_id}, #{get_flavor_ref_resize})" do - compute.confirm_resize_server(@server_id).status.must_equal 204 + _(compute.confirm_resize_server(@server_id).status).must_equal 204 unless Fog.mocking? compute.servers.get(@server_id).wait_for { ready? } end @@ -283,7 +283,7 @@ def compute # REBOOT - HARD it "#reboot_server(#{@server_id}, 'HARD')" do - compute.reboot_server(@server_id, 'HARD').status.must_equal 202 + _(compute.reboot_server(@server_id, 'HARD').status).must_equal 202 unless Fog.mocking? compute.servers.get(@server_id).wait_for { ready? } end @@ -291,7 +291,7 @@ def compute # REBOOT - SOFT it "#reboot_server(#{@server_id}, 'SOFT')" do - compute.reboot_server(@server_id, 'SOFT').status.must_equal 202 + _(compute.reboot_server(@server_id, 'SOFT').status).must_equal 202 unless Fog.mocking? compute.servers.get(@server_id).wait_for { ready? } end @@ -299,26 +299,26 @@ def compute # STOP it "#stop_server(#{@server_id})" do - compute.stop_server(@server_id).must_equal true + _(compute.stop_server(@server_id)).must_equal true end # START it "#start_server(#{@server_id})" do - compute.start_server(@server_id).must_equal true + _(compute.start_server(@server_id)).must_equal true unless Fog.mocking? compute.servers.get(@server_id).wait_for { ready? } end end it "#shelve_server(#{@server_id}" do - compute.shelve_server(@server_id).must_equal true + _(compute.shelve_server(@server_id)).must_equal true unless Fog.mocking? compute.servers.get(@server_id).wait_for { ready? } end end it "#unshelve_server(#{@server_id})" do - compute.unshelve_server(@server_id).must_equal true + _(compute.unshelve_server(@server_id)).must_equal true unless Fog.mocking? compute.servers.get(@server_id).wait_for { ready? } end @@ -339,44 +339,44 @@ def compute describe "failure" do it "#delete_server(0)" do - proc do + _(proc do self.class.compute.delete_server(0) - end.must_raise Fog::OpenStack::Compute::NotFound + end).must_raise Fog::OpenStack::Compute::NotFound end it "#get_server_details(0)" do - proc do + _(proc do self.class.compute.get_server_details(0) - end.must_raise Fog::OpenStack::Compute::NotFound + end).must_raise Fog::OpenStack::Compute::NotFound end it "#update_server(0, :name => 'fogupdatedserver', :adminPass => 'fogupdatedserver')" do - proc do + _(proc do self.class.compute.update_server(0, :name => 'fogupdatedserver', :adminPass => 'fogupdatedserver') - end.must_raise Fog::OpenStack::Compute::NotFound + end).must_raise Fog::OpenStack::Compute::NotFound end it "#reboot_server(0)" do unless Fog.mocking? - proc do + _(proc do self.class.compute.reboot_server(0) - end.must_raise Fog::OpenStack::Compute::NotFound + end).must_raise Fog::OpenStack::Compute::NotFound end end it "#start_server(0)" do unless Fog.mocking? - proc do + _(proc do self.class.compute.start_server(0) - end.must_raise Fog::OpenStack::Compute::NotFound + end).must_raise Fog::OpenStack::Compute::NotFound end end it "#stop_server(0)" do unless Fog.mocking? - proc do + _(proc do self.class.compute.stop_server(0) - end.must_raise Fog::OpenStack::Compute::NotFound + end).must_raise Fog::OpenStack::Compute::NotFound end end end diff --git a/test/requests/compute/service_tests.rb b/test/requests/compute/service_tests.rb index 74f1a6063..f7390dada 100644 --- a/test/requests/compute/service_tests.rb +++ b/test/requests/compute/service_tests.rb @@ -18,27 +18,27 @@ describe "success" do it "#list_services" do - @services.must_match_schema('services' => [@service_format]) + _(@services).must_match_schema('services' => [@service_format]) end it "#disable_service" do - Fog::OpenStack::Compute.new.disable_service( + _(Fog::OpenStack::Compute.new.disable_service( @service['host'], @service['binary'] - ).body["service"]["status"].must_equal "disabled" + ).body["service"]["status"]).must_equal "disabled" end it "#disable_service_log_reason" do disabled_service = Fog::OpenStack::Compute.new.disable_service_log_reason( @service['host'], @service['binary'], 'reason' ).body - disabled_service["service"]["status"].must_equal "disabled" - disabled_service["service"]["disabled_reason"].must_equal "test2" + _(disabled_service["service"]["status"]).must_equal "disabled" + _(disabled_service["service"]["disabled_reason"]).must_equal "test2" end it "#enable_service" do - Fog::OpenStack::Compute.new.enable_service( + _(Fog::OpenStack::Compute.new.enable_service( @service['host'], @service['binary'] - ).body["service"]["status"].must_equal "enabled" + ).body["service"]["status"]).must_equal "enabled" end end end diff --git a/test/requests/compute/tenant_tests.rb b/test/requests/compute/tenant_tests.rb index ccc25cc02..706e87bfe 100644 --- a/test/requests/compute/tenant_tests.rb +++ b/test/requests/compute/tenant_tests.rb @@ -13,12 +13,12 @@ describe "success" do it "#list_tenants" do identity = Fog::OpenStack::Identity.new(:openstack_identity_api_version => 'v2.0') - identity.list_tenants.body. + _(identity.list_tenants.body). must_match_schema('tenants_links' => Array, 'tenants' => [@tenant_format]) end it "#set_tenant admin" do - Fog::OpenStack::Compute.new.set_tenant("admin").must_equal true + _(Fog::OpenStack::Compute.new.set_tenant("admin")).must_equal true end end end diff --git a/test/requests/compute/volume_tests.rb b/test/requests/compute/volume_tests.rb index ec78c1409..1bb55f1de 100644 --- a/test/requests/compute/volume_tests.rb +++ b/test/requests/compute/volume_tests.rb @@ -22,11 +22,11 @@ describe "success" do it "#create_volume" do - @volume.must_match_schema('volume' => @volume_format) + _(@volume).must_match_schema('volume' => @volume_format) end it "#list_volumes" do - @compute.list_volumes.body.must_match_schema('volumes' => [@volume_format]) + _(@compute.list_volumes.body).must_match_schema('volumes' => [@volume_format]) end describe "body" do @@ -35,12 +35,12 @@ end it "#get_volume_detail" do - @compute.get_volume_details(@volume_id). - body.must_match_schema('volume' => @volume_format) + _(@compute.get_volume_details(@volume_id). + body).must_match_schema('volume' => @volume_format) end it "delete_volume" do - @compute.delete_volume(@volume_id).status.must_equal 204 + _(@compute.delete_volume(@volume_id).status).must_equal 204 end end end diff --git a/test/requests/container_infra/bay_model_tests.rb b/test/requests/container_infra/bay_model_tests.rb index 677c26dff..6fb98844a 100644 --- a/test/requests/container_infra/bay_model_tests.rb +++ b/test/requests/container_infra/bay_model_tests.rb @@ -55,16 +55,16 @@ end it "#create_bay_model" do - @bay.must_match_schema(@bay_model_format) + _(@bay).must_match_schema(@bay_model_format) end it "#list_bay_models" do - container_infra.list_bay_models.body.must_match_schema('baymodels' => [@bay_model_format]) + _(container_infra.list_bay_models.body).must_match_schema('baymodels' => [@bay_model_format]) end it "#get_bay_model" do bay_model_uuid = container_infra.bay_models.all.first.uuid - container_infra.get_bay_model(bay_model_uuid).body.must_match_schema(@bay_model_format) + _(container_infra.get_bay_model(bay_model_uuid).body).must_match_schema(@bay_model_format) end it "#update_bay_model" do @@ -82,13 +82,13 @@ } ] - container_infra.update_bay_model(bay_model_uuid, attributes).body. + _(container_infra.update_bay_model(bay_model_uuid, attributes).body). must_match_schema(@bay_model_format) end it "#delete_bay_model" do bay_model_uuid = container_infra.bay_models.all.first.uuid - container_infra.delete_bay_model(bay_model_uuid).status.must_equal 204 + _(container_infra.delete_bay_model(bay_model_uuid).status).must_equal 204 end end end diff --git a/test/requests/container_infra/bay_tests.rb b/test/requests/container_infra/bay_tests.rb index 3f0fe6713..036e09fbf 100644 --- a/test/requests/container_infra/bay_tests.rb +++ b/test/requests/container_infra/bay_tests.rb @@ -47,16 +47,16 @@ end it "#create_bay" do - @bay.must_match_schema({"uuid" => String}) + _(@bay).must_match_schema({"uuid" => String}) end it "#list_bays" do - container_infra.list_bays.body.must_match_schema('bays' => [@bay_format]) + _(container_infra.list_bays.body).must_match_schema('bays' => [@bay_format]) end it "#get_bay" do bay_uuid = container_infra.bays.all.first.uuid - container_infra.get_bay(bay_uuid).body.must_match_schema(@bay_format) + _(container_infra.get_bay(bay_uuid).body).must_match_schema(@bay_format) end it "#update_bay" do @@ -69,13 +69,13 @@ } ] - container_infra.update_bay(bay_uuid, attributes).body. + _(container_infra.update_bay(bay_uuid, attributes).body). must_match_schema({"uuid" => String}) end it "#delete_bay" do bay_uuid = container_infra.bays.all.first.uuid - container_infra.delete_bay(bay_uuid).status.must_equal 204 + _(container_infra.delete_bay(bay_uuid).status).must_equal 204 end end end diff --git a/test/requests/container_infra/certificate_tests.rb b/test/requests/container_infra/certificate_tests.rb index 488bb3b5e..87c18e026 100644 --- a/test/requests/container_infra/certificate_tests.rb +++ b/test/requests/container_infra/certificate_tests.rb @@ -41,12 +41,12 @@ end it "#create_certificate" do - @certificate.must_match_schema(@certificate_format) + _(@certificate).must_match_schema(@certificate_format) end it "#get_certificate" do bay_uuid = container_infra.clusters.all.first.uuid - container_infra.get_certificate(bay_uuid).body.must_match_schema(@certificate_format) + _(container_infra.get_certificate(bay_uuid).body).must_match_schema(@certificate_format) end end end diff --git a/test/requests/container_infra/cluster_template_tests.rb b/test/requests/container_infra/cluster_template_tests.rb index 418a580a4..ca25c8af4 100644 --- a/test/requests/container_infra/cluster_template_tests.rb +++ b/test/requests/container_infra/cluster_template_tests.rb @@ -56,16 +56,16 @@ end it "#create_cluster_template" do - @cluster_template.must_match_schema("uuid" => String) + _(@cluster_template).must_match_schema("uuid" => String) end it "#list_cluster_templates" do - container_infra.list_cluster_templates.body.must_match_schema('clustertemplates' => [@cluster_template_format]) + _(container_infra.list_cluster_templates.body).must_match_schema('clustertemplates' => [@cluster_template_format]) end it "#get_cluster_template" do cluster_template_uuid = container_infra.cluster_templates.all.first.uuid - container_infra.get_cluster_template(cluster_template_uuid).body.must_match_schema(@cluster_template_format) + _(container_infra.get_cluster_template(cluster_template_uuid).body).must_match_schema(@cluster_template_format) end it "#update_cluster_template" do @@ -83,13 +83,13 @@ } ] - container_infra.update_cluster_template(cluster_template_uuid, attributes).body. + _(container_infra.update_cluster_template(cluster_template_uuid, attributes).body). must_match_schema(@cluster_template_format) end it "#delete_cluster_template" do cluster_template_uuid = container_infra.cluster_templates.all.first.uuid - container_infra.delete_cluster_template(cluster_template_uuid).status.must_equal 204 + _(container_infra.delete_cluster_template(cluster_template_uuid).status).must_equal 204 end end end diff --git a/test/requests/container_infra/cluster_tests.rb b/test/requests/container_infra/cluster_tests.rb index 100a3c08a..7cdff829c 100644 --- a/test/requests/container_infra/cluster_tests.rb +++ b/test/requests/container_infra/cluster_tests.rb @@ -47,16 +47,16 @@ end it "#create_cluster" do - @cluster.must_match_schema("uuid" => String) + _(@cluster).must_match_schema("uuid" => String) end it "#list_clusters" do - container_infra.list_clusters.body.must_match_schema('clusters' => [@cluster_format]) + _(container_infra.list_clusters.body).must_match_schema('clusters' => [@cluster_format]) end it "#get_cluster" do cluster_uuid = container_infra.clusters.all.first.uuid - container_infra.get_cluster(cluster_uuid).body.must_match_schema(@cluster_format) + _(container_infra.get_cluster(cluster_uuid).body).must_match_schema(@cluster_format) end it "#update_cluster" do @@ -69,13 +69,13 @@ } ] - container_infra.update_cluster(cluster_uuid, attributes).body. + _(container_infra.update_cluster(cluster_uuid, attributes).body). must_match_schema({"uuid" => String}) end it "#delete_cluster" do cluster_uuid = container_infra.clusters.all.first.uuid - container_infra.delete_cluster(cluster_uuid).status.must_equal 204 + _(container_infra.delete_cluster(cluster_uuid).status).must_equal 204 end end end diff --git a/test/requests/dns_v1/domain_tests.rb b/test/requests/dns_v1/domain_tests.rb index 0774c6ccc..53c0635d5 100644 --- a/test/requests/dns_v1/domain_tests.rb +++ b/test/requests/dns_v1/domain_tests.rb @@ -18,7 +18,7 @@ describe "success" do it "#list_domains" do - @dns.list_domains.body.must_match_schema("domains" => [@domain_format]) + _(@dns.list_domains.body).must_match_schema("domains" => [@domain_format]) end end end diff --git a/test/requests/dns_v1/quota_tests.rb b/test/requests/dns_v1/quota_tests.rb index 0733b5383..01bae6fe8 100644 --- a/test/requests/dns_v1/quota_tests.rb +++ b/test/requests/dns_v1/quota_tests.rb @@ -19,7 +19,7 @@ describe "success" do it "#get_quota" do - @quota.must_match_schema(@quota_format) + _(@quota).must_match_schema(@quota_format) end it "#update_quota" do @@ -28,8 +28,8 @@ 'domains' => @quota['domains'] + 2 ) - @dns.update_quota(@project_id, new_values.clone).status.must_equal 200 - @dns.get_quota(@project_id).body.must_equal new_values + _(@dns.update_quota(@project_id, new_values.clone).status).must_equal 200 + _(@dns.get_quota(@project_id).body).must_equal new_values end end end diff --git a/test/requests/dns_v2/pool_tests.rb b/test/requests/dns_v2/pool_tests.rb index e8a68ed4c..d83ea3cc8 100644 --- a/test/requests/dns_v2/pool_tests.rb +++ b/test/requests/dns_v2/pool_tests.rb @@ -22,11 +22,11 @@ describe "success" do it "#list_pools" do - @dns.list_pools.body.must_match_schema("pools" => [@pool_format]) + _(@dns.list_pools.body).must_match_schema("pools" => [@pool_format]) end it "#get_pool" do - @dns.get_pool(@pool_id).body.must_match_schema(@pool_format) + _(@dns.get_pool(@pool_id).body).must_match_schema(@pool_format) end end end diff --git a/test/requests/dns_v2/quota_tests.rb b/test/requests/dns_v2/quota_tests.rb index aec0065d3..f01cbe7b1 100644 --- a/test/requests/dns_v2/quota_tests.rb +++ b/test/requests/dns_v2/quota_tests.rb @@ -18,7 +18,7 @@ describe "success" do it "#get_quota" do - @quota.must_match_schema(@quota_format) + _(@quota).must_match_schema(@quota_format) end it "#update_quota" do @@ -27,8 +27,8 @@ 'zones' => @quota['zones'] + 2 ) - @dns.update_quota(@project_id, new_values.clone).status.must_equal 200 - @dns.get_quota(@project_id).body.must_equal new_values + _(@dns.update_quota(@project_id, new_values.clone).status).must_equal 200 + _(@dns.get_quota(@project_id).body).must_equal new_values # turn back @dns.update_quota(@project_id, @quota) end diff --git a/test/requests/dns_v2/recordset_tests.rb b/test/requests/dns_v2/recordset_tests.rb index 6d1b6295b..ed3a04ca3 100644 --- a/test/requests/dns_v2/recordset_tests.rb +++ b/test/requests/dns_v2/recordset_tests.rb @@ -44,34 +44,34 @@ describe "success" do it "#list_recordsets deprecated" do recordset_list_body = @dns.list_recordsets(@zone_id).body - recordset_list_body.must_match_schema(@recordset_list_format) - recordset_list_body['recordsets'].sample['zone_id'].must_equal(@zone_id) + _(recordset_list_body).must_match_schema(@recordset_list_format) + _(recordset_list_body['recordsets'].sample['zone_id']).must_equal(@zone_id) end it "#list_recordsets" do recordset_list_body = @dns.list_recordsets(:zone_id => @zone_id).body - recordset_list_body.must_match_schema(@recordset_list_format) - recordset_list_body['recordsets'].sample['zone_id'].must_equal(@zone_id) + _(recordset_list_body).must_match_schema(@recordset_list_format) + _(recordset_list_body['recordsets'].sample['zone_id']).must_equal(@zone_id) end it "#create_recordset" do - @recordset.body.must_match_schema(@recordset_format) + _(@recordset.body).must_match_schema(@recordset_format) end it "#get_recordset" do - @dns.get_recordset(@zone_id, @recordset.body['id']).body.must_match_schema(@recordset_format) + _(@dns.get_recordset(@zone_id, @recordset.body['id']).body).must_match_schema(@recordset_format) end it "#update_recordset" do - @dns.update_recordset( + _(@dns.update_recordset( @zone_id, @recordset.body['id'], "email" => 'new_hostmaster@test.example.org' - ).body.must_match_schema(@recordset_format) + ).body).must_match_schema(@recordset_format) end it "#delete_recordset" do - @dns.delete_recordset(@zone_id, @recordset.body['id']).body.must_match_schema(@recordset_format) + _(@dns.delete_recordset(@zone_id, @recordset.body['id']).body).must_match_schema(@recordset_format) end end end diff --git a/test/requests/dns_v2/zone_tests.rb b/test/requests/dns_v2/zone_tests.rb index 940777afb..c3f471174 100644 --- a/test/requests/dns_v2/zone_tests.rb +++ b/test/requests/dns_v2/zone_tests.rb @@ -28,23 +28,23 @@ describe "success" do it "#list_zones" do - @dns.list_zones.body.must_match_schema("zones" => [@zone_format]) + _(@dns.list_zones.body).must_match_schema("zones" => [@zone_format]) end it "#create_zone" do - @zone.body.must_match_schema(@zone_format) + _(@zone.body).must_match_schema(@zone_format) end it "#get_zone" do - @dns.get_zone(@zone_id).body.must_match_schema(@zone_format) + _(@dns.get_zone(@zone_id).body).must_match_schema(@zone_format) end it "#update_zone" do - @dns.update_zone(@zone_id, "email" => 'new_hostmaster@example.org').body.must_match_schema(@zone_format) + _(@dns.update_zone(@zone_id, "email" => 'new_hostmaster@example.org').body).must_match_schema(@zone_format) end it "#delete_zone" do - @dns.delete_zone(@zone_id).body.must_match_schema(@zone_format) + _(@dns.delete_zone(@zone_id).body).must_match_schema(@zone_format) end end end diff --git a/test/requests/event/event_tests.rb b/test/requests/event/event_tests.rb index f171a334f..eb35b5592 100644 --- a/test/requests/event/event_tests.rb +++ b/test/requests/event/event_tests.rb @@ -11,12 +11,12 @@ describe "success" do it "#list_events" do - @metering.list_events.body. + _(@metering.list_events.body). must_match_schema([@event_format]) end it "#get_event" do - @metering.get_event('test').body. + _(@metering.get_event('test').body). must_match_schema(@event_format) end end diff --git a/test/requests/identity/ec2_credentials_tests.rb b/test/requests/identity/ec2_credentials_tests.rb index bf1891b54..2476dd293 100644 --- a/test/requests/identity/ec2_credentials_tests.rb +++ b/test/requests/identity/ec2_credentials_tests.rb @@ -22,22 +22,22 @@ describe "success" do it "#create_ec2_credential" do - @response.body.must_match_schema('credential' => @credential_format) + _(@response.body).must_match_schema('credential' => @credential_format) end it "#get_ec2_credential" do - @identity.get_ec2_credential(@user_id, @ec2_credential['access']).body. + _(@identity.get_ec2_credential(@user_id, @ec2_credential['access']).body). must_match_schema('credential' => @credential_format) end it "#list_ec2_credentials" do - @identity.list_ec2_credentials(@user_id).body. + _(@identity.list_ec2_credentials(@user_id).body). must_match_schema('credentials' => [@credential_format]) end it "#delete_ec2_credential" do - @identity.delete_ec2_credential(@user_id, @ec2_credential['access']). - status.must_equal 204 + _(@identity.delete_ec2_credential(@user_id, @ec2_credential['access']). + status).must_equal 204 end end end diff --git a/test/requests/identity/role_tests.rb b/test/requests/identity/role_tests.rb index 4ab969af3..7b7e67f2b 100644 --- a/test/requests/identity/role_tests.rb +++ b/test/requests/identity/role_tests.rb @@ -16,39 +16,39 @@ describe "success" do it "#create_role('Role Name')" do - @role.must_match_schema(@role_format, nil, :allow_optional_rules => false) + _(@role).must_match_schema(@role_format, nil, :allow_optional_rules => false) end it "#list_roles" do - @identity.list_roles.body.must_match_schema('roles' => [@role_format]) + _(@identity.list_roles.body).must_match_schema('roles' => [@role_format]) end it "#get_role" do - @identity.get_role(@role['id']).body['role'].must_match_schema(@role_format) + _(@identity.get_role(@role['id']).body['role']).must_match_schema(@role_format) end it "#create_user_role(@tenant['id'], @user['id'], @role['id'])" do - @identity.create_user_role(@tenant['id'], @user['id'], @role['id']).body['role']. + _(@identity.create_user_role(@tenant['id'], @user['id'], @role['id']).body['role']). must_match_schema(@role_format) end it "#list_roles_for_user_on_tenant" do - @identity.list_roles_for_user_on_tenant(@tenant['id'], @user['id']).body['roles']. + _(@identity.list_roles_for_user_on_tenant(@tenant['id'], @user['id']).body['roles']). must_match_schema([@role_format]) end it "#delete_user_role with tenant" do - @identity.delete_user_role(@tenant['id'], @user['id'], @role['id']).body. + _(@identity.delete_user_role(@tenant['id'], @user['id'], @role['id']).body). must_equal "" end it "#delete_user_role with tenant" do - @identity.delete_user_role(@tenant['id'], @user['id'], @role['id']).status. + _(@identity.delete_user_role(@tenant['id'], @user['id'], @role['id']).status). must_equal 204 end it "#delete_role" do - @identity.delete_role(@role['id']).status.must_equal 204 + _(@identity.delete_role(@role['id']).status).must_equal 204 end end end diff --git a/test/requests/identity/tenant_tests.rb b/test/requests/identity/tenant_tests.rb index e5158e26c..67f33e770 100644 --- a/test/requests/identity/tenant_tests.rb +++ b/test/requests/identity/tenant_tests.rb @@ -24,21 +24,21 @@ describe "success" do it "#list_tenants" do - @identity.list_tenants.body.must_match_schema('tenants' => [@tenant_format], 'tenants_links' => []) + _(@identity.list_tenants.body).must_match_schema('tenants' => [@tenant_format], 'tenants_links' => []) end it "#list_roles_for_user_on_tenant(0,1)" do - @identity.list_roles_for_user_on_tenant( + _(@identity.list_roles_for_user_on_tenant( @identity.current_tenant['id'], OpenStack::Identity.get_user_id(@identity) - ).body.must_match_schema('roles' => [@role_format]) + ).body).must_match_schema('roles' => [@role_format]) end it "#create_tenant" do - @tenant.must_match_schema('tenant' => @tenant_format) + _(@tenant).must_match_schema('tenant' => @tenant_format) end it "#get_tenant" do - @identity.get_tenant(@tenant['tenant']['id']).body. + _(@identity.get_tenant(@tenant['tenant']['id']).body). must_match_schema('tenant' => @tenant_format) end @@ -48,14 +48,14 @@ @tenant['tenant']['id'], 'name' => tenant_name_update ) - tenant.body.must_match_schema('tenant' => @tenant_format) + _(tenant.body).must_match_schema('tenant' => @tenant_format) end it "#update_tenant update name" do tenant_name_update = Fog::Mock.random_hex(64) tenant = @identity.update_tenant( @tenant['tenant']['id'], 'name' => tenant_name_update).body - tenant['tenant']['name'].must_equal tenant_name_update + _(tenant['tenant']['name']).must_equal tenant_name_update end it "#delete_tenant" do diff --git a/test/requests/identity/user_tests.rb b/test/requests/identity/user_tests.rb index cedbce996..0c93b7697 100644 --- a/test/requests/identity/user_tests.rb +++ b/test/requests/identity/user_tests.rb @@ -25,29 +25,29 @@ describe "success" do it "#create_user(#{@user_name}, 'mypassword', 'morph@example.com', 't3n4nt1d', true)" do - @user.must_match_schema(@user_format, nil, :allow_optional_rules => false) + _(@user).must_match_schema(@user_format, nil, :allow_optional_rules => false) end it "#list_users" do - @identity.list_users.body["users"][0].must_match_schema(@user_format) + _(@identity.list_users.body["users"][0]).must_match_schema(@user_format) end it "#get_user_by_id" do - @identity.get_user_by_id(@user['id']).body['user'].must_match_schema(@user_format) + _(@identity.get_user_by_id(@user['id']).body['user']).must_match_schema(@user_format) end it "#get_user_by_name" do - @identity.get_user_by_name(@user['name']).body['user'].must_match_schema(@user_format) + _(@identity.get_user_by_name(@user['name']).body['user']).must_match_schema(@user_format) end it "#update_user" do - @identity.update_user( + _(@identity.update_user( @user['id'], :name => @user_name_update, :email => 'fog@test.com' - ).status.must_equal 200 + ).status).must_equal 200 end it "#delete_user" do - @identity.delete_user(@user['id']).status.must_equal 204 + _(@identity.delete_user(@user['id']).status).must_equal 204 end end end diff --git a/test/requests/image/image_tests.rb b/test/requests/image/image_tests.rb index 7a0fa2815..e86d94fdc 100644 --- a/test/requests/image/image_tests.rb +++ b/test/requests/image/image_tests.rb @@ -99,32 +99,32 @@ describe "success" do it "#list_public_images" do - Fog::OpenStack::Image.new.list_public_images.body.must_match_schema('images' => [@image_format]) + _(Fog::OpenStack::Image.new.list_public_images.body).must_match_schema('images' => [@image_format]) end it "#list_public_images_detailed" do - Fog::OpenStack::Image.new.list_public_images_detailed.body. + _(Fog::OpenStack::Image.new.list_public_images_detailed.body). must_match_schema('images' => [@detailed_image_format]) end it "#create_image" do - @instance.must_match_schema('image' => @detailed_image_format) + _(@instance).must_match_schema('image' => @detailed_image_format) end it "#get_image" do - Fog::OpenStack::Image.new.get_image(@instance['image']['id']).headers. + _(Fog::OpenStack::Image.new.get_image(@instance['image']['id']).headers). must_match_schema(@image_meta_format) end it "#update_image" do - Fog::OpenStack::Image.new.update_image( + _(Fog::OpenStack::Image.new.update_image( :id => @instance['image']['id'], :name => 'edit image' - ).body['image'].must_match_schema(@detailed_image_format) + ).body['image']).must_match_schema(@detailed_image_format) end it "#add_member_to_image" do - [200, 204].must_include( + _([200, 204]).must_include( Fog::OpenStack::Image.new.add_member_to_image( @instance['image']['id'], @instance['image']['owner'] ).status @@ -132,15 +132,15 @@ end it "#get_image_members" do - [200, 204].must_include(Fog::OpenStack::Image.new.get_image_members(@instance['image']['id']).status) + _([200, 204]).must_include(Fog::OpenStack::Image.new.get_image_members(@instance['image']['id']).status) end it "#get_shared_images" do - [200, 204].must_include(Fog::OpenStack::Image.new.get_shared_images(@instance['image']['owner']).status) + _([200, 204]).must_include(Fog::OpenStack::Image.new.get_shared_images(@instance['image']['owner']).status) end it "#remove_member_from_image" do - [200, 204].must_include( + _([200, 204]).must_include( Fog::OpenStack::Image.new.remove_member_from_image( @instance['image']['id'], @instance['image']['owner'] ).status @@ -148,7 +148,7 @@ end it "#delete_image" do - Fog::OpenStack::Image.new.delete_image(@instance['image']['id']).status.must_equal 200 + _(Fog::OpenStack::Image.new.delete_image(@instance['image']['id']).status).must_equal 200 end end end diff --git a/test/requests/introspection/introspection_tests.rb b/test/requests/introspection/introspection_tests.rb index 126b7e70d..1be7fb74f 100644 --- a/test/requests/introspection/introspection_tests.rb +++ b/test/requests/introspection/introspection_tests.rb @@ -283,19 +283,19 @@ describe "success" do it "#create_introspection" do - @inspector.create_introspection(@node_uuid).status.must_equal 202 + _(@inspector.create_introspection(@node_uuid).status).must_equal 202 end it "#abort_introspection" do - @inspector.abort_introspection(@node_uuid).status.must_equal 202 + _(@inspector.abort_introspection(@node_uuid).status).must_equal 202 end it "#get_introspection" do - @inspector.get_introspection(@node_uuid).body.must_match_schema(@introspection_finished) + _(@inspector.get_introspection(@node_uuid).body).must_match_schema(@introspection_finished) end it "#get_introspection_details" do - @inspector.get_introspection_details(@node_uuid).body.must_match_schema('data' => @introspection_data) + _(@inspector.get_introspection_details(@node_uuid).body).must_match_schema('data' => @introspection_data) end end end diff --git a/test/requests/introspection/rules_tests.rb b/test/requests/introspection/rules_tests.rb index 0835154d8..fbc7dac49 100644 --- a/test/requests/introspection/rules_tests.rb +++ b/test/requests/introspection/rules_tests.rb @@ -14,7 +14,7 @@ describe "success" do it "#list_rules" do - @inspector.list_rules.body.must_match_schema('rules' => @rules) + _(@inspector.list_rules.body).must_match_schema('rules' => @rules) end it "#create_rules" do @@ -32,19 +32,19 @@ "description" => "", "uuid" => "" } - @inspector.create_rules(attributes).body.must_match_schema('rules' => @rules) + _(@inspector.create_rules(attributes).body).must_match_schema('rules' => @rules) end it "#get_rules" do - @inspector.get_rules(@rules_id).body.must_match_schema('rules' => @rules) + _(@inspector.get_rules(@rules_id).body).must_match_schema('rules' => @rules) end it "#delete_rules" do - @inspector.delete_rules(@rules_id).status.must_equal 204 + _(@inspector.delete_rules(@rules_id).status).must_equal 204 end it "#delete_rules_all" do - @inspector.delete_rules_all.status.must_equal 204 + _(@inspector.delete_rules_all.status).must_equal 204 end end end diff --git a/test/requests/metering/event_tests.rb b/test/requests/metering/event_tests.rb index c07553403..5e95dd154 100644 --- a/test/requests/metering/event_tests.rb +++ b/test/requests/metering/event_tests.rb @@ -11,12 +11,12 @@ describe "success" do it "#list_events" do - @metering.list_events.body. + _(@metering.list_events.body). must_match_schema([@event_format]) end it "#get_event" do - @metering.get_event('test').body. + _(@metering.get_event('test').body). must_match_schema(@event_format) end end diff --git a/test/requests/metering/meter_tests.rb b/test/requests/metering/meter_tests.rb index c41ec5763..135153e93 100644 --- a/test/requests/metering/meter_tests.rb +++ b/test/requests/metering/meter_tests.rb @@ -44,15 +44,15 @@ describe "success" do it "#list_meters" do - @metering.list_meters.body.must_match_schema([@meter_format]) + _(@metering.list_meters.body).must_match_schema([@meter_format]) end it "#get_samples" do - @metering.get_samples('test').body.must_match_schema([@sample_format]) + _(@metering.get_samples('test').body).must_match_schema([@sample_format]) end it "#get_statistics" do - @metering.get_statistics('test').body.must_match_schema([@statistics_format]) + _(@metering.get_statistics('test').body).must_match_schema([@statistics_format]) end end end diff --git a/test/requests/metering/resource_tests.rb b/test/requests/metering/resource_tests.rb index 16b706ba1..895265128 100644 --- a/test/requests/metering/resource_tests.rb +++ b/test/requests/metering/resource_tests.rb @@ -14,11 +14,11 @@ describe "success" do it "#list_resource" do - @metering.list_resources.body.must_match_schema([@resource_format]) + _(@metering.list_resources.body).must_match_schema([@resource_format]) end it "#get_resource" do - @metering.get_resource('test').body.must_match_schema(@resource_format) + _(@metering.get_resource('test').body).must_match_schema(@resource_format) end end end diff --git a/test/requests/metric/metric_test.rb b/test/requests/metric/metric_test.rb index 4918afdd6..fbfed98c3 100644 --- a/test/requests/metric/metric_test.rb +++ b/test/requests/metric/metric_test.rb @@ -7,15 +7,15 @@ describe "success" do it "#list_metrics" do - @metric.list_metrics.status.must_equal 200 + _(@metric.list_metrics.status).must_equal 200 end it "#get_metric" do - @metric.get_metric('test').status.must_equal 200 + _(@metric.get_metric('test').status).must_equal 200 end it "#get_metric_measures" do - @metric.get_metric_measures('metricuuid123').status.must_equal 200 + _(@metric.get_metric_measures('metricuuid123').status).must_equal 200 end end end diff --git a/test/requests/metric/resource_test.rb b/test/requests/metric/resource_test.rb index d6b34f723..5ec2b41ff 100644 --- a/test/requests/metric/resource_test.rb +++ b/test/requests/metric/resource_test.rb @@ -7,19 +7,19 @@ describe "success" do it "#list_resources" do - @metric.list_resources.status.must_equal 200 + _(@metric.list_resources.status).must_equal 200 end it "#list_resources where type = instance_network_interface" do - @metric.list_resources("instance_network_interface").status.must_equal 200 + _(@metric.list_resources("instance_network_interface").status).must_equal 200 end it "#get_resource" do - @metric.get_resource('uuid1234').status.must_equal 200 + _(@metric.get_resource('uuid1234').status).must_equal 200 end it "#get_resource_metric_measures" do - @metric.get_resource_metric_measures('uuid123', 'cpu_util').status.must_equal 200 + _(@metric.get_resource_metric_measures('uuid123', 'cpu_util').status).must_equal 200 end end end diff --git a/test/requests/network/extension_tests.rb b/test/requests/network/extension_tests.rb index 11fec830e..6ac4fb3f9 100644 --- a/test/requests/network/extension_tests.rb +++ b/test/requests/network/extension_tests.rb @@ -13,22 +13,22 @@ describe "success" do it "#list_extensions" do - network.list_extensions.body. + _(network.list_extensions.body). must_match_schema('extensions' => [@extension_format]) end it "#get_extension" do extension_id = network.extensions.all.first.id - network.get_extension(extension_id).body. + _(network.get_extension(extension_id).body). must_match_schema('extension' => @extension_format) end end describe "failure" do it "#get_extension" do - proc do + _(proc do network.get_extension(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/network/ike_policy_tests.rb b/test/requests/network/ike_policy_tests.rb index e76b67732..ec4d329a8 100644 --- a/test/requests/network/ike_policy_tests.rb +++ b/test/requests/network/ike_policy_tests.rb @@ -32,17 +32,17 @@ end it "#create_ike_policy" do - @ike_policy.must_match_schema('ikepolicy' => @ike_policy_format) + _(@ike_policy).must_match_schema('ikepolicy' => @ike_policy_format) end it "#list_ike_policies" do - network.list_ike_policies.body. + _(network.list_ike_policies.body). must_match_schema('ikepolicies' => [@ike_policy_format]) end it "#get_ike_policy" do ike_policy_id = network.ike_policies.all.first.id - network.get_ike_policy(ike_policy_id).body. + _(network.get_ike_policy(ike_policy_id).body). must_match_schema('ikepolicy' => @ike_policy_format) end @@ -60,33 +60,33 @@ :ike_version => 'v1' } - network.update_ike_policy(ike_policy_id, attributes).body. + _(network.update_ike_policy(ike_policy_id, attributes).body). must_match_schema('ikepolicy' => @ike_policy_format) end it "#delete_ike_policy" do ike_policy_id = network.ike_policies.all.first.id - network.delete_ike_policy(ike_policy_id).status.must_equal 204 + _(network.delete_ike_policy(ike_policy_id).status).must_equal 204 end end describe "failure" do it "#get_ike_policy" do - proc do + _(proc do network.get_ike_policy(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#update_ike_policy" do - proc do + _(proc do network.update_ike_policy(0, {}) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_ike_policy" do - proc do + _(proc do network.delete_ike_policy(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/network/ipsec_policy_tests.rb b/test/requests/network/ipsec_policy_tests.rb index f3c1d3873..2c3760ea1 100644 --- a/test/requests/network/ipsec_policy_tests.rb +++ b/test/requests/network/ipsec_policy_tests.rb @@ -34,17 +34,17 @@ end it "#create_ipsec_policy" do - @create_ipsec_policy.must_match_schema('ipsecpolicy' => @ipsec_policy_format) + _(@create_ipsec_policy).must_match_schema('ipsecpolicy' => @ipsec_policy_format) end it "#list_ipsec_policies" do - network.list_ipsec_policies.body. + _(network.list_ipsec_policies.body). must_match_schema('ipsecpolicies' => [@ipsec_policy_format]) end it "#get_ipsec_policy" do ipsec_policy_id = network.ipsec_policies.all.first.id - network.get_ipsec_policy(ipsec_policy_id).body. + _(network.get_ipsec_policy(ipsec_policy_id).body). must_match_schema('ipsecpolicy' => @ipsec_policy_format) end @@ -62,33 +62,33 @@ :encapsulation_mode => 'tunnel' } - network.update_ipsec_policy(ipsec_policy_id, attributes).body. + _(network.update_ipsec_policy(ipsec_policy_id, attributes).body). must_match_schema('ipsecpolicy' => @ipsec_policy_format) end it "#delete_ipsec_policy" do ipsec_policy_id = network.ipsec_policies.all.first.id - network.delete_ipsec_policy(ipsec_policy_id).status.must_equal 204 + _(network.delete_ipsec_policy(ipsec_policy_id).status).must_equal 204 end end describe "failure" do it "#get_ipsec_policy" do - proc do + _(proc do network.get_ipsec_policy(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#update_ipsec_policy" do - proc do + _(proc do network.update_ipsec_policy(0, {}) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_ipsec_policy" do - proc do + _(proc do network.delete_ipsec_policy(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/network/ipsec_site_connection_tests.rb b/test/requests/network/ipsec_site_connection_tests.rb index 0912b07cc..22a4715d8 100644 --- a/test/requests/network/ipsec_site_connection_tests.rb +++ b/test/requests/network/ipsec_site_connection_tests.rb @@ -53,19 +53,19 @@ end it "#create_ipsec_site_connection" do - @ipsec_site_connection.must_match_schema( + _(@ipsec_site_connection).must_match_schema( 'ipsec_site_connection' => @ipsec_site_connection_format ) end it "#list_ipsec_site_connections" do - network.list_ipsec_site_connections.body. + _(network.list_ipsec_site_connections.body). must_match_schema('ipsec_site_connections' => [@ipsec_site_connection_format]) end it "#get_ipsec_site_connection" do ipsec_site_connection_id = network.ipsec_site_connections.all.first.id - network.get_ipsec_site_connection(ipsec_site_connection_id).body. + _(network.get_ipsec_site_connection(ipsec_site_connection_id).body). must_match_schema('ipsec_site_connection' => @ipsec_site_connection_format) end @@ -86,33 +86,33 @@ :admin_state_up => true } - network.update_ipsec_site_connection(ipsec_site_connection_id, attributes).body. + _(network.update_ipsec_site_connection(ipsec_site_connection_id, attributes).body). must_match_schema('ipsec_site_connection' => @ipsec_site_connection_format) end it "#delete_ipsec_site_connection" do ipsec_site_connection_id = network.ipsec_site_connections.all.first.id - network.delete_ipsec_site_connection(ipsec_site_connection_id).status.must_equal 204 + _(network.delete_ipsec_site_connection(ipsec_site_connection_id).status).must_equal 204 end end describe "failure" do it "#get_ipsec_site_connection" do - proc do + _(proc do network.get_ipsec_site_connection(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#update_ipsec_site_connection" do - proc do + _(proc do network.update_ipsec_site_connection(0, {}) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_ipsec_site_connection" do - proc do + _(proc do network.delete_ipsec_site_connection(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/network/lb_health_monitor_tests.rb b/test/requests/network/lb_health_monitor_tests.rb index a0dc44547..37fbef460 100644 --- a/test/requests/network/lb_health_monitor_tests.rb +++ b/test/requests/network/lb_health_monitor_tests.rb @@ -48,17 +48,17 @@ end it "#create_lb_health_monitor" do - @lb_health_monitor.must_match_schema('health_monitor' => @lb_health_monitor_format) + _(@lb_health_monitor).must_match_schema('health_monitor' => @lb_health_monitor_format) end it "#list_lb_health_monitors" do - network.list_lb_health_monitors.body. + _(network.list_lb_health_monitors.body). must_match_schema('health_monitors' => [@lb_health_monitor_format]) end it "#get_lb_health_monitor" do lb_health_monitor_id = network.lb_health_monitors.all.first.id - network.get_lb_health_monitor(lb_health_monitor_id).body. + _(network.get_lb_health_monitor(lb_health_monitor_id).body). must_match_schema('health_monitor' => @lb_health_monitor_format) end @@ -74,55 +74,55 @@ :admin_state_up => false } - network.update_lb_health_monitor(lb_health_monitor_id, attributes).body. + _(network.update_lb_health_monitor(lb_health_monitor_id, attributes).body). must_match_schema('health_monitor' => @lb_health_monitor_format) end it "#associate_lb_health_monitor" do lb_health_monitor_id = network.lb_health_monitors.all.first.id - network.associate_lb_health_monitor(@lb_pool.id, lb_health_monitor_id).status.must_equal 200 + _(network.associate_lb_health_monitor(@lb_pool.id, lb_health_monitor_id).status).must_equal 200 end it "#disassociate_lb_health_monitor" do lb_health_monitor_id = network.lb_health_monitors.all.first.id - network.disassociate_lb_health_monitor(@lb_pool.id, lb_health_monitor_id).status.must_equal 204 + _(network.disassociate_lb_health_monitor(@lb_pool.id, lb_health_monitor_id).status).must_equal 204 end it "#delete_lb_health_monitor" do lb_health_monitor_id = network.lb_health_monitors.all.first.id - network.delete_lb_health_monitor(lb_health_monitor_id).status.must_equal 204 + _(network.delete_lb_health_monitor(lb_health_monitor_id).status).must_equal 204 end end describe "failure" do it "#get_lb_health_monitor" do - proc do + _(proc do network.get_lb_health_monitor(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#update_lb_health_monitor" do - proc do + _(proc do network.update_lb_health_monitor(0, {}) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#associate_lb_health_monitor" do - proc do + _(proc do network.associate_lb_health_monitor(0, 0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#disassociate_lb_health_monitor" do - proc do + _(proc do network.disassociate_lb_health_monitor(0, 0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_lb_health_monitor" do - proc do + _(proc do network.delete_lb_health_monitor(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/network/lb_member_tests.rb b/test/requests/network/lb_member_tests.rb index eb734bfb9..c35472ddd 100644 --- a/test/requests/network/lb_member_tests.rb +++ b/test/requests/network/lb_member_tests.rb @@ -28,16 +28,16 @@ end it "#create_lb_member" do - @lb_member.must_match_schema('member' => @lb_member_format) + _(@lb_member).must_match_schema('member' => @lb_member_format) end it "#list_lb_members" do - network.list_lb_members.body.must_match_schema('members' => [@lb_member_format]) + _(network.list_lb_members.body).must_match_schema('members' => [@lb_member_format]) end it "#get_lb_member" do lb_member_id = network.lb_members.all.first.id - network.get_lb_member(lb_member_id).body. + _(network.get_lb_member(lb_member_id).body). must_match_schema('member' => @lb_member_format) end @@ -49,33 +49,33 @@ :admin_state_up => false } - network.update_lb_member(lb_member_id, attributes).body. + _(network.update_lb_member(lb_member_id, attributes).body). must_match_schema('member' => @lb_member_format) end it "#delete_lb_member" do lb_member_id = network.lb_members.all.first.id - network.delete_lb_member(lb_member_id).status.must_equal 204 + _(network.delete_lb_member(lb_member_id).status).must_equal 204 end end describe "failure" do it "#get_lb_member" do - proc do + _(proc do network.get_lb_member(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#update_lb_member" do - proc do + _(proc do network.update_lb_member(0, {}) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_lb_member" do - proc do + _(proc do network.delete_lb_member(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/network/lb_pool_tests.rb b/test/requests/network/lb_pool_tests.rb index 4a56292a6..6daedc9f7 100644 --- a/test/requests/network/lb_pool_tests.rb +++ b/test/requests/network/lb_pool_tests.rb @@ -44,23 +44,23 @@ end it "#create_lb_pool" do - @lb_pool.must_match_schema('pool' => @lb_pool_format) + _(@lb_pool).must_match_schema('pool' => @lb_pool_format) end it "#list_lb_pools" do - network.list_lb_pools.body. + _(network.list_lb_pools.body). must_match_schema('pools' => [@lb_pool_format]) end it "#get_lb_pool" do lb_pool_id = network.lb_pools.all.first.id - network.get_lb_pool(lb_pool_id).body. + _(network.get_lb_pool(lb_pool_id).body). must_match_schema('pool' => @lb_pool_format) end it "#get_lb_pool_stats" do lb_pool_id = network.lb_pools.all.first.id - network.get_lb_pool_stats(lb_pool_id).body. + _(network.get_lb_pool_stats(lb_pool_id).body). must_match_schema('stats' => @lb_pool_stats_format) end @@ -72,33 +72,33 @@ :lb_method => 'LEAST_CONNECTIONS', :admin_state_up => false } - network.update_lb_pool(lb_pool_id, attributes).body. + _(network.update_lb_pool(lb_pool_id, attributes).body). must_match_schema('pool' => @lb_pool_format) end it "#delete_lb_pool" do lb_pool_id = network.lb_pools.all.first.id - network.delete_lb_pool(lb_pool_id).status.must_equal 204 + _(network.delete_lb_pool(lb_pool_id).status).must_equal 204 end end describe "failure" do it "#get_lb_pool" do - proc do + _(proc do network.get_lb_pool(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#update_lb_pool" do - proc do + _(proc do network.update_lb_pool(0, {}) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_lb_pool" do - proc do + _(proc do network.delete_lb_pool(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/network/lb_vip_tests.rb b/test/requests/network/lb_vip_tests.rb index e92bc2e15..8e32e93a4 100644 --- a/test/requests/network/lb_vip_tests.rb +++ b/test/requests/network/lb_vip_tests.rb @@ -37,16 +37,16 @@ end it "#create_lb_vip" do - @lb_vip.must_match_schema('vip' => @lb_vip_format) + _(@lb_vip).must_match_schema('vip' => @lb_vip_format) end it "#list_lb_vips" do - network.list_lb_vips.body.must_match_schema('vips' => [@lb_vip_format]) + _(network.list_lb_vips.body).must_match_schema('vips' => [@lb_vip_format]) end it "#get_lb_vip" do lb_vip_id = network.lb_vips.all.first.id - network.get_lb_vip(lb_vip_id).body. + _(network.get_lb_vip(lb_vip_id).body). must_match_schema('vip' => @lb_vip_format) end @@ -60,33 +60,33 @@ :session_persistence => {"type" => "HTTP_COOKIE"}, :admin_state_up => false } - network.update_lb_vip(lb_vip_id, attributes).body. + _(network.update_lb_vip(lb_vip_id, attributes).body). must_match_schema('vip' => @lb_vip_format) end it "#delete_lb_vip" do lb_vip_id = network.lb_vips.all.first.id - network.delete_lb_vip(lb_vip_id).status.must_equal 204 + _(network.delete_lb_vip(lb_vip_id).status).must_equal 204 end end describe "failure" do it "#get_lb_vip" do - proc do + _(proc do network.get_lb_vip(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#update_lb_vip" do - proc do + _(proc do network.update_lb_vip(0, {}) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_lb_vip" do - proc do + _(proc do network.delete_lb_vip(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/network/network_tests.rb b/test/requests/network/network_tests.rb index 57bdeab8b..99632fec4 100644 --- a/test/requests/network/network_tests.rb +++ b/test/requests/network/network_tests.rb @@ -43,7 +43,7 @@ end it "#create_network" do - created_network.must_match_schema("network" => network_format) + _(created_network).must_match_schema("network" => network_format) end it "#create_network+provider extensions" do @@ -62,18 +62,18 @@ :router_external => true, } - network.create_network(attributes).body. + _(network.create_network(attributes).body). must_match_schema('network' => network_format.merge(network_extentions_format)) end it "#list_networks" do - network.list_networks.body. + _(network.list_networks.body). must_match_schema('networks' => [network_format]) end it "#get_network" do network_id = created_network["network"]["id"] - network.get_network(network_id).body. + _(network.get_network(network_id).body). must_match_schema('network' => network_format) end @@ -89,20 +89,20 @@ network_id = network.networks.all.first.id network_update_extentions_format = {"router:external" => Fog::Boolean} - network.update_network(network_id, attributes).body. + _(network.update_network(network_id, attributes).body). must_match_schema('network' => network_format.merge(network_update_extentions_format)) end it "#delete_network" do network_id = network.networks.all.first.id - network.delete_network(network_id).status.must_equal 204 + _(network.delete_network(network_id).status).must_equal 204 end end describe "failure" do it "#create_network+provider extensions" do unless Fog.mocking? - proc do + _(proc do attributes = { :name => 'net_name', :shared => false, @@ -117,26 +117,26 @@ } network.create_network(attributes) - end.must_raise Excon::Errors::BadRequest + end).must_raise Excon::Errors::BadRequest end end it "#get_network" do - proc do + _(proc do network.get_network(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#update_network" do - proc do + _(proc do network.update_network(0, {}) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_network" do - proc do + _(proc do network.delete_network(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end diff --git a/test/requests/network/port_tests.rb b/test/requests/network/port_tests.rb index 8caf37014..95a758aef 100644 --- a/test/requests/network/port_tests.rb +++ b/test/requests/network/port_tests.rb @@ -37,18 +37,18 @@ end it "#create_port" do - @port.must_match_schema('port' => @port_format) + _(@port).must_match_schema('port' => @port_format) end it "#list_port" do # Breaks because sometimes "security_groups" => nil skip unless Minitest::Test::UNIT_TESTS_CLEAN - network.list_ports.body.must_match_schema('ports' => [@port_format]) + _(network.list_ports.body).must_match_schema('ports' => [@port_format]) end it "#get_port" do port_id = network.ports.all.first.id - network.get_port(port_id).body.must_match_schema('port' => @port_format) + _(network.get_port(port_id).body).must_match_schema('port' => @port_format) end it "#update_port" do @@ -61,33 +61,33 @@ :device_id => 'device_id' } - network.update_port(port_id, attributes).body. + _(network.update_port(port_id, attributes).body). must_match_schema('port' => @port_format) end it "#delete_port" do port_id = network.ports.all.first.id - network.delete_port(port_id).status.must_equal 204 + _(network.delete_port(port_id).status).must_equal 204 end end describe "failure" do it "#get_port" do - proc do + _(proc do network.get_port(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#update_port" do - proc do + _(proc do network.update_port(0, {}) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_port" do - proc do + _(proc do network.delete_port(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/network/quota_tests.rb b/test/requests/network/quota_tests.rb index e5d06c2cc..22d910cb0 100644 --- a/test/requests/network/quota_tests.rb +++ b/test/requests/network/quota_tests.rb @@ -28,11 +28,11 @@ describe "success" do it "#get_quotas" do - network.get_quotas.body.must_match_schema('quotas' => @quotas_format) + _(network.get_quotas.body).must_match_schema('quotas' => @quotas_format) end it "#get_quota" do - @quota.must_match_schema(@quota_format) + _(@quota).must_match_schema(@quota_format) end it "#update_quota" do @@ -42,15 +42,15 @@ ) network.update_quota(@tenant_id, new_values.clone) - network.get_quota(@tenant_id).body['quota'].must_equal new_values + _(network.get_quota(@tenant_id).body['quota']).must_equal new_values network.update_quota(@tenant_id, @quota.clone) - network.get_quota(@tenant_id).body['quota'].must_equal @quota + _(network.get_quota(@tenant_id).body['quota']).must_equal @quota end end describe "#delete_quota" do it "succeeds" do - network.delete_quota(@tenant_id).status.must_equal 204 + _(network.delete_quota(@tenant_id).status).must_equal 204 end end end diff --git a/test/requests/network/router_tests.rb b/test/requests/network/router_tests.rb index 6b10de227..4a835cbd6 100644 --- a/test/requests/network/router_tests.rb +++ b/test/requests/network/router_tests.rb @@ -23,16 +23,16 @@ end it "#create_router" do - @router.must_match_schema('router' => @router_format) + _(@router).must_match_schema('router' => @router_format) end it "#list_routers" do - network.list_routers.body.must_match_schema('routers' => [@router_format]) + _(network.list_routers.body).must_match_schema('routers' => [@router_format]) end it "#get_router" do router_id = network.routers.all.first.id - network.get_router(router_id).body.must_match_schema('router' => @router_format) + _(network.get_router(router_id).body).must_match_schema('router' => @router_format) end it "#update_router" do @@ -43,7 +43,7 @@ :status => 'ACTIVE', :admin_state_up => true } - network.update_router(router_id, attributes).body.must_match_schema('router' => @router_format) + _(network.update_router(router_id, attributes).body).must_match_schema('router' => @router_format) end it "#update_router_with_network" do @@ -56,32 +56,32 @@ :admin_state_up => true } - network.update_router(router_id, attributes).body.must_match_schema('router' => @router_format) + _(network.update_router(router_id, attributes).body).must_match_schema('router' => @router_format) end it "#delete_router" do router_id = network.routers.all.last.id - network.delete_router(router_id).status.must_equal 204 + _(network.delete_router(router_id).status).must_equal 204 end end describe "failure" do it "#get_router" do - proc do + _(proc do network.get_router(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#update_router" do - proc do + _(proc do network.update_router(0, {}) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_router" do - proc do + _(proc do network.delete_router(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/network/security_group_rule_tests.rb b/test/requests/network/security_group_rule_tests.rb index f8083255b..4a80169b9 100644 --- a/test/requests/network/security_group_rule_tests.rb +++ b/test/requests/network/security_group_rule_tests.rb @@ -36,36 +36,36 @@ end it "#create_security_group_rule(@sec_group_id, 'ingress', attributes)" do - @security_group_rule.must_match_schema(@security_group_rule_format) + _(@security_group_rule).must_match_schema(@security_group_rule_format) end it "#get_security_group_rule(@sec_group_rule_id)" do - network.get_security_group_rule(@sec_group_rule_id). - body["security_group_rule"].must_match_schema(@security_group_rule_format) + _(network.get_security_group_rule(@sec_group_rule_id). + body["security_group_rule"]).must_match_schema(@security_group_rule_format) end it "#list_security_group_rules" do - network.list_security_group_rules.body.must_match_schema( + _(network.list_security_group_rules.body).must_match_schema( "security_group_rules" => [@security_group_rule_format] ) end it "#delete_security_group_rule(@sec_group_rule_id)" do - network.delete_security_group_rule(@sec_group_rule_id).status.must_equal 204 + _(network.delete_security_group_rule(@sec_group_rule_id).status).must_equal 204 end end describe "failure" do it "#get_security_group_rule(0)" do - proc do + _(proc do network.get_security_group_rule(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_security_group_rule(0)" do - proc do + _(proc do network.delete_security_group_rule(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/network/security_group_tests.rb b/test/requests/network/security_group_tests.rb index 6622e4fed..8c68534ed 100644 --- a/test/requests/network/security_group_tests.rb +++ b/test/requests/network/security_group_tests.rb @@ -21,16 +21,16 @@ end it "#create_security_group('fog_security_group', 'tests group')" do - @security_group.must_match_schema(@security_group_format) + _(@security_group).must_match_schema(@security_group_format) end it "#get_security_group('#{@sec_group_id}')" do - network.get_security_group(@sec_group_id).body["security_group"]. + _(network.get_security_group(@sec_group_id).body["security_group"]). must_match_schema(@security_group_format) end it "#list_security_groups" do - network.list_security_groups.body. + _(network.list_security_groups.body). must_match_schema('security_groups' => [@security_group_format]) end @@ -41,26 +41,26 @@ :description => "New sg desc", } updated = network.update_security_group(security_group_id, attributes) - updated.body.must_match_schema("security_group" => @security_group_format) - updated.body["security_group"]["name"].must_equal "new_security_group_name" + _(updated.body).must_match_schema("security_group" => @security_group_format) + _(updated.body["security_group"]["name"]).must_equal "new_security_group_name" end it "#delete_security_group('#{@sec_group_id}')" do - network.delete_security_group(@sec_group_id).status.must_equal 204 + _(network.delete_security_group(@sec_group_id).status).must_equal 204 end end describe "failure" do it "#get_security_group(0)" do - proc do + _(proc do network.get_security_group(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_security_group(0)" do - proc do + _(proc do network.delete_security_group(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/network/subnet_pool_tests.rb b/test/requests/network/subnet_pool_tests.rb index 50005886f..2f859839b 100644 --- a/test/requests/network/subnet_pool_tests.rb +++ b/test/requests/network/subnet_pool_tests.rb @@ -28,16 +28,16 @@ @subnet_pool = network.create_subnet_pool(name, prefixes).body end it "#create_subnet_pool" do - @subnet_pool.must_match_schema('subnetpool' => @subnet_pool_format) + _(@subnet_pool).must_match_schema('subnetpool' => @subnet_pool_format) end it "#list_subnet_pool" do - network.list_subnet_pools.body.must_match_schema('subnetpools' => [@subnet_pool_format]) + _(network.list_subnet_pools.body).must_match_schema('subnetpools' => [@subnet_pool_format]) end it "#get_subnet_pool" do subnet_pool_id = network.subnet_pools.all.first.id - network.get_subnet_pool(subnet_pool_id).body.must_match_schema('subnetpool' => @subnet_pool_format) + _(network.get_subnet_pool(subnet_pool_id).body).must_match_schema('subnetpool' => @subnet_pool_format) end it "#update_subnet_pool" do @@ -46,32 +46,33 @@ :name => 'new_subnet_pool_name' } - network.update_subnet_pool(subnet_pool_id, attributes).body.must_match_schema('subnetpool' => @subnet_pool_format) + _(network.update_subnet_pool(subnet_pool_id, attributes).body) + .must_match_schema('subnetpool' => @subnet_pool_format) end it "#delete_subnet_pool" do subnet_pool_id = network.subnet_pools.all.first.id - network.delete_subnet_pool(subnet_pool_id).status.must_equal 204 + _(network.delete_subnet_pool(subnet_pool_id).status).must_equal 204 end end describe "failure" do it "#get_subnet_pool" do - proc do + _(proc do network.get_subnet_pool(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#update_subnet_pool" do - proc do + _(proc do network.update_subnet_pool(0, {}) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_subnet_pool" do - proc do + _(proc do network.delete_subnet_pool(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/network/subnet_tests.rb b/test/requests/network/subnet_tests.rb index e18338382..09958354f 100644 --- a/test/requests/network/subnet_tests.rb +++ b/test/requests/network/subnet_tests.rb @@ -34,16 +34,16 @@ @subnet = network.create_subnet(network_id, cidr, ip_version, attributes).body end it "#create_subnet" do - @subnet.must_match_schema('subnet' => @subnet_format) + _(@subnet).must_match_schema('subnet' => @subnet_format) end it "#list_subnet" do - network.list_subnets.body.must_match_schema('subnets' => [@subnet_format]) + _(network.list_subnets.body).must_match_schema('subnets' => [@subnet_format]) end it "#get_subnet" do subnet_id = network.subnets.all.first.id - network.get_subnet(subnet_id).body.must_match_schema('subnet' => @subnet_format) + _(network.get_subnet(subnet_id).body).must_match_schema('subnet' => @subnet_format) end it "#update_subnet" do @@ -57,32 +57,32 @@ :enable_dhcp => true } - network.update_subnet(subnet_id, attributes).body.must_match_schema('subnet' => @subnet_format) + _(network.update_subnet(subnet_id, attributes).body).must_match_schema('subnet' => @subnet_format) end it "#delete_subnet" do subnet_id = network.subnets.all.first.id - network.delete_subnet(subnet_id).status.must_equal 204 + _(network.delete_subnet(subnet_id).status).must_equal 204 end end describe "failure" do it "#get_subnet" do - proc do + _(proc do network.get_subnet(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#update_subnet" do - proc do + _(proc do network.update_subnet(0, {}) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_subnet" do - proc do + _(proc do network.delete_subnet(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/network/vpn_service_tests.rb b/test/requests/network/vpn_service_tests.rb index 1145a03f6..631e77d32 100644 --- a/test/requests/network/vpn_service_tests.rb +++ b/test/requests/network/vpn_service_tests.rb @@ -32,16 +32,16 @@ end it "#create_vpn_service" do - @vpn_service.must_match_schema('vpnservice' => @vpn_service_format) + _(@vpn_service).must_match_schema('vpnservice' => @vpn_service_format) end it "#list_vpn_services" do - network.list_vpn_services.body.must_match_schema('vpnservices' => [@vpn_service_format]) + _(network.list_vpn_services.body).must_match_schema('vpnservices' => [@vpn_service_format]) end it "#get_vpn_service" do vpn_service_id = network.vpn_services.all.first.id - network.get_vpn_service(vpn_service_id).body.must_match_schema('vpnservice' => @vpn_service_format) + _(network.get_vpn_service(vpn_service_id).body).must_match_schema('vpnservice' => @vpn_service_format) end it "#update_vpn_service" do @@ -55,32 +55,33 @@ :router_id => 'router_id' } - network.update_vpn_service(vpn_service_id, attributes).body.must_match_schema('vpnservice' => @vpn_service_format) + _(network.update_vpn_service(vpn_service_id, attributes).body) + .must_match_schema('vpnservice' => @vpn_service_format) end it "#delete_vpn_service" do vpn_servcice_id = network.vpn_services.all.first.id - network.delete_vpn_service(vpn_servcice_id).status.must_equal 204 + _(network.delete_vpn_service(vpn_servcice_id).status).must_equal 204 end end describe "failure" do it "#get_vpn_service" do - proc do + _(proc do network.get_vpn_service(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#update_lb_pool" do - proc do + _(proc do network.update_lb_pool(0, {}) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end it "#delete_vpn_service" do - proc do + _(proc do network.delete_vpn_service(0) - end.must_raise Fog::OpenStack::Network::NotFound + end).must_raise Fog::OpenStack::Network::NotFound end end end diff --git a/test/requests/nfv/vnf_tests.rb b/test/requests/nfv/vnf_tests.rb index 859acb77a..71bcef7b0 100644 --- a/test/requests/nfv/vnf_tests.rb +++ b/test/requests/nfv/vnf_tests.rb @@ -37,29 +37,30 @@ describe "success" do it "#create_vnfs" do - @vnf_body.must_match_schema('vnf' => @vnfs_create) + _(@vnf_body).must_match_schema('vnf' => @vnfs_create) end it "#list_vnfs" do - @nfv.list_vnfs.body.must_match_schema('vnfs' => [@vnfs]) + _(@nfv.list_vnfs.body).must_match_schema('vnfs' => [@vnfs]) end it "#get_vnfs" do - @nfv.get_vnf(@vnf_body["vnf"]["id"]).body.must_match_schema('vnf' => @vnfs) + _(@nfv.get_vnf(@vnf_body["vnf"]["id"]).body).must_match_schema('vnf' => @vnfs) end describe "inter2" do it "#update_vnfs" do vnf_data = {:attributes => {:config => "vdus:\n vdu1: \n\n"}} auth = {"tenantName" => "admin", "passwordCredentials" => {"username" => "admin", "password" => "password"}} - @nfv.update_vnf(@vnf_body["vnf"]["id"], :vnf => vnf_data, :auth => auth).body.must_match_schema('vnf' => @vnfs) + _(@nfv.update_vnf(@vnf_body["vnf"]["id"], :vnf => vnf_data, :auth => auth).body) + .must_match_schema('vnf' => @vnfs) end it "#delete_vnfs" do sleep(10) unless Fog.mocking? - @nfv.delete_vnf(@vnf_body["vnf"]["id"]).status.must_equal 204 - @nfv.delete_vnfd(@vnfd_body["vnfd"]["id"]).status.must_equal 204 + _(@nfv.delete_vnf(@vnf_body["vnf"]["id"]).status).must_equal 204 + _(@nfv.delete_vnfd(@vnfd_body["vnfd"]["id"]).status).must_equal 204 end end end diff --git a/test/requests/nfv/vnfd_tests.rb b/test/requests/nfv/vnfd_tests.rb index 040e88ab3..b30a08abe 100644 --- a/test/requests/nfv/vnfd_tests.rb +++ b/test/requests/nfv/vnfd_tests.rb @@ -19,19 +19,19 @@ describe "success" do it "#create_vnfds" do - @vnfd_body.must_match_schema('vnfd' => @vnfds) + _(@vnfd_body).must_match_schema('vnfd' => @vnfds) end it "#list_vnfds" do - @nfv.list_vnfds.body.must_match_schema('vnfds' => [@vnfds]) + _(@nfv.list_vnfds.body).must_match_schema('vnfds' => [@vnfds]) end it "#get_vnfds" do - @nfv.get_vnfd(@vnfd_body["vnfd"]["id"]).body.must_match_schema('vnfd' => @vnfds) + _(@nfv.get_vnfd(@vnfd_body["vnfd"]["id"]).body).must_match_schema('vnfd' => @vnfds) end it "#delete_vnfds" do - @nfv.delete_vnfd(@vnfd_body["vnfd"]["id"]).status.must_equal 204 + _(@nfv.delete_vnfd(@vnfd_body["vnfd"]["id"]).status).must_equal 204 end end end diff --git a/test/requests/orchestration/stack_tests.rb b/test/requests/orchestration/stack_tests.rb index 4becd492d..64d412eb2 100644 --- a/test/requests/orchestration/stack_tests.rb +++ b/test/requests/orchestration/stack_tests.rb @@ -63,7 +63,7 @@ describe "success" do it "#create_stack" do - @stack = @orchestration.create_stack(:stack_name => "teststack").body.must_match_schema(@create_format) + @stack = _(@orchestration.create_stack(:stack_name => "teststack").body).must_match_schema(@create_format) end it "#create_stack_with_files" do @@ -71,7 +71,7 @@ :stack_name => "teststack_files", :files => {'foo.sh'=>'hello'} } - @stack = @orchestration.create_stack(args).body.must_match_schema(@create_format_files) + @stack = _(@orchestration.create_stack(args).body).must_match_schema(@create_format_files) end it "#create_stack_resolve_files" do @@ -81,7 +81,7 @@ :template => YAML.load_file("local.yaml"), } response = @orchestration.create_stack(args) - response.body.must_match_schema(@create_format_files) + _(response.body).must_match_schema(@create_format_files) files = response.body['files'] Fog::Logger.warning("Request processed: #{files.keys}") assert_equal_set(expected, files.keys) @@ -95,34 +95,34 @@ :files => {expected[-1] => "# just a mock"} } response = @orchestration.create_stack(args) - response.body.must_match_schema(@create_format_files) + _(response.body).must_match_schema(@create_format_files) files = response.body['files'] Fog::Logger.warning("Request processed: #{files.keys}") assert_equal_set(expected, files.keys) end it "#list_stack_data" do - @orchestration.list_stack_data.body.must_match_schema('stacks' => [@stack_format]) + _(@orchestration.list_stack_data.body).must_match_schema('stacks' => [@stack_format]) end it "#list_stack_data_Detailed" do - @orchestration.list_stack_data_detailed.body.must_match_schema('stacks' => [@stack_detailed_format]) + _(@orchestration.list_stack_data_detailed.body).must_match_schema('stacks' => [@stack_detailed_format]) end it "#update_stack" do - @orchestration.update_stack(@stack_mock).body.must_match_schema({}) + _(@orchestration.update_stack(@stack_mock).body).must_match_schema({}) end it "#patch_stack" do - @orchestration.patch_stack(@stack_mock).body.must_match_schema({}) + _(@orchestration.patch_stack(@stack_mock).body).must_match_schema({}) end it "#delete_stack" do - @orchestration.delete_stack(@stack_mock).body.must_match_schema({}) + _(@orchestration.delete_stack(@stack_mock).body).must_match_schema({}) end it "#cancel_update" do - @orchestration.cancel_update(@stack_mock).body.must_match_schema({}) + _(@orchestration.cancel_update(@stack_mock).body).must_match_schema({}) end end end diff --git a/test/requests/planning/plan_tests.rb b/test/requests/planning/plan_tests.rb index 602ab706c..884f1a649 100644 --- a/test/requests/planning/plan_tests.rb +++ b/test/requests/planning/plan_tests.rb @@ -21,15 +21,15 @@ describe "success" do it "#list_plans" do - @plans.must_match_schema([@plan_format]) + _(@plans).must_match_schema([@plan_format]) end it "#get_plan" do - Fog::OpenStack::Planning.new.get_plan(@instance['uuid']).body.must_match_schema(@plan_format) + _(Fog::OpenStack::Planning.new.get_plan(@instance['uuid']).body).must_match_schema(@plan_format) end it "#delete_plan" do - Fog::OpenStack::Planning.new.delete_plan(@instance['uuid']).status.must_equal 204 + _(Fog::OpenStack::Planning.new.delete_plan(@instance['uuid']).status).must_equal 204 end it "#create_plan" do @@ -38,14 +38,14 @@ :description => 'test-plan-desc', } @instance = Fog::OpenStack::Planning.new.create_plan(plan_attributes).body - @instance.must_match_schema(@plan_format) + _(@instance).must_match_schema(@plan_format) end it "#add_role_to_plan" do - Fog::OpenStack::Planning.new.add_role_to_plan( + _(Fog::OpenStack::Planning.new.add_role_to_plan( @instance['uuid'], @role_instance['uuid'] - ).body.must_match_schema(@plan_format) + ).body).must_match_schema(@plan_format) end it "#patch_plan" do @@ -57,19 +57,19 @@ "value" => "test-#{parameter['name']}-value", } end - Fog::OpenStack::Planning.new.patch_plan(@instance['uuid'], plan_parameters).body. + _(Fog::OpenStack::Planning.new.patch_plan(@instance['uuid'], plan_parameters).body). must_match_schema(@plan_format) end it "#get_plan_templates" do - Fog::OpenStack::Planning.new.get_plan_templates(@instance['uuid']).body. + _(Fog::OpenStack::Planning.new.get_plan_templates(@instance['uuid']).body). must_match_schema(@plan_templates_format) end it "#remove_role_from_plan" do - Fog::OpenStack::Planning.new.remove_role_from_plan( + _(Fog::OpenStack::Planning.new.remove_role_from_plan( @instance['uuid'], @role_instance['uuid'] - ).body.must_match_schema(@plan_format) + ).body).must_match_schema(@plan_format) end end end diff --git a/test/requests/planning/role_tests.rb b/test/requests/planning/role_tests.rb index 0545482ea..5bbe5f258 100644 --- a/test/requests/planning/role_tests.rb +++ b/test/requests/planning/role_tests.rb @@ -12,7 +12,7 @@ describe "success" do it "#list_roles" do - Fog::OpenStack::Planning.new.list_roles.body.must_match_schema([@role_format]) + _(Fog::OpenStack::Planning.new.list_roles.body).must_match_schema([@role_format]) end end end diff --git a/test/requests/shared_file_system/quota_tests.rb b/test/requests/shared_file_system/quota_tests.rb index d2fe3db20..41c6e1881 100644 --- a/test/requests/shared_file_system/quota_tests.rb +++ b/test/requests/shared_file_system/quota_tests.rb @@ -19,7 +19,7 @@ describe "success" do it "#get_quota" do - @quota.must_match_schema(@quota_format) + _(@quota).must_match_schema(@quota_format) end it "#update_quota" do @@ -28,8 +28,8 @@ 'snapshots' => @quota['snapshots'] + 2 ) - @manila.update_quota(@project_id, new_values.clone).status.must_equal 200 - @manila.get_quota(@project_id).body['quota_set'].must_equal new_values + _(@manila.update_quota(@project_id, new_values.clone).status).must_equal 200 + _(@manila.get_quota(@project_id).body['quota_set']).must_equal new_values # turn back @manila.update_quota(@project_id, @quota) end diff --git a/test/requests/storage/container_tests.rb b/test/requests/storage/container_tests.rb index 148ded79f..00d3f8e00 100644 --- a/test/requests/storage/container_tests.rb +++ b/test/requests/storage/container_tests.rb @@ -30,14 +30,14 @@ def cleanup_container describe "success" do it "#put_container('fogcontainertests')" do unless Fog.mocking? - @storage.put_container('fogcontainertests').status.must_equal 201 + _(@storage.put_container('fogcontainertests').status).must_equal 201 end end describe "using container" do before do unless Fog.mocking? - @storage.put_container(@container_name).status.must_equal 201 + _(@storage.put_container(@container_name).status).must_equal 201 end end @@ -47,34 +47,34 @@ def cleanup_container it "#get_container('fogcontainertests')" do unless Fog.mocking? - @storage.get_container('fogcontainertests').body.must_match_schema(@container_format) + _(@storage.get_container('fogcontainertests').body).must_match_schema(@container_format) end end it "#get_containers" do unless Fog.mocking? - @storage.get_containers.body.must_match_schema(@containers_format) + _(@storage.get_containers.body).must_match_schema(@containers_format) end end it "#head_container('fogcontainertests')" do unless Fog.mocking? resp = @storage.head_container('fogcontainertests') - resp.status.must_equal 204 - resp.headers['X-Container-Object-Count'].to_i.must_equal 0 + _(resp.status).must_equal 204 + _(resp.headers['X-Container-Object-Count'].to_i).must_equal 0 end end it "#head_containers" do unless Fog.mocking? resp = @storage.head_containers - resp.status.must_equal 204 - resp.headers['X-Account-Container-Count'].to_i.must_equal 1 + _(resp.status).must_equal 204 + _(resp.headers['X-Account-Container-Count'].to_i).must_equal 1 end end it "#delete_container('fogcontainertests')" do unless Fog.mocking? - @storage.delete_container('fogcontainertests').status.must_equal 204 + _(@storage.delete_container('fogcontainertests').status).must_equal 204 end end end @@ -83,25 +83,25 @@ def cleanup_container describe "failure" do it "#get_container('fognoncontainer')" do unless Fog.mocking? - proc do + _(proc do @storage.get_container('fognoncontainer') - end.must_raise Fog::OpenStack::Storage::NotFound + end).must_raise Fog::OpenStack::Storage::NotFound end end it "#head_container('fognoncontainer')" do unless Fog.mocking? - proc do + _(proc do @storage.head_container('fognoncontainer') - end.must_raise Fog::OpenStack::Storage::NotFound + end).must_raise Fog::OpenStack::Storage::NotFound end end it "#delete_container('fognoncontainer')" do unless Fog.mocking? - proc do + _(proc do @storage.delete_container('fognoncontainer') - end.must_raise Fog::OpenStack::Storage::NotFound + end).must_raise Fog::OpenStack::Storage::NotFound end end end diff --git a/test/requests/storage/large_object_tests.rb b/test/requests/storage/large_object_tests.rb index cc8ca9803..8226683be 100644 --- a/test/requests/storage/large_object_tests.rb +++ b/test/requests/storage/large_object_tests.rb @@ -85,7 +85,7 @@ it "#get_object streams all segments matching the default prefix" do unless Fog.mocking? expected = @segments[:a][:data] + @segments[:b][:data] + @segments[:c][:data] - @storage.get_object(@directory.identity, 'fog_large_object').body.must_equal expected + _(@storage.get_object(@directory.identity, 'fog_large_object').body).must_equal expected end end @@ -102,7 +102,7 @@ ] # returned in quotes "\"2577f38428e895c50de6ea78ccc7da2a"\" expected = %("#{Digest::MD5.hexdigest(etags.join)}") - @storage.head_object(@directory.identity, 'fog_large_object').headers['Etag'].must_equal expected + _(@storage.head_object(@directory.identity, 'fog_large_object').headers['Etag']).must_equal expected end end end @@ -127,7 +127,7 @@ unless Fog.mocking? expected = @segments[:a][:data] + @segments[:b][:data] resp = @storage.get_object(@directory.identity, 'fog_large_object') - resp.body.must_equal expected + _(resp.body).must_equal expected end end @@ -136,7 +136,7 @@ etags = [@segments[:a][:etag], @segments[:b][:etag]] # returned in quotes "\"0f035ed3cc38aa0ef46dda3478fad44d"\" expected = %("#{Digest::MD5.hexdigest(etags.join)}") - @storage.head_object(@directory.identity, 'fog_large_object').headers['Etag'].must_equal expected + _(@storage.head_object(@directory.identity, 'fog_large_object').headers['Etag']).must_equal expected end end end @@ -152,7 +152,7 @@ it "#get_object" do unless Fog.mocking? expected = @segments[:a][:data] + @segments[:b][:data] - @storage.get_object(@directory2.identity, 'fog_large_object').body.must_equal expected + _(@storage.get_object(@directory2.identity, 'fog_large_object').body).must_equal expected end end end @@ -186,9 +186,9 @@ content_length = @segments[:a][:size] + @segments[:c][:size] response = @storage.head_object(@directory.identity, 'fog_large_object') - response.headers['Etag'].must_equal etag - response.headers['Content-Length'].to_i.must_equal content_length - response.headers['X-Static-Large-Object'].must_equal 'True' + _(response.headers['Etag']).must_equal etag + _(response.headers['Content-Length'].to_i).must_equal content_length + _(response.headers['X-Static-Large-Object']).must_equal 'True' end end @@ -196,7 +196,7 @@ unless Fog.mocking? expected = @segments[:a][:data] + @segments[:c][:data] resp = @storage.get_object(@directory.identity, 'fog_large_object') - resp.body.must_equal expected + _(resp.body).must_equal expected end end @@ -210,7 +210,7 @@ 'Number Deleted' => 3, 'Response Body' => '' } - @storage.delete_static_large_object(@directory.identity, 'fog_large_object').body.must_equal expected + _(@storage.delete_static_large_object(@directory.identity, 'fog_large_object').body).must_equal expected end end end @@ -243,9 +243,9 @@ content_length = (@segments[:b][:size] + @segments[:d][:size]) response = @storage.head_object(@directory2.identity, 'fog_large_object') - response.headers['Etag'].must_equal etag - response.headers['Content-Length'].to_i.must_equal content_length - response.headers['X-Static-Large-Object'].must_equal 'True' + _(response.headers['Etag']).must_equal etag + _(response.headers['Content-Length'].to_i).must_equal content_length + _(response.headers['X-Static-Large-Object']).must_equal 'True' end end @@ -253,7 +253,7 @@ unless Fog.mocking? expected = @segments[:b][:data] + @segments[:d][:data] resp = @storage.get_object(@directory2.identity, 'fog_large_object') - resp.body.must_equal expected + _(resp.body).must_equal expected end end @@ -267,7 +267,7 @@ 'Response Body' => '' } resp = @storage.delete_static_large_object(@directory2.identity, 'fog_large_object') - resp.body.must_equal expected + _(resp.body).must_equal expected end end end @@ -278,9 +278,9 @@ describe "dynamic large object requests" do it "#put_dynamic_obj_manifest with missing container" do unless Fog.mocking? - proc do + _(proc do @storage.put_dynamic_obj_manifest('fognoncontainer', 'fog_large_object') - end.must_raise Fog::OpenStack::Storage::NotFound + end).must_raise Fog::OpenStack::Storage::NotFound end end end @@ -288,9 +288,9 @@ describe "static large object requests" do it "#put_static_obj_manifest with missing container" do unless Fog.mocking? - proc do + _(proc do @storage.put_static_obj_manifest('fognoncontainer', 'fog_large_object', []) - end.must_raise Fog::OpenStack::Storage::NotFound + end).must_raise Fog::OpenStack::Storage::NotFound end end @@ -303,10 +303,10 @@ }] expected = {'Errors' => [[segments[0][:path], '404 Not Found']]} - err = proc do + err = _(proc do @storage.put_static_obj_manifest(@directory.identity, 'fog_large_object', segments) - end.must_raise Excon::Errors::BadRequest - Fog::JSON.decode(err.response.body).must_equal expected + end).must_raise Excon::Errors::BadRequest + _(Fog::JSON.decode(err.response.body)).must_equal expected end end @@ -329,11 +329,11 @@ }] expected = {'Errors' => [[segments[0][:path], 'Etag Mismatch']]} - err = proc do + err = _(proc do @storage.put_static_obj_manifest(@directory.identity, 'fog_large_object', segments) - end.must_raise Excon::Errors::BadRequest + end).must_raise Excon::Errors::BadRequest - Fog::JSON.decode(err.response.body).must_equal expected + _(Fog::JSON.decode(err.response.body)).must_equal expected end end @@ -346,11 +346,11 @@ }] expected = {'Errors' => [[segments[0][:path], 'Size Mismatch']]} - err = proc do + err = _(proc do @storage.put_static_obj_manifest(@directory.identity, 'fog_large_object', segments) - end.must_raise Excon::Errors::BadRequest + end).must_raise Excon::Errors::BadRequest - Fog::JSON.decode(err.response.body).must_equal expected + _(Fog::JSON.decode(err.response.body)).must_equal expected end end @@ -383,7 +383,7 @@ 'Number Deleted' => 2, 'Response Body' => '' } - @storage.delete_static_large_object(@directory.identity, 'fog_large_object').body.must_equal expected + _(@storage.delete_static_large_object(@directory.identity, 'fog_large_object').body).must_equal expected end end end @@ -400,7 +400,7 @@ } resp = @storage.delete_static_large_object('fognoncontainer', 'fog_large_object') - resp.body.must_equal expected + _(resp.body).must_equal expected end end @@ -414,7 +414,7 @@ 'Response Body' => '' } - @storage.delete_static_large_object(@directory.identity, 'fog_non_object').body.must_equal expected + _(@storage.delete_static_large_object(@directory.identity, 'fog_non_object').body).must_equal expected end end end diff --git a/test/requests/storage/object_tests.rb b/test/requests/storage/object_tests.rb index c7cdad329..a2444481f 100644 --- a/test/requests/storage/object_tests.rb +++ b/test/requests/storage/object_tests.rb @@ -3,10 +3,10 @@ def test_temp_url(url_s, time, desired_scheme) object_url = URI.parse(url_s) query_params = URI.decode_www_form(object_url.query) - object_url.scheme.must_equal desired_scheme - object_url.path.must_match %r{/#{@directory.identity}/fog_object} - query_params.any? { |p| p[0] == 'temp_url_sig' }.must_equal true - query_params.any? { |p| p == ['temp_url_expires', time.to_i.to_s] }.must_equal true + _(object_url.scheme).must_equal desired_scheme + _(object_url.path).must_match %r{/#{@directory.identity}/fog_object} + _(query_params.any? { |p| p[0] == 'temp_url_sig' }).must_equal true + _(query_params.any? { |p| p == ['temp_url_expires', time.to_i.to_s] }).must_equal true end describe "Fog::OpenStack::Storage | object requests" do @@ -32,7 +32,7 @@ def override_path(path) describe "success" do it "#put_object('fogobjecttests', 'fog_object')" do resp = Fog::OpenStack::Storage.new.put_object('fogobjecttests', 'fog_object', lorem_file) - resp.headers['ETag'].must_equal '80d7930fe13ff4e45156b6581656a247' + _(resp.headers['ETag']).must_equal '80d7930fe13ff4e45156b6581656a247' end describe "with_object" do @@ -40,13 +40,13 @@ def override_path(path) file = lorem_file resp = Fog::OpenStack::Storage.new.put_object('fogobjecttests', 'fog_object', file) file.close - resp.headers['ETag'].must_equal '80d7930fe13ff4e45156b6581656a247' + _(resp.headers['ETag']).must_equal '80d7930fe13ff4e45156b6581656a247' end it "#get_object('fogobjectests', 'fog_object')" do unless Fog.mocking? resp = Fog::OpenStack::Storage.new.get_object('fogobjecttests', 'fog_object') - resp.body.must_equal lorem_file.read + _(resp.body).must_equal lorem_file.read end end @@ -56,28 +56,28 @@ def override_path(path) Fog::OpenStack::Storage.new.get_object('fogobjecttests', 'fog_object') do |chunk, _remaining_bytes, _total_bytes| data << chunk end - data.must_equal lorem_file.read + _(data).must_equal lorem_file.read end end it "#public_url('fogobjectests', 'fog_object')" do unless Fog.mocking? url = Fog::OpenStack::Storage.new.directories.first.files.first.public_url - url.end_with?('/fogobjecttests/fog_object').must_equal true + _(url.end_with?('/fogobjecttests/fog_object')).must_equal true end end it "#public_url('fogobjectests')" do unless Fog.mocking? url = Fog::OpenStack::Storage.new.directories.first.public_url - url.end_with?('/fogobjecttests').must_equal true + _(url.end_with?('/fogobjecttests')).must_equal true end end it "#head_object('fogobjectests', 'fog_object')" do unless Fog.mocking? resp = Fog::OpenStack::Storage.new.head_object('fogobjecttests', 'fog_object') - resp.headers['ETag'].must_equal '80d7930fe13ff4e45156b6581656a247' + _(resp.headers['ETag']).must_equal '80d7930fe13ff4e45156b6581656a247' end end @@ -89,15 +89,15 @@ def override_path(path) 'X-Object-Meta-test-header' => 'fog-test-value' ) resp = Fog::OpenStack::Storage.new.head_object('fogobjecttests', 'fog_object') - resp.headers.must_include 'X-Object-Meta-Test-Header' - resp.headers['X-Object-Meta-Test-Header'].must_equal 'fog-test-value' + _(resp.headers).must_include 'X-Object-Meta-Test-Header' + _(resp.headers['X-Object-Meta-Test-Header']).must_equal 'fog-test-value' end end it "#delete_object('fogobjecttests', 'fog_object')" do unless Fog.mocking? resp = Fog::OpenStack::Storage.new.delete_object('fogobjecttests', 'fog_object') - resp.status.must_equal 204 + _(resp.status).must_equal 204 end end @@ -138,7 +138,7 @@ def override_path(path) ensure file.close end - resp.headers['ETag'].must_equal '80d7930fe13ff4e45156b6581656a247' + _(resp.headers['ETag']).must_equal '80d7930fe13ff4e45156b6581656a247' end describe "with_object" do @@ -153,14 +153,14 @@ def override_path(path) it "#get_object" do unless Fog.mocking? resp = Fog::OpenStack::Storage.new.get_object('fogobjecttests', 'fog_block_object') - resp.body.must_equal lorem_file.read + _(resp.body).must_equal lorem_file.read end end it "#delete_object" do unless Fog.mocking? resp = Fog::OpenStack::Storage.new.delete_object('fogobjecttests', 'fog_block_object') - resp.status.must_equal 204 + _(resp.status).must_equal 204 end end end @@ -199,7 +199,7 @@ def override_path(path) resp = Fog::OpenStack::Storage.new.delete_multiple_objects( 'fogobjecttests', %w[fog_object fog_object2] ) - resp.body.must_equal @expected + _(resp.body).must_equal @expected end end @@ -209,7 +209,7 @@ def override_path(path) nil, ['fogobjecttests2/fog_object', 'fogobjecttests2'] ) - resp.body.must_equal @expected + _(resp.body).must_equal @expected end end end @@ -218,57 +218,57 @@ def override_path(path) describe "failure" do it "#get_object('fogobjecttests', 'fog_non_object')" do unless Fog.mocking? - proc do + _(proc do Fog::OpenStack::Storage.new.get_object('fogobjecttests', 'fog_non_object') - end.must_raise(Fog::OpenStack::Storage::NotFound) + end).must_raise(Fog::OpenStack::Storage::NotFound) end end it "#get_object('fognoncontainer', 'fog_non_object')" do unless Fog.mocking? - proc do + _(proc do Fog::OpenStack::Storage.new.get_object('fognoncontainer', 'fog_non_object') - end.must_raise(Fog::OpenStack::Storage::NotFound) + end).must_raise(Fog::OpenStack::Storage::NotFound) end end it "#head_object('fogobjecttests', 'fog_non_object')" do unless Fog.mocking? - proc do + _(proc do Fog::OpenStack::Storage.new.head_object('fogobjecttests', 'fog_non_object') - end.must_raise(Fog::OpenStack::Storage::NotFound) + end).must_raise(Fog::OpenStack::Storage::NotFound) end end it "#head_object('fognoncontainer', 'fog_non_object')" do unless Fog.mocking? - proc do + _(proc do Fog::OpenStack::Storage.new.head_object('fognoncontainer', 'fog_non_object') - end.must_raise(Fog::OpenStack::Storage::NotFound) + end).must_raise(Fog::OpenStack::Storage::NotFound) end end it "#post_object('fognoncontainer', 'fog_non_object')" do unless Fog.mocking? - proc do + _(proc do Fog::OpenStack::Storage.new.post_object('fognoncontainer', 'fog_non_object') - end.must_raise(Fog::OpenStack::Storage::NotFound) + end).must_raise(Fog::OpenStack::Storage::NotFound) end end it "#delete_object('fogobjecttests', 'fog_non_object')" do unless Fog.mocking? - proc do + _(proc do Fog::OpenStack::Storage.new.delete_object('fogobjecttests', 'fog_non_object') - end.must_raise(Fog::OpenStack::Storage::NotFound) + end).must_raise(Fog::OpenStack::Storage::NotFound) end end it "#delete_object('fognoncontainer', 'fog_non_object')" do unless Fog.mocking? - proc do + _(proc do Fog::OpenStack::Storage.new.delete_object('fognoncontainer', 'fog_non_object') - end.must_raise(Fog::OpenStack::Storage::NotFound) + end).must_raise(Fog::OpenStack::Storage::NotFound) end end @@ -290,7 +290,7 @@ def override_path(path) resp = Fog::OpenStack::Storage.new.delete_multiple_objects( 'fogobjecttests', %w[fog_non_object fog_non_object2] ) - resp.body.must_equal @expected + _(resp.body).must_equal @expected end end @@ -299,7 +299,7 @@ def override_path(path) resp = Fog::OpenStack::Storage.new.delete_multiple_objects( 'fognoncontainer', %w[fog_non_object fog_non_object2] ) - resp.body.must_equal @expected + _(resp.body).must_equal @expected end end @@ -308,7 +308,7 @@ def override_path(path) file = lorem_file resp = Fog::OpenStack::Storage.new.put_object('fogobjecttests', 'fog_object', file) file.close - resp.headers['ETag'].must_equal '80d7930fe13ff4e45156b6581656a247' + _(resp.headers['ETag']).must_equal '80d7930fe13ff4e45156b6581656a247' expected = { "Number Not Found" => 0, @@ -322,7 +322,7 @@ def override_path(path) nil, %w[fogobjecttests] ) - resp.body.must_equal expected + _(resp.body).must_equal expected end end end diff --git a/test/requests/volume/availability_zone_tests.rb b/test/requests/volume/availability_zone_tests.rb index 43e1fc4b3..f3c84b2ed 100644 --- a/test/requests/volume/availability_zone_tests.rb +++ b/test/requests/volume/availability_zone_tests.rb @@ -10,7 +10,7 @@ describe "success" do it "#list_zones" do - Fog::OpenStack::Volume.new.list_zones.body. + _(Fog::OpenStack::Volume.new.list_zones.body). must_match_schema('availabilityZoneInfo' => [@flavor_format]) end end diff --git a/test/requests/volume/backup_tests.rb b/test/requests/volume/backup_tests.rb index e8f335c23..3f3e1a2ca 100644 --- a/test/requests/volume/backup_tests.rb +++ b/test/requests/volume/backup_tests.rb @@ -18,16 +18,16 @@ describe "success" do it "create_backup" do - @backup.must_match_schema(@backup_format) + _(@backup).must_match_schema(@backup_format) end it "#get_backup_details" do - @volume.get_backup_details(@backup['id']).body['backup']. + _(@volume.get_backup_details(@backup['id']).body['backup']). must_match_schema(@backup_format) end it "#list_backups_detailed" do - @volume.list_backups_detailed.body['backups']. + _(@volume.list_backups_detailed.body['backups']). must_match_schema([@backup_format]) end diff --git a/test/requests/volume/quota_tests.rb b/test/requests/volume/quota_tests.rb index ca7648478..f4c5ed8d5 100644 --- a/test/requests/volume/quota_tests.rb +++ b/test/requests/volume/quota_tests.rb @@ -16,12 +16,12 @@ describe "success" do it "#get_quota_defaults" do - @volume.get_quota_defaults(@tenant_id).body. + _(@volume.get_quota_defaults(@tenant_id).body). must_match_schema('quota_set' => @quota_set_format) end it "#get_quota" do - @quota.must_match_schema(@quota_set_format) + _(@quota).must_match_schema(@quota_set_format) end it "updates quota" do @@ -31,7 +31,7 @@ ) @volume.update_quota(@tenant_id, @new_values.clone) - @volume.get_quota(@tenant_id).body['quota_set'].must_match_schema @new_values + _(@volume.get_quota(@tenant_id).body['quota_set']).must_match_schema @new_values end end end diff --git a/test/requests/volume/volume_type_tests.rb b/test/requests/volume/volume_type_tests.rb index 935deae68..c1eff5815 100644 --- a/test/requests/volume/volume_type_tests.rb +++ b/test/requests/volume/volume_type_tests.rb @@ -15,23 +15,23 @@ describe "success" do it "#create_volume_type" do - @volume_type.must_match_schema(@volume_type_format) + _(@volume_type).must_match_schema(@volume_type_format) end it "#update_volume_type" do - @volume.update_volume_type( + _(@volume.update_volume_type( @volume_type['id'], :name => 'test_volume_type_1' - ).body['volume_type'].must_match_schema(@volume_type_format) + ).body['volume_type']).must_match_schema(@volume_type_format) end it "#get_volume_type" do - @volume.get_volume_type_details(@volume_type['id']).body['volume_type']. + _(@volume.get_volume_type_details(@volume_type['id']).body['volume_type']). must_match_schema(@volume_type_format) end it "#list_volume_type" do - @volume.list_volume_types.body['volume_types']. + _(@volume.list_volume_types.body['volume_types']). must_match_schema([@volume_type_format]) end diff --git a/test/requests/workflow/workflow_tests.rb b/test/requests/workflow/workflow_tests.rb index 24dc08ac2..5f91f81b6 100644 --- a/test/requests/workflow/workflow_tests.rb +++ b/test/requests/workflow/workflow_tests.rb @@ -58,198 +58,198 @@ describe "success" do it "#create_execution" do - @workflow.create_execution(@workflow_name, @input).status.must_equal 201 + _(@workflow.create_execution(@workflow_name, @input).status).must_equal 201 end it "#get_execution" do response = @workflow.get_execution(@execution_id) - response.status.must_equal 200 - response.body.must_match_schema(@get_execution_response) + _(response.status).must_equal 200 + _(response.body).must_match_schema(@get_execution_response) end it "#list_executions" do - @workflow.list_executions.status.must_equal 200 + _(@workflow.list_executions.status).must_equal 200 end it "#update_execution" do response = @workflow.update_execution(@execution_id, "description", "changed description") - response.status.must_equal 200 + _(response.status).must_equal 200 end it "#delete_execution" do response = @workflow.delete_execution(@execution_id) - response.status.must_equal 204 + _(response.status).must_equal 204 end it "#create_action_execution" do action_name = "tripleo.list_roles" - @workflow.create_action_execution(action_name, @input).status.must_equal 201 + _(@workflow.create_action_execution(action_name, @input).status).must_equal 201 end it "#get_action_execution" do response = @workflow.get_action_execution(@execution_id) - response.status.must_equal 200 - response.body.must_match_schema(@get_execution_response) + _(response.status).must_equal 200 + _(response.body).must_match_schema(@get_execution_response) end it "#list_action_executions" do - @workflow.list_action_executions.status.must_equal 200 + _(@workflow.list_action_executions.status).must_equal 200 end it "#update_action_execution" do response = @workflow.update_action_execution(@execution_id, "output", "changed output") - response.status.must_equal 200 + _(response.status).must_equal 200 end it "#delete_action_execution" do response = @workflow.delete_action_execution(@execution_id) - response.status.must_equal 204 + _(response.status).must_equal 204 end it "#create_workbook" do - @workflow.create_workbook(@workbook_sample).status.must_equal 201 + _(@workflow.create_workbook(@workbook_sample).status).must_equal 201 end it "#get_workbook" do response = @workflow.get_workbook(@workbook_sample[:name]) - response.status.must_equal 200 - response.body.must_match_schema(@workbook_sample) + _(response.status).must_equal 200 + _(response.body).must_match_schema(@workbook_sample) end it "#list_workbooks" do - @workflow.list_workbooks.status.must_equal 200 + _(@workflow.list_workbooks.status).must_equal 200 end it "#update_workbook" do response = @workflow.update_workbook(@workbook_sample) - response.status.must_equal 200 + _(response.status).must_equal 200 end it "#validate_workbook" do response = @workflow.validate_workbook(@workbook_sample) - response.status.must_equal 200 + _(response.status).must_equal 200 end it "#delete_workbook" do response = @workflow.delete_workbook(@workbook_sample[:name]) - response.status.must_equal 204 + _(response.status).must_equal 204 end it "#create_workflow" do - @workflow.create_workflow(@workflow_sample).status.must_equal 201 + _(@workflow.create_workflow(@workflow_sample).status).must_equal 201 end it "#get_workflow" do response = @workflow.get_workflow(@workflow_sample[:name]) - response.status.must_equal 200 - response.body.must_match_schema(@workflow_sample) + _(response.status).must_equal 200 + _(response.body).must_match_schema(@workflow_sample) end it "#list_workflows" do - @workflow.list_workflows.status.must_equal 200 + _(@workflow.list_workflows.status).must_equal 200 end it "#update_workflow" do response = @workflow.update_workflow(@workflow_sample) - response.status.must_equal 200 + _(response.status).must_equal 200 end it "#validate_workflow" do response = @workflow.validate_workflow(@workflow_sample) - response.status.must_equal 200 + _(response.status).must_equal 200 end it "#delete_workflow" do response = @workflow.delete_workflow(@workflow_sample[:name]) - response.status.must_equal 204 + _(response.status).must_equal 204 end it "#create_action" do - @workflow.create_action(@action_sample).status.must_equal 201 + _(@workflow.create_action(@action_sample).status).must_equal 201 end it "#get_action" do response = @workflow.get_action("action1") - response.status.must_equal 200 - response.body.must_match_schema(@action_sample) + _(response.status).must_equal 200 + _(response.body).must_match_schema(@action_sample) end it "#list_actions" do - @workflow.list_actions.status.must_equal 200 + _(@workflow.list_actions.status).must_equal 200 end it "#update_action" do response = @workflow.update_action(@action_sample) - response.status.must_equal 200 + _(response.status).must_equal 200 end it "#validate_action" do response = @workflow.validate_action(@action_sample) - response.status.must_equal 200 + _(response.status).must_equal 200 end it "#delete_action" do response = @workflow.delete_action("action1") - response.status.must_equal 204 + _(response.status).must_equal 204 end it "#get_task" do response = @workflow.get_task("1") - response.status.must_equal 200 - response.body.must_match_schema(@task_sample) + _(response.status).must_equal 200 + _(response.body).must_match_schema(@task_sample) end it "#list_tasks" do response = @workflow.validate_action("1") - response.status.must_equal 200 + _(response.status).must_equal 200 end it "#rerun_task" do response = @workflow.delete_action("1") - response.status.must_equal 204 + _(response.status).must_equal 204 end it "#create_cron_trigger" do - @workflow.create_cron_trigger("cron1", 1, "input").status.must_equal 201 + _(@workflow.create_cron_trigger("cron1", 1, "input").status).must_equal 201 end it "#get_cron_trigger" do response = @workflow.get_cron_trigger("cron1") - response.status.must_equal 200 - response.body.must_match_schema(@cron_trigger_sample) + _(response.status).must_equal 200 + _(response.body).must_match_schema(@cron_trigger_sample) end it "#list_cron_triggers" do - @workflow.list_cron_triggers.status.must_equal 200 + _(@workflow.list_cron_triggers.status).must_equal 200 end it "#delete_cron_trigger" do response = @workflow.delete_cron_trigger("cron1") - response.status.must_equal 204 + _(response.status).must_equal 204 end it "#create_environment" do - @workflow.create_environment(@environment_sample).status.must_equal 201 + _(@workflow.create_environment(@environment_sample).status).must_equal 201 end it "#get_environment" do response = @workflow.get_environment("environment1") - response.status.must_equal 200 - response.body.must_match_schema(@environment_sample) + _(response.status).must_equal 200 + _(response.body).must_match_schema(@environment_sample) end it "#list_environments" do - @workflow.list_environments.status.must_equal 200 + _(@workflow.list_environments.status).must_equal 200 end it "#update_environment" do response = @workflow.update_environment(@environment_sample) - response.status.must_equal 200 + _(response.status).must_equal 200 end it "#delete_environment" do response = @workflow.delete_environment("environment1") - response.status.must_equal 204 + _(response.status).must_equal 204 end end end diff --git a/test/schema_validator_tests.rb b/test/schema_validator_tests.rb index a4fabd939..21baea25d 100644 --- a/test/schema_validator_tests.rb +++ b/test/schema_validator_tests.rb @@ -6,95 +6,95 @@ describe "#validate" do it "returns true when value matches schema expectation" do - validator.validate({"key" => "Value"}, "key" => String).must_equal true + _(validator.validate({"key" => "Value"}, "key" => String)).must_equal true end it "returns true when values within an array all match schema expectation" do - validator.validate({"key" => [1, 2]}, "key" => [Integer]).must_equal true + _(validator.validate({"key" => [1, 2]}, "key" => [Integer])).must_equal true end it "returns true when nested values match schema expectation" do - validator.validate({"key" => {:nested_key => "Value"}}, "key" => {:nested_key => String}).must_equal true + _(validator.validate({"key" => {:nested_key => "Value"}}, "key" => {:nested_key => String})).must_equal true end it "returns true when collection of values all match schema expectation" do - validator.validate([{"key" => "Value"}, {"key" => "Value"}], [{"key" => String}]).must_equal true + _(validator.validate([{"key" => "Value"}, {"key" => "Value"}], [{"key" => String}])).must_equal true end it "returns true when collection is empty although schema covers optional members" do - validator.validate([], [{"key" => String}]).must_equal true + _(validator.validate([], [{"key" => String}])).must_equal true end it "returns true when additional keys are passed and not strict" do - validator.validate({"key" => "Value", :extra => "Bonus"}, {"key" => String}, :allow_extra_keys => true).must_equal true + _(validator.validate({"key" => "Value", :extra => "Bonus"}, {"key" => String}, :allow_extra_keys => true)).must_equal true end it "returns true when value is nil and schema expects NilClass" do - validator.validate({"key" => nil}, {"key" => NilClass}).must_equal true + _(validator.validate({"key" => nil}, {"key" => NilClass})).must_equal true end it "returns true when value and schema match as hashes" do - validator.validate({}, {}).must_equal true + _(validator.validate({}, {})).must_equal true end it "returns true when value and schema match as arrays" do - validator.validate([], []).must_equal true + _(validator.validate([], [])).must_equal true end it "returns true when value is a Time" do - validator.validate({"time" => Time.now}, "time" => Time).must_equal true + _(validator.validate({"time" => Time.now}, "time" => Time)).must_equal true end it "returns true when key is missing but value should be NilClass (#1477)" do - validator.validate({}, {"key" => NilClass}, :allow_optional_rules => true).must_equal true + _(validator.validate({}, {"key" => NilClass}, :allow_optional_rules => true)).must_equal true end it "returns true when key is missing but value is nullable (#1477)" do - validator.validate({}, {"key" => Fog::Nullable::String}, :allow_optional_rules => true).must_equal true + _(validator.validate({}, {"key" => Fog::Nullable::String}, :allow_optional_rules => true)).must_equal true end it "returns false when value does not match schema expectation" do - validator.validate({"key" => nil}, "key" => String).must_equal false + _(validator.validate({"key" => nil}, "key" => String)).must_equal false end it "returns false when key formats do not match" do - validator.validate({"key" => "Value"}, :key => String).must_equal false + _(validator.validate({"key" => "Value"}, :key => String)).must_equal false end it "returns false when additional keys are passed and strict" do - validator.validate({"key" => "Missing"}, {}).must_equal false + _(validator.validate({"key" => "Missing"}, {})).must_equal false end it "returns false when some keys do not appear" do - validator.validate({}, "key" => String).must_equal false + _(validator.validate({}, "key" => String)).must_equal false end it "returns false when collection contains a member that does not match schema" do - validator.validate([{"key" => "Value"}, {"key" => 5}], [{"key" => String}]).must_equal false + _(validator.validate([{"key" => "Value"}, {"key" => 5}], [{"key" => String}])).must_equal false end it "returns false when collection has multiple schema patterns" do - validator.validate([{"key" => "Value"}], [{"key" => Integer}, {"key" => String}]).must_equal false + _(validator.validate([{"key" => "Value"}], [{"key" => Integer}, {"key" => String}])).must_equal false end it "returns false when hash and array are compared" do - validator.validate({}, []).must_equal false + _(validator.validate({}, [])).must_equal false end it "returns false when array and hash are compared" do - validator.validate([], {}).must_equal false + _(validator.validate([], {})).must_equal false end it "returns false when a hash is expected but another data type is found" do - validator.validate({"key" => {:nested_key => []}}, "key" => {:nested_key => {}}).must_equal false + _(validator.validate({"key" => {:nested_key => []}}, "key" => {:nested_key => {}})).must_equal false end it "returns false when key is missing but value should be NilClass (#1477)" do - validator.validate({}, {"key" => NilClass}, :allow_optional_rules => false).must_equal false + _(validator.validate({}, {"key" => NilClass}, :allow_optional_rules => false)).must_equal false end it "returns false when key is missing but value is nullable (#1477)" do - validator.validate({}, {"key" => Fog::Nullable::String}, :allow_optional_rules => false).must_equal false + _(validator.validate({}, {"key" => Fog::Nullable::String}, :allow_optional_rules => false)).must_equal false end end end diff --git a/test/version_tests.rb b/test/version_tests.rb index cb5d1cab8..84e9c0ed8 100644 --- a/test/version_tests.rb +++ b/test/version_tests.rb @@ -59,13 +59,13 @@ {:status => 300, :body => Fog::JSON.encode(@body)} ) - proc do + _(proc do Fog::OpenStack.get_supported_version( /v3(\.(0|1))*/, URI('http://example/'), "authtoken" ) - end.must_raise Fog::OpenStack::Errors::ServiceUnavailable + end).must_raise Fog::OpenStack::Errors::ServiceUnavailable end after do diff --git a/unit/auth/catalog_test.rb b/unit/auth/catalog_test.rb index 5766f0bd2..777c56692 100644 --- a/unit/auth/catalog_test.rb +++ b/unit/auth/catalog_test.rb @@ -123,45 +123,45 @@ describe '#get_endpoint_url' do it 'with matching name, interface and region' do catalog = Fog::OpenStack::Auth::Catalog::V3.new(payload) - catalog.get_endpoint_url('identity', 'admin', 'regionTwo').must_equal 'http://localhost2:35357' + _(catalog.get_endpoint_url('identity', 'admin', 'regionTwo')).must_equal 'http://localhost2:35357' end it 'with matching name and interface using avail region' do catalog = Fog::OpenStack::Auth::Catalog::V3.new(payload) - catalog.get_endpoint_url('network', %w[dummy admin]).must_equal 'http://localhost:9696' + _(catalog.get_endpoint_url('network', %w[dummy admin])).must_equal 'http://localhost:9696' end it 'with matching name and interface list' do catalog = Fog::OpenStack::Auth::Catalog::V3.new(payload) - catalog.get_endpoint_url('network', %w[dummy admin]).must_equal 'http://localhost:9696' + _(catalog.get_endpoint_url('network', %w[dummy admin])).must_equal 'http://localhost:9696' end it 'with matching name and interface and several regions available' do catalog = Fog::OpenStack::Auth::Catalog::V3.new(payload) - proc do + _(proc do catalog.get_endpoint_url('identity', 'admin') - end.must_raise Fog::OpenStack::Auth::Catalog::EndpointError + end).must_raise Fog::OpenStack::Auth::Catalog::EndpointError end it 'with unmatched name for service type' do catalog = Fog::OpenStack::Auth::Catalog::V3.new(payload) - proc do + _(proc do catalog.get_endpoint_url('service', 'public') - end.must_raise Fog::OpenStack::Auth::Catalog::ServiceTypeError + end).must_raise Fog::OpenStack::Auth::Catalog::ServiceTypeError end it 'with unmatched region' do catalog = Fog::OpenStack::Auth::Catalog::V3.new(payload) - proc do + _(proc do catalog.get_endpoint_url('identity', 'admin', 'regionOther') - end.must_raise Fog::OpenStack::Auth::Catalog::EndpointError + end).must_raise Fog::OpenStack::Auth::Catalog::EndpointError end it 'with unmatched interface' do catalog = Fog::OpenStack::Auth::Catalog::V3.new(payload) - proc do + _(proc do catalog.get_endpoint_url('identity', 'private') - end.must_raise Fog::OpenStack::Auth::Catalog::EndpointError + end).must_raise Fog::OpenStack::Auth::Catalog::EndpointError end end end @@ -213,40 +213,40 @@ describe '#get_endpoint_url' do it 'match name, interface and region' do catalog = Fog::OpenStack::Auth::Catalog::V2.new(payload) - catalog.get_endpoint_url('identity', 'internal', 'regionTwo').must_equal 'http://localhost:9999/v2.0' + _(catalog.get_endpoint_url('identity', 'internal', 'regionTwo')).must_equal 'http://localhost:9999/v2.0' end it 'match name, interface and unique region available' do catalog = Fog::OpenStack::Auth::Catalog::V2.new(payload) - catalog.get_endpoint_url('compute', 'internal').must_equal 'http://localhost:7777/v1.0' + _(catalog.get_endpoint_url('compute', 'internal')).must_equal 'http://localhost:7777/v1.0' end it 'fails when multiple region match' do catalog = Fog::OpenStack::Auth::Catalog::V2.new(payload) - proc do + _(proc do catalog.get_endpoint_url('identity', 'admin') - end.must_raise Fog::OpenStack::Auth::Catalog::EndpointError + end).must_raise Fog::OpenStack::Auth::Catalog::EndpointError end it 'with unmatched arguments' do catalog = Fog::OpenStack::Auth::Catalog::V2.new(payload) - proc do + _(proc do catalog.get_endpoint_url('test', 'unknown', 'regionOther') - end.must_raise Fog::OpenStack::Auth::Catalog::ServiceTypeError + end).must_raise Fog::OpenStack::Auth::Catalog::ServiceTypeError end it 'with unmatched region' do catalog = Fog::OpenStack::Auth::Catalog::V2.new(payload) - proc do + _(proc do catalog.get_endpoint_url('identity', 'admin', 'regionOther') - end.must_raise Fog::OpenStack::Auth::Catalog::EndpointError + end).must_raise Fog::OpenStack::Auth::Catalog::EndpointError end it 'with unmatched interface' do catalog = Fog::OpenStack::Auth::Catalog::V2.new(payload) - proc do + _(proc do catalog.get_endpoint_url('identity', 'private', 'regionTwo') - end.must_raise Fog::OpenStack::Auth::Catalog::EndpointError + end).must_raise Fog::OpenStack::Auth::Catalog::EndpointError end end end diff --git a/unit/auth/name_test.rb b/unit/auth/name_test.rb index 15629d9b9..c4f505dc7 100644 --- a/unit/auth/name_test.rb +++ b/unit/auth/name_test.rb @@ -5,33 +5,33 @@ describe 'creates' do it 'when id and name are provided' do name = Fog::OpenStack::Auth::Name.new('default', 'Default') - name.id.must_equal 'default' - name.name.must_equal 'Default' + _(name.id).must_equal 'default' + _(name.name).must_equal 'Default' end it 'when id is null' do name = Fog::OpenStack::Auth::Name.new(nil, 'Default') - name.id.must_be_nil - name.name.must_equal 'Default' + _(name.id).must_be_nil + _(name.name).must_equal 'Default' end it 'when name is null' do name = Fog::OpenStack::Auth::Name.new('default', nil) - name.id.must_equal 'default' - name.name.must_be_nil + _(name.id).must_equal 'default' + _(name.name).must_be_nil end it 'when both id and name is null' do name = Fog::OpenStack::Auth::Name.new(nil, nil) - name.name.must_be_nil + _(name.name).must_be_nil end end describe '#to_h' do it 'returns the hash of provided attribute' do name = Fog::OpenStack::Auth::Name.new('default', 'Default') - name.to_h(:id).must_equal(:id => 'default') - name.to_h(:name).must_equal(:name => 'Default') + _(name.to_h(:id)).must_equal(:id => 'default') + _(name.to_h(:name)).must_equal(:name => 'Default') end end end @@ -41,7 +41,7 @@ it 'set/get password' do user = Fog::OpenStack::Auth::User.new('user_id', 'User') user.password = 'secret' - user.identity.must_equal(:user => {:id => 'user_id', :password => 'secret'}) + _(user.identity).must_equal(:user => {:id => 'user_id', :password => 'secret'}) end end @@ -50,37 +50,37 @@ it "with user id and user name" do user = Fog::OpenStack::Auth::User.new('user_id', 'User') user.password = 'secret' - user.identity.must_equal(:user => {:id => 'user_id', :password => 'secret'}) + _(user.identity).must_equal(:user => {:id => 'user_id', :password => 'secret'}) end it 'with user name and user domain name' do user = Fog::OpenStack::Auth::User.new(nil, 'User') user.password = 'secret' user.domain = Fog::OpenStack::Auth::Name.new('default', nil) - user.identity.must_equal(:user => {:name => 'User', :domain => {:id => 'default'}, :password => 'secret'}) + _(user.identity).must_equal(:user => {:name => 'User', :domain => {:id => 'default'}, :password => 'secret'}) end it 'with user name and domain name' do user = Fog::OpenStack::Auth::User.new(nil, 'User') user.password = 'secret' user.domain = Fog::OpenStack::Auth::Name.new(nil, 'Default') - user.identity.must_equal(:user => {:name => 'User', :domain => {:name => 'Default'}, :password => 'secret'}) + _(user.identity).must_equal(:user => {:name => 'User', :domain => {:name => 'Default'}, :password => 'secret'}) end end describe 'raises an error' do it 'raises an error when password is missing' do - proc do + _(proc do user = Fog::OpenStack::Auth::User.new('user_id', 'User') user.identity - end.must_raise Fog::OpenStack::Auth::CredentialsError + end).must_raise Fog::OpenStack::Auth::CredentialsError end it 'with only user name and no domain' do - proc do + _(proc do user = Fog::OpenStack::Auth::User.new(nil, 'User') user.identity - end.must_raise Fog::OpenStack::Auth::CredentialsError + end).must_raise Fog::OpenStack::Auth::CredentialsError end end end @@ -90,26 +90,26 @@ describe '#identity' do it "when id is provided it doesn't require domain" do project = Fog::OpenStack::Auth::ProjectScope.new('project_id', 'Project') - project.identity.must_equal(:project => {:id => 'project_id'}) + _(project.identity).must_equal(:project => {:id => 'project_id'}) end it 'when id is nul and name is provided it uses domain id' do project = Fog::OpenStack::Auth::ProjectScope.new(nil, 'Project') project.domain = Fog::OpenStack::Auth::Name.new('default', nil) - project.identity.must_equal(:project => {:name => 'Project', :domain => {:id => 'default'}}) + _(project.identity).must_equal(:project => {:name => 'Project', :domain => {:id => 'default'}}) end it 'when id is nul and name is provided it uses domain name' do project = Fog::OpenStack::Auth::ProjectScope.new(nil, 'Project') project.domain = Fog::OpenStack::Auth::Name.new(nil, 'Default') - project.identity.must_equal(:project => {:name => 'Project', :domain => {:name => 'Default'}}) + _(project.identity).must_equal(:project => {:name => 'Project', :domain => {:name => 'Default'}}) end it 'raises an error with no project id and no domain are provided' do - proc do + _(proc do project = Fog::OpenStack::Auth::ProjectScope.new(nil, 'Project') project.identity - end.must_raise Fog::OpenStack::Auth::CredentialsError + end).must_raise Fog::OpenStack::Auth::CredentialsError end end end diff --git a/unit/auth/token_test.rb b/unit/auth/token_test.rb index 4106632ab..275e7fd16 100644 --- a/unit/auth/token_test.rb +++ b/unit/auth/token_test.rb @@ -12,9 +12,9 @@ :headers => {'x-subject-token'=>'token_data'} ) - proc do + _(proc do Fog::OpenStack::Auth::Token.build({}, {}) - end.must_raise Fog::OpenStack::Auth::Token::URLError + end).must_raise Fog::OpenStack::Auth::Token::URLError end describe 'using the password method' do @@ -37,7 +37,7 @@ ) token = Fog::OpenStack::Auth::Token.build(auth, {}) - token.get.must_equal 'token_data_v3' + _(token.get).must_equal 'token_data_v3' end it 'authenticates using a project name and a project domain id' do @@ -60,7 +60,7 @@ ) token = Fog::OpenStack::Auth::Token.build(auth, {}) - token.get.must_equal 'token_data' + _(token.get).must_equal 'token_data' end it 'authenticates using a project name and a project domain name' do @@ -84,7 +84,7 @@ ) token = Fog::OpenStack::Auth::Token.build(auth, {}) - token.get.must_equal 'token_data' + _(token.get).must_equal 'token_data' end end @@ -107,7 +107,7 @@ ) token = Fog::OpenStack::Auth::Token.build(auth, {}) - token.get.must_equal 'token_data' + _(token.get).must_equal 'token_data' end it 'authenticates using a domain name' do @@ -128,7 +128,7 @@ ) token = Fog::OpenStack::Auth::Token.build(auth, {}) - token.get.must_equal 'token_data' + _(token.get).must_equal 'token_data' end end @@ -150,7 +150,7 @@ ) token = Fog::OpenStack::Auth::Token.build(auth, {}) - token.get.must_equal 'token_data' + _(token.get).must_equal 'token_data' end end end @@ -172,7 +172,7 @@ ) token = Fog::OpenStack::Auth::Token.build(auth, {}) - token.get.must_equal 'token_data' + _(token.get).must_equal 'token_data' end end @@ -194,7 +194,7 @@ ) token = Fog::OpenStack::Auth::Token.build(auth, {}) - token.get.must_equal 'token_data' + _(token.get).must_equal 'token_data' end it 'authenticates using a project name and a project domain id' do @@ -215,7 +215,7 @@ ) token = Fog::OpenStack::Auth::Token.build(auth, {}) - token.get.must_equal 'token_data' + _(token.get).must_equal 'token_data' end end @@ -237,7 +237,7 @@ ) token = Fog::OpenStack::Auth::Token.build(auth, {}) - token.get.must_equal 'token_data' + _(token.get).must_equal 'token_data' end it 'authenticates using a domain name' do @@ -257,7 +257,7 @@ ) token = Fog::OpenStack::Auth::Token.build(auth, {}) - token.get.must_equal 'token_data' + _(token.get).must_equal 'token_data' end end end @@ -285,7 +285,7 @@ token = Fog::OpenStack::Auth::Token.build(authv3_creds, {}) token.stub :expired?, false do - token.get.must_equal 'token_data' + _(token.get).must_equal 'token_data' end end @@ -299,7 +299,7 @@ token = Fog::OpenStack::Auth::Token.build(authv3_creds, {}) token.stub :expired?, true do - token.get.must_equal 'token_data' + _(token.get).must_equal 'token_data' end end end @@ -313,7 +313,7 @@ ) token = Fog::OpenStack::Auth::Token.build(authv3_creds, {}) - token.catalog.payload.must_equal ['catalog_data'] + _(token.catalog.payload).must_equal ['catalog_data'] end it '#get_endpoint_url' do @@ -325,7 +325,7 @@ ) token = Fog::OpenStack::Auth::Token.build(authv3_creds, {}) - token.catalog.get_endpoint_url(%w[identity], 'public', 'regionOne').must_equal 'http://localhost' + _(token.catalog.get_endpoint_url(%w[identity], 'public', 'regionOne')).must_equal 'http://localhost' end end end @@ -336,9 +336,9 @@ stub_request(:post, 'http://localhost/identity/v2.0/tokens'). to_return(:status => 200, :body => "{\"access\":{\"token\":{\"id\":\"token_data\"}}}", :headers => {}) - proc do + _(proc do Fog::OpenStack::Auth::Token.build({}, {}) - end.must_raise Fog::OpenStack::Auth::Token::URLError + end).must_raise Fog::OpenStack::Auth::Token::URLError end describe 'using the password method' do @@ -356,7 +356,7 @@ to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {}) token = Fog::OpenStack::Auth::Token.build(auth, {}) - token.get.must_equal '4ae647d3a5294690a3c29bc658e17e26' + _(token.get).must_equal '4ae647d3a5294690a3c29bc658e17e26' end it 'authenticates using the tenant id' do @@ -373,7 +373,7 @@ to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {}) token = Fog::OpenStack::Auth::Token.build(auth, {}) - token.get.must_equal '4ae647d3a5294690a3c29bc658e17e26' + _(token.get).must_equal '4ae647d3a5294690a3c29bc658e17e26' end end @@ -390,7 +390,7 @@ to_return(:status => 200, :body => JSON.dump(auth_response_v2('identity', 'keystone')), :headers => {}) token = Fog::OpenStack::Auth::Token.build(auth, {}) - token.get.must_equal '4ae647d3a5294690a3c29bc658e17e26' + _(token.get).must_equal '4ae647d3a5294690a3c29bc658e17e26' end it 'authenticates using the tenant id' do @@ -431,7 +431,7 @@ token = Fog::OpenStack::Auth::Token.build(authv2_creds, {}) token.stub :expired?, false do - token.get.must_equal 'token_not_expired' + _(token.get).must_equal 'token_not_expired' end end @@ -445,7 +445,7 @@ token = Fog::OpenStack::Auth::Token.build(authv2_creds, {}) token.stub :expired?, true do - token.get.must_equal 'token_expired' + _(token.get).must_equal 'token_expired' end end end @@ -459,7 +459,7 @@ ) token = Fog::OpenStack::Auth::Token.build(authv2_creds, {}) - token.catalog.payload.must_equal ['catalog_data'] + _(token.catalog.payload).must_equal ['catalog_data'] end it '#get_endpoint_url' do @@ -471,7 +471,7 @@ ) token = Fog::OpenStack::Auth::Token.build(authv2_creds, {}) - token.catalog.get_endpoint_url(%w[identity], 'public', 'regionOne').must_equal 'http://localhost' + _(token.catalog.get_endpoint_url(%w[identity], 'public', 'regionOne')).must_equal 'http://localhost' end end end diff --git a/unit/test_helper.rb b/unit/test_helper.rb index 6b12ae3ad..dd7c11043 100644 --- a/unit/test_helper.rb +++ b/unit/test_helper.rb @@ -1,4 +1,5 @@ require 'minitest/autorun' +require 'minitest/mock' require 'webmock/minitest' require 'fog/core' diff --git a/unit/volume_test.rb b/unit/volume_test.rb new file mode 100644 index 000000000..e5428c4b6 --- /dev/null +++ b/unit/volume_test.rb @@ -0,0 +1,50 @@ +require 'test_helper' +require 'fog/openstack' + +describe Fog::OpenStack::Volume do + describe '.new' do + # Each versioned service resolves a different catalog entry, and raises a + # ServiceTypeError when the catalog does not advertise it. Stub the versions + # out so the negotiation itself can be tested without a token endpoint: the + # +catalog+ hash carries a marker for the versions the catalog knows about, + # and nil for the rest. + def with_catalog(catalog, &block) + missing = lambda do |*_args| + raise Fog::OpenStack::Auth::Catalog::ServiceTypeError, 'No endpoint match' + end + responder = ->(marker) { marker ? ->(*_args) { marker } : missing } + + Fog::OpenStack::Volume::V3.stub(:new, responder.call(catalog[:volumev3])) do + Fog::OpenStack::Volume::V2.stub(:new, responder.call(catalog[:volumev2])) do + Fog::OpenStack::Volume::V1.stub(:new, responder.call(catalog[:volume]), &block) + end + end + end + + it 'prefers V3 when the catalog advertises volumev3' do + with_catalog(:volumev3 => :v3, :volumev2 => :v2, :volume => :v1) do + _(Fog::OpenStack::Volume.new).must_equal :v3 + end + end + + it 'falls back to V2 when volumev3 is missing' do + with_catalog(:volumev2 => :v2, :volume => :v1) do + _(Fog::OpenStack::Volume.new).must_equal :v2 + end + end + + it 'falls back to V1 when only volume is advertised' do + with_catalog(:volume => :v1) do + _(Fog::OpenStack::Volume.new).must_equal :v1 + end + end + + it 're-raises when the catalog advertises no volume service at all' do + with_catalog({}) do + _(proc { Fog::OpenStack::Volume.new }).must_raise( + Fog::OpenStack::Auth::Catalog::ServiceTypeError + ) + end + end + end +end