Sha256: daced26e37843d52e91db3479d04e58457feee30b7dc0a0ed3c20e3bb0f0a500
Contents?: true
Size: 1.67 KB
Versions: 6
Compression:
Stored size: 1.67 KB
Contents
require 'test_plugin_helper' class ReportGeneratorTest < ActiveSupport::TestCase setup do User.current = User.find_by(login: 'secret_admin') env = FactoryBot.create(:katello_k_t_environment) cv = env.content_views << FactoryBot.create(:katello_content_view, organization: env.organization) @host = FactoryBot.create( :host, :with_subscription, :with_content, content_view: cv.first, lifecycle_environment: env, organization: env.organization ) @host.subscription_facet.pools << FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1) end def interesting_facts [ 'dmi::system::uuid', 'virt::uuid', 'cpu::cpu(s)', 'cpu::cpu_socket(s)', 'cpu::core(s)_per_socket', 'memory::memtotal', 'dmi::bios::vendor', 'dmi::bios::version', 'dmi::bios::relase_date', 'distribution::name', 'uname::release', 'lscpu::flags', ] end def fact_names @fact_names ||= Hash[ interesting_facts.map do |fact| [fact, FactoryBot.create(:fact_name, name: fact, type: 'Katello::RhsmFactName')] end ] end test 'generates a report for a single host' do batch = Host.where(id: @host.id).in_batches.first generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice_123') json_str = generator.render actual = JSON.parse(json_str.join("\n")) assert_equal 'slice_123', actual['report_slice_id'] assert_not_nil(actual_host = actual['hosts'].first) assert_equal @host.name, actual_host['display_name'] assert_equal @host.fqdn, actual_host['fqdn'] assert_equal '1234', actual_host['account'] end end
Version data entries
6 entries across 6 versions & 1 rubygems