Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #37153 - Fix tests for strict keywords matching #10884

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test/controllers/api/v2/repositories_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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' }
Expand All @@ -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' }
Expand All @@ -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 }
Expand All @@ -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' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions test/lib/repo_discovery_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/lib/tasks/clean_backend_objects_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/lib/tasks/repository_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/models/concerns/host_managed_extensions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/models/concerns/smart_proxy_extensions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/services/katello/pulp3/repository/apt/apt_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading