From 833b4210842f78d2e83009ecf0feaba19572896f Mon Sep 17 00:00:00 2001 From: Oleh Fedorenko Date: Thu, 8 Feb 2024 15:57:45 +0000 Subject: [PATCH] Fixes #37153 - Fix tests for strict keywords matching --- .../api/rhsm/candlepin_proxies_controller_test.rb | 4 ++-- .../controllers/api/v2/repositories_controller_test.rb | 10 +++++----- .../api/v2/upstream_subscriptions_controller_test.rb | 6 +++--- test/lib/repo_discovery_test.rb | 8 ++++---- test/lib/tasks/clean_backend_objects_test.rb | 4 ++-- test/lib/tasks/repository_test.rb | 2 +- .../update_subscription_facet_backend_data_test.rb | 2 +- test/models/concerns/host_managed_extensions_test.rb | 2 +- test/models/concerns/smart_proxy_extensions_test.rb | 6 +++--- .../ansible_collection_repository_mirror_test.rb | 2 +- test/services/katello/pulp3/repository/apt/apt_test.rb | 4 ++-- .../repository/docker/docker_repository_mirror_test.rb | 2 +- 12 files changed, 26 insertions(+), 26 deletions(-) diff --git a/test/controllers/api/rhsm/candlepin_proxies_controller_test.rb b/test/controllers/api/rhsm/candlepin_proxies_controller_test.rb index 3e068a50088..24f6459e57e 100644 --- a/test/controllers/api/rhsm/candlepin_proxies_controller_test.rb +++ b/test/controllers/api/rhsm/candlepin_proxies_controller_test.rb @@ -188,7 +188,7 @@ module Katello it "should update facts" do facts = {'rhsm_fact' => 'rhsm_value'} - ::Host.any_instance.expects(:update_candlepin_associations).with("facts" => facts) + ::Host.any_instance.expects(:update_candlepin_associations).with({ "facts" => facts }) put :facts, params: { :id => @host.subscription_facet.uuid, :facts => facts } assert_equal 200, response.status end @@ -207,7 +207,7 @@ module Katello uuid = @host.subscription_facet.uuid stub_cp_consumer_with_uuid(uuid) facts = {'rhsm_fact' => 'rhsm_value'} - ::Host.any_instance.expects(:update_candlepin_associations).with("facts" => facts) + ::Host.any_instance.expects(:update_candlepin_associations).with({ "facts" => facts }) put :facts, params: { :id => @host.subscription_facet.uuid, :facts => facts} assert_response 200 end diff --git a/test/controllers/api/v2/repositories_controller_test.rb b/test/controllers/api/v2/repositories_controller_test.rb index 10db64914b5..0ac2133bf68 100644 --- a/test/controllers/api/v2/repositories_controller_test.rb +++ b/test/controllers/api/v2/repositories_controller_test.rb @@ -940,7 +940,7 @@ def test_import_uploads # this is yum repo. So unit keys should accept name @controller.expects(:sync_task) .with(::Actions::Katello::Repository::ImportUpload, @repository, uploads, - generate_metadata: true, content_type: nil, sync_capsule: true) + { generate_metadata: true, content_type: nil, sync_capsule: true }) .returns(build_task_stub) put :import_uploads, params: { id: @repository.id, uploads: uploads } @@ -979,7 +979,7 @@ def test_import_uploads_file uploads = [{'id' => '1', 'size' => '12333', 'checksum' => 'asf23421324', 'name' => 'test'}] @controller.expects(:sync_task) .with(::Actions::Katello::Repository::ImportUpload, file_repo, uploads, - generate_metadata: true, content_type: 'file', sync_capsule: true) + { generate_metadata: true, content_type: 'file', sync_capsule: true }) .returns(build_task_stub) put :import_uploads, params: { id: file_repo, uploads: uploads, content_type: 'file' } @@ -993,7 +993,7 @@ def test_import_uploads_docker_manifest uploads = [{'id' => '1', 'size' => '12333', 'checksum' => 'asf23421324', 'name' => 'test'}] @controller.expects(:sync_task) .with(::Actions::Katello::Repository::ImportUpload, @docker_repo, uploads, - generate_metadata: true, content_type: 'docker_manifest', sync_capsule: true) + { generate_metadata: true, content_type: 'docker_manifest', sync_capsule: true }) .returns(build_task_stub) put :import_uploads, params: { id: @docker_repo.id, uploads: uploads, content_type: 'docker_manifest' } @@ -1007,7 +1007,7 @@ def test_import_uploads_docker_tag # this is docker repo so unit keys should acccept name @controller.expects(:sync_task) .with(::Actions::Katello::Repository::ImportUpload, @docker_repo, uploads, - generate_metadata: true, content_type: nil, sync_capsule: true) + { generate_metadata: true, content_type: nil, sync_capsule: true }) .returns(build_task_stub) put :import_uploads, params: { id: @docker_repo.id, uploads: uploads } @@ -1021,7 +1021,7 @@ def test_import_uploads_srpm # this is yum repo. So unit keys should accept name @controller.expects(:sync_task) .with(::Actions::Katello::Repository::ImportUpload, @srpm_repo, uploads, - generate_metadata: true, content_type: 'srpm', sync_capsule: true) + { generate_metadata: true, content_type: 'srpm', sync_capsule: true }) .returns(build_task_stub) put :import_uploads, params: { id: @srpm_repo.id, uploads: uploads, content_type: 'srpm' } diff --git a/test/controllers/api/v2/upstream_subscriptions_controller_test.rb b/test/controllers/api/v2/upstream_subscriptions_controller_test.rb index d16d150416f..22b2e5e3d68 100644 --- a/test/controllers/api/v2/upstream_subscriptions_controller_test.rb +++ b/test/controllers/api/v2/upstream_subscriptions_controller_test.rb @@ -23,7 +23,7 @@ def setup def test_index params = { page: '3', per_page: '7', organization_id: @organization.id } - UpstreamPool.expects(:fetch_pools).with('page' => '3', 'per_page' => '7').returns(pools: [{}], total: nil) + UpstreamPool.expects(:fetch_pools).with({ 'page' => '3', 'per_page' => '7' }).returns(pools: [{}], total: nil) get :index, params: params assert_response :success @@ -42,7 +42,7 @@ def test_index_full_result def test_index_pool_ids params = {pool_ids: %w(1 2 3), page: '3', per_page: '7', organization_id: @organization.id} # omit page and per_page params for candlepin - UpstreamPool.expects(:fetch_pools).with('pool_ids' => %w(1 2 3)).returns({}) + UpstreamPool.expects(:fetch_pools).with({ 'pool_ids' => %w(1 2 3) }).returns({}) get :index, params: params @@ -51,7 +51,7 @@ def test_index_pool_ids def test_index_no_per_page params = {page: '3', organization_id: @organization.id } - UpstreamPool.expects(:fetch_pools).with('page' => '3', 'per_page' => Setting[:entries_per_page]).returns({}) + UpstreamPool.expects(:fetch_pools).with({ 'page' => '3', 'per_page' => Setting[:entries_per_page] }).returns({}) get :index, params: params diff --git a/test/lib/repo_discovery_test.rb b/test/lib/repo_discovery_test.rb index 5dbec54fc78..83b8b5ea01b 100644 --- a/test/lib/repo_discovery_test.rb +++ b/test/lib/repo_discovery_test.rb @@ -61,7 +61,7 @@ def test_docker_with_v1_search_no_proxy search = 'busybox' RestClient::Request.expects(:execute) - .with(method: :get, url: base_url.to_s + "v1/search?q=#{search}", headers: {:accept => :json}) + .with({ method: :get, url: base_url.to_s + "v1/search?q=#{search}", headers: {:accept => :json} }) .returns({results: ['busybox']}.to_json) rd = RepoDiscovery.new(base_url, 'docker', nil, nil, search, crawled, found, to_follow) @@ -78,7 +78,7 @@ def test_docker_with_v1_search_with_proxy search = 'busybox' RestClient::Request.expects(:execute) - .with(method: :get, url: base_url.to_s + "v1/search?q=#{search}", proxy: @proxy_url, headers: {:accept => :json}) + .with({ method: :get, url: base_url.to_s + "v1/search?q=#{search}", proxy: @proxy_url, headers: {:accept => :json} }) .returns({results: ['busybox']}.to_json) rd = RepoDiscovery.new(base_url, 'docker', nil, nil, search, crawled, found, to_follow) @@ -101,11 +101,11 @@ def test_docker_with_v2_search_with_proxy search = 'busybox' RestClient::Request.expects(:execute) - .with(method: :get, url: base_url.to_s + "v1/search?q=#{search}", proxy: @proxy_url, headers: {:accept => :json}) + .with({ method: :get, url: base_url.to_s + "v1/search?q=#{search}", proxy: @proxy_url, headers: {:accept => :json} }) .returns({code: Net::HTTPNotFound}.to_json) RestClient::Request.expects(:execute) - .with(method: :get, url: base_url.to_s + "v2/_catalog", proxy: @proxy_url, headers: {:accept => :json}) + .with({ method: :get, url: base_url.to_s + "v2/_catalog", proxy: @proxy_url, headers: {:accept => :json} }) .returns({'repositories' => ['busybox']}.to_json.extend(MockHeaders)) rd = RepoDiscovery.new(base_url, 'docker', nil, nil, search, crawled, found, to_follow) diff --git a/test/lib/tasks/clean_backend_objects_test.rb b/test/lib/tasks/clean_backend_objects_test.rb index 8e234b12e18..7cb458a4799 100644 --- a/test/lib/tasks/clean_backend_objects_test.rb +++ b/test/lib/tasks/clean_backend_objects_test.rb @@ -42,7 +42,7 @@ def test_managed_host @host.subscription_facet.update!(:uuid => nil) mock_cp - Katello::RegistrationManager.expects(:unregister_host).with(@host, :unregistering => true).once + Katello::RegistrationManager.expects(:unregister_host).with(@host, { :unregistering => true }).once Rake.application.invoke_task('katello:clean_backend_objects') end @@ -55,7 +55,7 @@ def test_compute_resource_host @host.subscription_facet.update!(:uuid => nil) mock_cp - Katello::RegistrationManager.expects(:unregister_host).with(@host, :unregistering => true).once + Katello::RegistrationManager.expects(:unregister_host).with(@host, { :unregistering => true }).once Rake.application.invoke_task('katello:clean_backend_objects') end diff --git a/test/lib/tasks/repository_test.rb b/test/lib/tasks/repository_test.rb index 90f751edf08..72f2fe489ba 100644 --- a/test/lib/tasks/repository_test.rb +++ b/test/lib/tasks/repository_test.rb @@ -140,7 +140,7 @@ def test_correct_repositories_missing_library_repo_commit_pulp3 Katello::Repository.stubs(:in_environment).returns(Katello::Repository.where(:id => @library_repo)) PulpRpmClient::RepositoriesRpmApi.any_instance.expects(:read).once.with("test_repo_1/").raises(PulpRpmClient::ApiError) - ForemanTasks.expects(:sync_task).with(::Actions::Katello::Repository::Create, @library_repo, { force_repo_create: true }) + ForemanTasks.expects(:sync_task).with(::Actions::Katello::Repository::Create, @library_repo, force_repo_create: true) Rake.application.invoke_task('katello:correct_repositories') end diff --git a/test/lib/tasks/update_subscription_facet_backend_data_test.rb b/test/lib/tasks/update_subscription_facet_backend_data_test.rb index 5d2a78dc99b..5fc83bc461b 100644 --- a/test/lib/tasks/update_subscription_facet_backend_data_test.rb +++ b/test/lib/tasks/update_subscription_facet_backend_data_test.rb @@ -19,7 +19,7 @@ def test_run Katello::Resources::Candlepin::Consumer.stubs(:virtual_guests).returns([]) Katello::Resources::Candlepin::Consumer.stubs(:virtual_host).returns(nil) - Katello::Host::SubscriptionFacet.expects(:update_facts).with(@host, :foo => :bar).once + Katello::Host::SubscriptionFacet.expects(:update_facts).with(@host, { :foo => :bar }).once Rake.application.invoke_task('katello:update_subscription_facet_backend_data') end diff --git a/test/models/concerns/host_managed_extensions_test.rb b/test/models/concerns/host_managed_extensions_test.rb index dcf71786268..2e1273912ef 100644 --- a/test/models/concerns/host_managed_extensions_test.rb +++ b/test/models/concerns/host_managed_extensions_test.rb @@ -218,7 +218,7 @@ def test_update_with_facet_params host = FactoryBot.create(:host, :with_content, :with_subscription, :content_view => @library_view, :lifecycle_environment => @library) host.content_facet.expects(:save!) host.subscription_facet.stubs(:consumer_attributes).returns('autoheal' => true) - host.subscription_facet.expects(:update_from_consumer_attributes).with('autoheal' => true) + host.subscription_facet.expects(:update_from_consumer_attributes).with({ 'autoheal' => true }) ::Katello::Resources::Candlepin::Consumer.expects(:update).with(host.subscription_facet.uuid, host.subscription_facet.consumer_attributes) ::Katello::Resources::Candlepin::Consumer.expects(:refresh_entitlements).never ::Katello::Host::SubscriptionFacet.expects(:update_facts).never diff --git a/test/models/concerns/smart_proxy_extensions_test.rb b/test/models/concerns/smart_proxy_extensions_test.rb index 2000f82371f..a356055b1a8 100644 --- a/test/models/concerns/smart_proxy_extensions_test.rb +++ b/test/models/concerns/smart_proxy_extensions_test.rb @@ -248,9 +248,9 @@ def test_sync_container_gateway with_pulp3_features(capsule_content.smart_proxy) capsule_content.smart_proxy.add_lifecycle_environment(environment) - repo_list_update_expectation = ProxyAPI::ContainerGateway.any_instance.expects(:repository_list).with( - :repositories => [{:repository => "empty_organization-puppet_product-busybox", :auth_required => true}, {:repository => "busybox", :auth_required => true}] - ) + repo_list_update_expectation = ProxyAPI::ContainerGateway.any_instance.expects(:repository_list).with({ + :repositories => [{:repository => "empty_organization-puppet_product-busybox", :auth_required => true}, {:repository => "busybox", :auth_required => true}] + }) repo_list_update_expectation.once.returns(true) repo_mapping_update_expectation = ProxyAPI::ContainerGateway.any_instance.expects(:user_repository_mapping).with do |arg| diff --git a/test/services/katello/pulp3/repository/ansible_collection/ansible_collection_repository_mirror_test.rb b/test/services/katello/pulp3/repository/ansible_collection/ansible_collection_repository_mirror_test.rb index 5849a556597..74776a2185b 100644 --- a/test/services/katello/pulp3/repository/ansible_collection/ansible_collection_repository_mirror_test.rb +++ b/test/services/katello/pulp3/repository/ansible_collection/ansible_collection_repository_mirror_test.rb @@ -18,7 +18,7 @@ def test_sync @repo_mirror.stubs(:remote_href).returns("remote_href") @repo_mirror.stubs(:repository_href).returns("repository_href") sync_url = @repo_service.api.repository_sync_url_class.new(remote: "remote_href", mirror: true) - PulpAnsibleClient::AnsibleRepositorySyncURL.expects(:new).with(remote: "remote_href", mirror: true).once.returns(sync_url) + PulpAnsibleClient::AnsibleRepositorySyncURL.expects(:new).with({ remote: "remote_href", mirror: true }).once.returns(sync_url) PulpAnsibleClient::RepositoriesAnsibleApi.any_instance.expects(:sync).once.with("repository_href", sync_url) @repo_mirror.sync(optimize: "test", skip_types: "another test") end diff --git a/test/services/katello/pulp3/repository/apt/apt_test.rb b/test/services/katello/pulp3/repository/apt/apt_test.rb index 62ed4f2b72a..b69fd8153d4 100644 --- a/test/services/katello/pulp3/repository/apt/apt_test.rb +++ b/test/services/katello/pulp3/repository/apt/apt_test.rb @@ -66,7 +66,7 @@ def test_publication_options_wo_signing_service PulpcoreClient::SigningServicesApi .any_instance .expects(:list) - .with({name: 'katello_deb_sign'}) + .with(name: 'katello_deb_sign') .returns(signing_service_response_list) service = Katello::Pulp3::Repository::Apt.new(@repo, @proxy) @@ -85,7 +85,7 @@ def test_publication_options_with_signing_service PulpcoreClient::SigningServicesApi .any_instance .expects(:list) - .with({name: 'katello_deb_sign'}) + .with(name: 'katello_deb_sign') .returns(signing_service_response_list) service = Katello::Pulp3::Repository::Apt.new(@repo, @proxy) diff --git a/test/services/katello/pulp3/repository/docker/docker_repository_mirror_test.rb b/test/services/katello/pulp3/repository/docker/docker_repository_mirror_test.rb index b3235795be3..cafcf049628 100644 --- a/test/services/katello/pulp3/repository/docker/docker_repository_mirror_test.rb +++ b/test/services/katello/pulp3/repository/docker/docker_repository_mirror_test.rb @@ -22,7 +22,7 @@ def test_sync @repo_mirror.stubs(:remote_href).returns("remote_href") @repo_mirror.stubs(:repository_href).returns("repository_href") sync_url = @repo_service.api.repository_sync_url_class.new(remote: "remote_href", mirror: true) - PulpContainerClient::ContainerRepositorySyncURL.expects(:new).with(remote: "remote_href", mirror: true).once.returns(sync_url) + PulpContainerClient::ContainerRepositorySyncURL.expects(:new).with({ remote: "remote_href", mirror: true }).once.returns(sync_url) PulpContainerClient::RepositoriesContainerApi.any_instance.expects(:sync).once.with("repository_href", sync_url) @repo_mirror.sync(optimize: "test", skip_types: "another test") end