diff --git a/.rubocop.yml b/.rubocop.yml index b0524d13..2eddf31d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -79,17 +79,20 @@ FormatString: Style/WordArray: Enabled: false # don't force usage of %w() -Style/LineLength: +Metrics/LineLength: Max: 120 Style/GuardClause: Enabled: false -Style/ClassLength: +Metrics/ClassLength: Max: 600 -Style/CyclomaticComplexity: +Metrics/CyclomaticComplexity: Enabled: false Style/StringLiterals: Enabled: false + +Style/SignalException: + EnforcedStyle: semantic diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e69de29b..eb870388 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -0,0 +1,18 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2016-05-11 14:40:15 -0400 using RuboCop version 0.39.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 39 +Metrics/AbcSize: + Max: 60 + +# Offense count: 7 +Metrics/PerceivedComplexity: + Max: 15 + +Style/Alias: + Enabled: false diff --git a/.travis.yml b/.travis.yml index c20cca72..2a3e60f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,10 @@ language: - ruby rvm: - - "1.9.3" - "2.0.0" - "2.2.0" script: - bundle install --without debug - - bundle exec rake test - bundle exec rake rubocop + - bundle exec rake test diff --git a/Gemfile b/Gemfile index 25a2fab8..19dcbde5 100644 --- a/Gemfile +++ b/Gemfile @@ -10,6 +10,6 @@ group :test do gem 'minitest', '~> 4.7' gem 'parseconfig' gem 'mocha', "~> 0.14.0" - gem 'rubocop', "0.24.1" + gem 'rubocop', "0.39.0" gem 'coveralls' end diff --git a/lib/runcible/base.rb b/lib/runcible/base.rb index 9befee21..da6cb2b0 100644 --- a/lib/runcible/base.rb +++ b/lib/runcible/base.rb @@ -31,16 +31,16 @@ def call(method, path, options = {}) #on occation path will already have prefix (sync cancel) path = clone_config[:api_path] + path unless path.start_with?(clone_config[:api_path]) - RestClient.log = [] + RestClient.log = [] headers = clone_config[:headers].clone get_params = options[:params] if options[:params] path = combine_get_params(path, get_params) if get_params client_options = {} - client_options[:timeout] = clone_config[:timeout] if clone_config[:timeout] - client_options[:open_timeout] = clone_config[:open_timeout] if clone_config[:open_timeout] - client_options[:verify_ssl] = clone_config[:verify_ssl] unless clone_config[:verify_ssl].nil? + client_options[:timeout] = clone_config[:timeout] if clone_config[:timeout] + client_options[:open_timeout] = clone_config[:open_timeout] if clone_config[:open_timeout] + client_options[:verify_ssl] = clone_config[:verify_ssl] unless clone_config[:verify_ssl].nil? if clone_config[:oauth] headers = add_oauth_header(method, path, headers) @@ -52,7 +52,7 @@ def call(method, path, options = {}) client_options[:ssl_client_cert] = clone_config[:cert_auth][:ssl_client_cert] client_options[:ssl_client_key] = clone_config[:cert_auth][:ssl_client_key] else - client_options[:user] = clone_config[:user] + client_options[:user] = clone_config[:user] client_options[:password] = config[:http_auth][:password] end @@ -83,7 +83,7 @@ def get_response(client, path, *args) end def combine_get_params(path, params) - query_string = params.map do |k, v| + query_string = params.map do |k, v| if v.is_a? Array v.map { |y| "#{k}=#{y}" }.join('&') else @@ -105,11 +105,11 @@ def generate_payload(options) def format_payload_json(payload_hash) if payload_hash if payload_hash[:optional] - if payload_hash[:required] - payload = payload_hash[:required].merge(payload_hash[:optional]) - else - payload = payload_hash[:optional] - end + payload = if payload_hash[:required] + payload_hash[:required].merge(payload_hash[:optional]) + else + payload_hash[:optional] + end elsif payload_hash[:delta] payload = payload_hash else @@ -128,7 +128,7 @@ def process_response(response) if body.respond_to? :with_indifferent_access body = body.with_indifferent_access elsif body.is_a? Array - body = body.map do |i| + body = body.map do |i| i.respond_to?(:with_indifferent_access) ? i.with_indifferent_access : i end end diff --git a/lib/runcible/extensions/consumer.rb b/lib/runcible/extensions/consumer.rb index 18b0a05d..e18bfe23 100644 --- a/lib/runcible/extensions/consumer.rb +++ b/lib/runcible/extensions/consumer.rb @@ -114,12 +114,12 @@ def generate_content(type_id, units, options = {}) units.each do |unit| content_unit = {} content_unit[:type_id] = type_id - if unit.is_a?(Hash) - #allow user to pass in entire unit - content_unit[:unit_key] = unit - else - content_unit[:unit_key] = { unit_key => unit } - end + content_unit[:unit_key] = if unit.is_a?(Hash) + #allow user to pass in entire unit + unit + else + { unit_key => unit } + end content.push(content_unit) end @@ -132,7 +132,7 @@ def generate_content(type_id, units, options = {}) # @param [String, Array] ids array of consumer ids # @return [RestClient::Response] def regenerate_applicability_by_ids(ids) - criteria = { + criteria = { 'consumer_criteria' => { 'filters' => { 'id' => { '$in' => ids } } } } regenerate_applicability(criteria) @@ -149,7 +149,7 @@ def regenerate_applicability_by_ids(ids) def applicable_errata(ids) ids = [ids] if ids.is_a? String - criteria = { + criteria = { 'criteria' => { 'filters' => { 'id' => { '$in' => ids } } }, 'content_types' => [Runcible::Extensions::Errata.content_type] } diff --git a/lib/runcible/extensions/repository.rb b/lib/runcible/extensions/repository.rb index ddb57995..980fe095 100644 --- a/lib/runcible/extensions/repository.rb +++ b/lib/runcible/extensions/repository.rb @@ -31,20 +31,18 @@ def create_with_distributors(id, distributors) # @param [Hash] optional container for all optional parameters # @return [RestClient::Response] the created repository def create_with_importer_and_distributors(id, importer, distributors = [], optional = {}) - if importer.is_a?(Runcible::Models::Importer) + if importer && importer.is_a?(Runcible::Models::Importer) optional[:importer_type_id] = importer.id optional[:importer_config] = importer.config - else + elsif importer optional[:importer_type_id] = importer.delete('id') || importer.delete(:id) optional[:importer_config] = importer - end if importer + end repo_type = if importer.methods.include?(:repo_type) importer.repo_type elsif importer.is_a?(Hash) && importer.key?(:repo_type) importer[:repo_type] - else - nil end if optional.key?(:importer_type_id) && repo_type @@ -326,7 +324,7 @@ def docker_images(id) # the [{:image_id => , :tag =>"value"}] # @return [RestClient::Response] def update_docker_tags(id, tags) - update(id, :scratchpad => {:tags => tags}) + update(id, :scratchpad => {:tags => tags}) end # Creates or updates a sync schedule for a repository @@ -387,7 +385,7 @@ def retrieve_with_details(repo_id) # False is the default option. # @return [RestClient::Response] def regenerate_applicability_by_ids(ids, parallel = false) - criteria = { + criteria = { 'parallel' => parallel, 'repo_criteria' => { 'filters' => { 'id' => { '$in' => ids } } } } diff --git a/lib/runcible/instance.rb b/lib/runcible/instance.rb index d7647595..d83bf857 100644 --- a/lib/runcible/instance.rb +++ b/lib/runcible/instance.rb @@ -1,16 +1,5 @@ module Runcible class Instance - # rubocop:disable Style/ClassVars - def self.resource_classes - @@resource_classes ||= gather_classes('resources') - @@resource_classes - end - - def self.extension_classes - @@extension_classes ||= gather_classes('extensions') - @@extension_classes - end - attr_accessor :resources attr_accessor :extensions @@ -50,6 +39,29 @@ def update_config(key, value) attr_reader :config + class << self + # rubocop:disable Style/ClassVars + def resource_classes + @@resource_classes ||= gather_classes('resources') + @@resource_classes + end + + def extension_classes + @@extension_classes ||= gather_classes('extensions') + @@extension_classes + end + + private + + def gather_classes(type) + const = Runcible + const = const.const_get(type.camelize) + path = File.dirname(__FILE__) + "/#{type}/*.rb" + base_names = Dir.glob(path).map { |f| File.basename(f, '.rb') } + base_names.map { |name| const.const_get(name.camelize) } + end + end + private def initialize_wrappers @@ -72,14 +84,6 @@ def accessible_class(class_object) # (e.g. consumer_group) class_object.name.split('::').last.underscore end - - def self.gather_classes(type) - const = Runcible - const = const.const_get(type.camelize) - path = File.dirname(__FILE__) + "/#{type}/*.rb" - base_names = Dir.glob(path).map { |f| File.basename(f, '.rb') } - base_names.map { |name| const.const_get(name.camelize) } - end end #Wrapper class to provide access to instances diff --git a/lib/runcible/models/docker_distributor.rb b/lib/runcible/models/docker_distributor.rb index c6b41b8e..2b1243f1 100644 --- a/lib/runcible/models/docker_distributor.rb +++ b/lib/runcible/models/docker_distributor.rb @@ -6,7 +6,7 @@ module Models class DockerDistributor < Distributor #optional attributes attr_accessor 'docker_publish_directory', 'protected', - 'redirect_url', 'repo_registry_id' + 'redirect_url', 'repo_registry_id' def initialize(params = {}) super(params) diff --git a/lib/runcible/models/docker_importer.rb b/lib/runcible/models/docker_importer.rb index 3ce4caa8..c40a2786 100644 --- a/lib/runcible/models/docker_importer.rb +++ b/lib/runcible/models/docker_importer.rb @@ -1,8 +1,8 @@ module Runcible module Models class DockerImporter < Importer - ID = 'docker_importer' - REPO_TYPE = 'docker-repo' + ID = 'docker_importer'.freeze + REPO_TYPE = 'docker-repo'.freeze attr_accessor 'upstream_name', 'mask_id', 'enable_v1' diff --git a/lib/runcible/models/iso_importer.rb b/lib/runcible/models/iso_importer.rb index 876ca70e..8928a7b4 100644 --- a/lib/runcible/models/iso_importer.rb +++ b/lib/runcible/models/iso_importer.rb @@ -1,7 +1,7 @@ module Runcible module Models class IsoImporter < Importer - ID = 'iso_importer' + ID = 'iso_importer'.freeze # Importer Type id # diff --git a/lib/runcible/models/ostree_importer.rb b/lib/runcible/models/ostree_importer.rb index 3cccd75b..f4dbbffd 100644 --- a/lib/runcible/models/ostree_importer.rb +++ b/lib/runcible/models/ostree_importer.rb @@ -1,8 +1,8 @@ module Runcible module Models class OstreeImporter < Importer - ID = 'ostree_web_importer' - REPO_TYPE = 'OSTREE' + ID = 'ostree_web_importer'.freeze + REPO_TYPE = 'OSTREE'.freeze attr_accessor 'branches' diff --git a/lib/runcible/models/puppet_importer.rb b/lib/runcible/models/puppet_importer.rb index 15c9c41f..e147dc17 100644 --- a/lib/runcible/models/puppet_importer.rb +++ b/lib/runcible/models/puppet_importer.rb @@ -1,8 +1,8 @@ module Runcible module Models class PuppetImporter < Importer - ID = 'puppet_importer' - REPO_TYPE = 'puppet-repo' + ID = 'puppet_importer'.freeze + REPO_TYPE = 'puppet-repo'.freeze attr_accessor 'queries' diff --git a/lib/runcible/models/python_importer.rb b/lib/runcible/models/python_importer.rb index 9e12a2bb..89fbd41b 100644 --- a/lib/runcible/models/python_importer.rb +++ b/lib/runcible/models/python_importer.rb @@ -1,8 +1,8 @@ module Runcible module Models class PythonImporter < Importer - ID = 'python_importer' - REPO_TYPE = 'python-repo' + ID = 'python_importer'.freeze + REPO_TYPE = 'python-repo'.freeze attr_accessor 'packages_names' diff --git a/lib/runcible/models/yum_importer.rb b/lib/runcible/models/yum_importer.rb index 234bf5d3..eb6bcd34 100644 --- a/lib/runcible/models/yum_importer.rb +++ b/lib/runcible/models/yum_importer.rb @@ -1,11 +1,11 @@ module Runcible module Models class YumImporter < Importer - ID = 'yum_importer' - REPO_TYPE = 'rpm-repo' - DOWNLOAD_IMMEDIATE = 'immediate' - DOWNLOAD_ON_DEMAND = 'on_demand' - DOWNLOAD_BACKGROUND = 'background' + ID = 'yum_importer'.freeze + REPO_TYPE = 'rpm-repo'.freeze + DOWNLOAD_IMMEDIATE = 'immediate'.freeze + DOWNLOAD_ON_DEMAND = 'on_demand'.freeze + DOWNLOAD_BACKGROUND = 'background'.freeze DOWNLOAD_POLICIES = [DOWNLOAD_IMMEDIATE, DOWNLOAD_ON_DEMAND, DOWNLOAD_BACKGROUND].freeze attr_accessor 'download_policy' diff --git a/lib/runcible/resources/consumer.rb b/lib/runcible/resources/consumer.rb index 8af0e8c0..8453e20f 100644 --- a/lib/runcible/resources/consumer.rb +++ b/lib/runcible/resources/consumer.rb @@ -7,7 +7,7 @@ class Consumer < Runcible::Base # @param [String] id the ID of the consumer # @return [String] the consumer path, may contain the id if passed def self.path(id = nil) - (id.nil?) ? 'consumers/' : "consumers/#{id}/" + id.nil? ? 'consumers/' : "consumers/#{id}/" end # Creates a consumer diff --git a/lib/runcible/resources/content.rb b/lib/runcible/resources/content.rb index 33e99949..61f0d805 100644 --- a/lib/runcible/resources/content.rb +++ b/lib/runcible/resources/content.rb @@ -9,7 +9,7 @@ class Content < Runcible::Base # @param [String] upload_id the id of the upload_request # @return [String] the content path, may contain the upload_id if passed def upload_path(upload_id = nil) - (upload_id.nil?) ? 'content/uploads/' : "content/uploads/#{upload_id}/" + upload_id.nil? ? 'content/uploads/' : "content/uploads/#{upload_id}/" end # Creates an Upload Request diff --git a/lib/runcible/resources/event_notifier.rb b/lib/runcible/resources/event_notifier.rb index 53fc8418..d6bdc0fb 100644 --- a/lib/runcible/resources/event_notifier.rb +++ b/lib/runcible/resources/event_notifier.rb @@ -3,14 +3,14 @@ module Resources # @see https://pulp-dev-guide.readthedocs.org/en/latest/events/index.html class EventNotifier < Runcible::Base class EventTypes - REPO_SYNC_COMPLETE = 'repo.sync.finish' - REPO_SYNC_START = 'repo.sync.start' - REPO_PUBLISH_COMPLETE = 'repo.publish.finish' - REPO_PUBLISH_START = 'repo.publish.start' + REPO_SYNC_COMPLETE = 'repo.sync.finish'.freeze + REPO_SYNC_START = 'repo.sync.start'.freeze + REPO_PUBLISH_COMPLETE = 'repo.publish.finish'.freeze + REPO_PUBLISH_START = 'repo.publish.start'.freeze end class NotifierTypes - REST_API = 'http' + REST_API = 'http'.freeze end # Generates the API path for Event Notifiers @@ -18,7 +18,7 @@ class NotifierTypes # @param [String] id the ID of the event notifier # @return [String] the event notifier path, may contain the ID if passed def self.path(id = nil) - (id.nil?) ? 'events/' : "events/#{id}/" + id.nil? ? 'events/' : "events/#{id}/" end # Creates an Event Notification diff --git a/lib/runcible/resources/repository.rb b/lib/runcible/resources/repository.rb index 1455bd26..34a82a83 100644 --- a/lib/runcible/resources/repository.rb +++ b/lib/runcible/resources/repository.rb @@ -9,7 +9,7 @@ class Repository < Runcible::Base # @param [String] id the id of the repository # @return [String] the repository path, may contain the id if passed def self.path(id = nil) - (id.nil?) ? 'repositories/' : "repositories/#{id}/" + id.nil? ? 'repositories/' : "repositories/#{id}/" end # Creates a repository diff --git a/lib/runcible/resources/repository_schedule.rb b/lib/runcible/resources/repository_schedule.rb index 4e7d92f0..66a70e05 100644 --- a/lib/runcible/resources/repository_schedule.rb +++ b/lib/runcible/resources/repository_schedule.rb @@ -13,7 +13,7 @@ class RepositorySchedule < Runcible::Base def self.path(repo_id, importer_id, schedule_id = nil) repo_path = Runcible::Resources::Repository.path(repo_id) path = "#{repo_path}importers/#{importer_id}/schedules/sync/" - (schedule_id.nil?) ? path : "#{path}#{schedule_id}/" + schedule_id.nil? ? path : "#{path}#{schedule_id}/" end # List the schedules for a repository for a given importer type diff --git a/lib/runcible/resources/role.rb b/lib/runcible/resources/role.rb index 6a0784e8..8f9b87e9 100644 --- a/lib/runcible/resources/role.rb +++ b/lib/runcible/resources/role.rb @@ -7,7 +7,7 @@ class Role < Runcible::Base # @param [String] id the ID of the role # @return [String] the role path, may contain the ID if passed def self.path(id = nil) - (id.nil?) ? 'roles/' : "roles/#{id}/" + id.nil? ? 'roles/' : "roles/#{id}/" end # Adds a user to a role diff --git a/lib/runcible/resources/task.rb b/lib/runcible/resources/task.rb index 344d835d..298778ed 100644 --- a/lib/runcible/resources/task.rb +++ b/lib/runcible/resources/task.rb @@ -7,7 +7,7 @@ class Task < Runcible::Base # @param [String] id the id of the task # @return [String] the task path, may contain the id if passed def self.path(id = nil) - (id.nil?) ? 'tasks/' : "tasks/#{id}/" + id.nil? ? 'tasks/' : "tasks/#{id}/" end # Polls for the status of a task diff --git a/lib/runcible/resources/task_group.rb b/lib/runcible/resources/task_group.rb index d4133f49..95d3f5c9 100644 --- a/lib/runcible/resources/task_group.rb +++ b/lib/runcible/resources/task_group.rb @@ -7,7 +7,7 @@ class TaskGroup < Runcible::Base # @param [String] id the id of the task # @return [String] the task path, may contain the id if passed def self.path(id = nil) - (id.nil?) ? 'task_groups/' : "task_groups/#{id}/" + id.nil? ? 'task_groups/' : "task_groups/#{id}/" end def self.summary_path(id) diff --git a/lib/runcible/resources/user.rb b/lib/runcible/resources/user.rb index 642a6b46..cd41e4be 100644 --- a/lib/runcible/resources/user.rb +++ b/lib/runcible/resources/user.rb @@ -7,7 +7,7 @@ class User < Runcible::Base # @param [String] login the user's login # @return [String] the user path, may contain the login if passed def self.path(login = nil) - (login.nil?) ? 'users/' : "users/#{login}/" + login.nil? ? 'users/' : "users/#{login}/" end # Retrieves all users diff --git a/lib/runcible/version.rb b/lib/runcible/version.rb index dd0b66b3..37f28d8d 100644 --- a/lib/runcible/version.rb +++ b/lib/runcible/version.rb @@ -1,3 +1,3 @@ module Runcible - VERSION = '1.7.2' + VERSION = '1.7.2'.freeze end diff --git a/test/extensions/consumer_test.rb b/test/extensions/consumer_test.rb index 2ba03374..2ca545c6 100644 --- a/test/extensions/consumer_test.rb +++ b/test/extensions/consumer_test.rb @@ -107,7 +107,7 @@ def test_generate_applicability_by_ids end def test_applicable_errata - response = @extension.applicable_errata([@consumer_id]) + response = @extension.applicable_errata([@consumer_id]) assert_equal 200, response.code end diff --git a/test/extensions/puppet_repository_test.rb b/test/extensions/puppet_repository_test.rb index b921022c..bc1b3e4a 100644 --- a/test/extensions/puppet_repository_test.rb +++ b/test/extensions/puppet_repository_test.rb @@ -53,7 +53,7 @@ def test_create_with_distributors def test_create_with_distributor_object repo_id = RepositorySupport.repo_id + '_distro' response = @extension.create_with_distributors(repo_id, [Runcible::Models::PuppetDistributor.new( - '/path', true, true, :id => '123')]) + '/path', true, true, :id => '123')]) assert_equal 201, response.code response = @extension.retrieve(repo_id, :details => true) diff --git a/test/extensions/repository_test.rb b/test/extensions/repository_test.rb index 9b07a926..1137ac94 100644 --- a/test/extensions/repository_test.rb +++ b/test/extensions/repository_test.rb @@ -55,7 +55,7 @@ def test_create_with_distributors def test_create_with_distributor_object repo_id = RepositorySupport.repo_id + '_distro' response = @extension.create_with_distributors(repo_id, [Runcible::Models::YumDistributor.new( - 'path', true, true, :id => '123')]) + 'path', true, true, :id => '123')]) assert_equal 201, response.code response = @extension.retrieve(repo_id, :details => true) @@ -79,7 +79,7 @@ def test_create_with_importer_and_distributors def test_create_with_importer_and_distributors_objects distributors = [Runcible::Models::YumDistributor.new( - 'path', true, true, :id => '123')] + 'path', true, true, :id => '123')] importer = Runcible::Models::YumImporter.new response = @extension.create_with_importer_and_distributors(RepositorySupport.repo_id, importer, distributors) assert_equal 201, response.code @@ -112,15 +112,27 @@ def test_search_by_repository_ids end def test_create_or_update_schedule - response = @extension.create_or_update_schedule(RepositorySupport.repo_id, 'yum_importer', '2012-09-25T20:44:00Z/P7D') + response = @extension.create_or_update_schedule( + RepositorySupport.repo_id, + 'yum_importer', + '2012-09-25T20:44:00Z/P7D' + ) assert_equal 201, response.code - response = @extension.create_or_update_schedule(RepositorySupport.repo_id, 'yum_importer', '2011-09-25T20:44:00Z/P7D') + response = @extension.create_or_update_schedule( + RepositorySupport.repo_id, + 'yum_importer', + '2011-09-25T20:44:00Z/P7D' + ) assert_equal 200, response.code end def test_remove_schedules - TestRuncible.server.resources.repository_schedule.create(RepositorySupport.repo_id, 'yum_importer', '2012-10-25T20:44:00Z/P7D') + TestRuncible.server.resources.repository_schedule.create( + RepositorySupport.repo_id, + 'yum_importer', + '2012-10-25T20:44:00Z/P7D' + ) response = @extension.remove_schedules(RepositorySupport.repo_id, 'yum_importer') assert_equal 200, response.code diff --git a/test/extensions/rpm_test.rb b/test/extensions/rpm_test.rb index 1cf91a06..1ef8e76d 100644 --- a/test/extensions/rpm_test.rb +++ b/test/extensions/rpm_test.rb @@ -82,14 +82,15 @@ def test_copy end def test_copy_with_filters - response = self.class.extension_class.copy(RepositorySupport.repo_id, - self.class.clone_name, - :filters => { - :unit => { - '$and' => [{'name' => {'$regex' => 'p.*'}}, - {'version' => {'$gt' => '1.0'}}] - }} - ) + response = self.class.extension_class.copy( + RepositorySupport.repo_id, + self.class.clone_name, + :filters => { + :unit => { + '$and' => [{'name' => {'$regex' => 'p.*'}}, + {'version' => {'$gt' => '1.0'}}] + }} + ) tasks = assert_async_response(response) assert_includes tasks.first['tags'], 'pulp:action:associate' end diff --git a/test/resources/consumer_group_test.rb b/test/resources/consumer_group_test.rb index d8489fe3..feb12ec5 100644 --- a/test/resources/consumer_group_test.rb +++ b/test/resources/consumer_group_test.rb @@ -57,7 +57,7 @@ def test_destroy end end - class ConsumerGroupTests < MiniTest::Unit::TestCase + class ConsumerGroupTests < MiniTest::Unit::TestCase include TestConsumerGroupBase def setup @@ -169,21 +169,21 @@ def teardown end def test_install_units - response = @resource.install_units(@consumer_group_id, ['unit_key' => {:name => 'zsh'}, 'type_id' => 'rpm']) + response = @resource.install_units(@consumer_group_id, ['unit_key' => {:name => 'zsh'}, 'type_id' => 'rpm']) assert_equal 202, response.code assert response['spawned_tasks'].first['task_id'] end def test_update_units - response = @resource.update_units(@consumer_group_id, ['unit_key' => {:name => 'zsh'}, 'type_id' => 'rpm']) + response = @resource.update_units(@consumer_group_id, ['unit_key' => {:name => 'zsh'}, 'type_id' => 'rpm']) assert_equal 202, response.code assert response['spawned_tasks'].first['task_id'] end def test_uninstall_units - response = @resource.uninstall_units(@consumer_group_id, ['unit_key' => {:name => 'zsh'}, 'type_id' => 'rpm']) + response = @resource.uninstall_units(@consumer_group_id, ['unit_key' => {:name => 'zsh'}, 'type_id' => 'rpm']) assert_equal 202, response.code assert response['spawned_tasks'].first['task_id'] diff --git a/test/resources/consumer_test.rb b/test/resources/consumer_test.rb index 12051dc5..9ed56975 100644 --- a/test/resources/consumer_test.rb +++ b/test/resources/consumer_test.rb @@ -129,7 +129,7 @@ def teardown end def test_generate_applicability - criteria = { + criteria = { 'consumer_criteria' => { 'filters' => { 'id' => { '$in' => [@consumer_id] } } } } @@ -140,11 +140,11 @@ def test_generate_applicability end def test_applicability - criteria = { + criteria = { 'criteria' => { 'filters' => { 'id' => { '$in' => [@consumer_id] } } }, 'content_types' => [Runcible::Extensions::Errata.content_type] } - response = @resource.applicability(criteria) + response = @resource.applicability(criteria) assert_equal 200, response.code end @@ -241,28 +241,28 @@ def test_retrieve_binding end def test_retrieve_bindings - response = @resource.retrieve_bindings(ConsumerSupport.consumer_id) + response = @resource.retrieve_bindings(ConsumerSupport.consumer_id) assert_equal 200, response.code refute_empty response end def test_install_units - response = @resource.install_units(ConsumerSupport.consumer_id, + response = @resource.install_units(ConsumerSupport.consumer_id, [{'unit_key' => {:name => 'zsh'}, :type_id => 'rpm'}]) assert_equal 202, response.code refute_empty response end def test_update_units - response = @resource.update_units(ConsumerSupport.consumer_id, + response = @resource.update_units(ConsumerSupport.consumer_id, [{'unit_key' => {:name => 'zsh'}, :type_id => 'rpm'}]) assert_equal 202, response.code refute_empty response end def test_uninstall_units - response = @resource.uninstall_units(ConsumerSupport.consumer_id, + response = @resource.uninstall_units(ConsumerSupport.consumer_id, [{'unit_key' => {:name => 'zsh'}, :type_id => 'rpm'}]) assert_equal 202, response.code refute_empty response diff --git a/test/resources/repository_test.rb b/test/resources/repository_test.rb index dd591812..7868aa32 100644 --- a/test/resources/repository_test.rb +++ b/test/resources/repository_test.rb @@ -116,7 +116,7 @@ def test_search end def test_generate_applicability_with_spawned_tasks - criteria = { + criteria = { 'repo_criteria' => { 'filters' => { 'id' => { '$in' => [RepositorySupport.repo_id] } } } } response = @resource.regenerate_applicability(criteria) @@ -126,7 +126,7 @@ def test_generate_applicability_with_spawned_tasks end def test_generate_applicability_with_task_group - criteria = { + criteria = { 'parallel' => true, 'repo_criteria' => { 'filters' => { 'id' => { '$in' => [RepositorySupport.repo_id] } } } } diff --git a/test/resources/task_group_test.rb b/test/resources/task_group_test.rb index a51f31c5..4945c790 100644 --- a/test/resources/task_group_test.rb +++ b/test/resources/task_group_test.rb @@ -10,7 +10,7 @@ def setup @resource = TestRuncible.server.resources.task_group @repo_resource = TestRuncible.server.resources.repository - criteria = { + criteria = { 'parallel' => true, 'repo_criteria' => { 'filters' => { 'id' => { '$in' => [RepositorySupport.repo_id] } } } } @@ -48,7 +48,7 @@ def test_summary_path_with_task_id def test_summary response = @resource.summary(@group_id) assert_equal 200, response.code - keys = ["accepted", "finished", "running", "canceled", "waiting", "skipped", "suspended", "error", "total"] + keys = ["accepted", "finished", "running", "canceled", "waiting", "skipped", "suspended", "error", "total"] assert_equal [], keys - response.keys assert keys.all? { |key| response[key].is_a? Numeric } end diff --git a/test/support/consumer_support.rb b/test/support/consumer_support.rb index 04117f88..75b2a019 100644 --- a/test/support/consumer_support.rb +++ b/test/support/consumer_support.rb @@ -4,7 +4,7 @@ class ConsumerSupport def initialize - @consumer_resource = TestRuncible.server.resources.consumer + @consumer_resource = TestRuncible.server.resources.consumer end def self.consumer_id diff --git a/test/support/repository_support.rb b/test/support/repository_support.rb index 68e0d1cf..22d4ee12 100644 --- a/test/support/repository_support.rb +++ b/test/support/repository_support.rb @@ -3,7 +3,7 @@ require './lib/runcible' class RepositorySupport - FIXTURE_PATH = '/var/www/repositories' + FIXTURE_PATH = '/var/www/repositories'.freeze @@repo_id = 'integration_test_id' @@repo_name = @@repo_id @@ -128,7 +128,7 @@ def wait_on_tasks(tasks) end def wait_on_task(task) - until (['finished', 'error', 'timed_out', 'canceled', 'reset'].include?(task['state'])) + until ['finished', 'error', 'timed_out', 'canceled', 'reset'].include?(task['state']) self.sleep_if_needed task = @task_resource.poll(task['task_id']) end diff --git a/test/unit/base_test.rb b/test/unit/base_test.rb index 15253957..b82881ff 100644 --- a/test/unit/base_test.rb +++ b/test/unit/base_test.rb @@ -48,7 +48,7 @@ def test_verbose_logger end def test_exception_logger - @my_runcible.config[:logging][:exception] = true + @my_runcible.config[:logging][:exception] = true @my_runcible.log_exception assert_equal @log_message, @logger.message