def test_newest_kernel(monkeypatch): monkeypatch.setattr( api, 'current_actor', CurrentActorMocked(kernel='3.10.0-1234.21.1.el7.x86_64')) monkeypatch.setattr(api, 'current_logger', mocked_logger()) monkeypatch.setattr(api, 'consume', mocked_consume(versioned_kernel_pkgs)) monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) library.process() assert not reporting.create_report.called monkeypatch.setattr( api, 'current_actor', CurrentActorMocked(kernel='3.10.0-456.43.1.el7.x86_64')) monkeypatch.setattr(api, 'current_logger', mocked_logger()) monkeypatch.setattr(api, 'consume', mocked_consume(versioned_kernel_pkgs)) monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) library.process() assert reporting.create_report.called assert reporting.create_report.report_fields[ 'title'] == 'Newest installed kernel not in use' monkeypatch.setattr( api, 'current_actor', CurrentActorMocked(kernel='3.10.0-789.35.2.el7.x86_64')) monkeypatch.setattr(api, 'current_logger', mocked_logger()) monkeypatch.setattr(api, 'consume', mocked_consume(versioned_kernel_pkgs)) monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) library.process() assert reporting.create_report.called assert reporting.create_report.report_fields[ 'title'] == 'Newest installed kernel not in use'
def test_report_skipped_packages_no_verbose_mode(monkeypatch, caplog, is_verbose_mode_on): """ Tests whether the report_skipped_packages function creates message of the expected form and that the function respects whether leapp is running in verbose mode. """ monkeypatch.setattr(api, 'produce', produce_mocked()) monkeypatch.setattr(api, 'show_message', show_message_mocked()) monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setenv('LEAPP_VERBOSE', '1') report_skipped_packages(title='Packages will not be installed', message='packages will not be installed:', package_repo_pairs=[ (('skipped01', None), 'bad_repo01'), (('skipped02', ('module', 'stream')), 'bad_repo02') ]) message = ('2 packages will not be installed:\n' '- skipped01 (repoid: bad_repo01)\n' '- skipped02 [module:stream] (repoid: bad_repo02)') assert message in caplog.messages assert reporting.create_report.called == 1 assert reporting.create_report.report_fields[ 'title'] == 'Packages will not be installed' assert reporting.create_report.report_fields['summary'] == message leapp_verbose = '1' if is_verbose_mode_on else '0' monkeypatch.setenv('LEAPP_VERBOSE', leapp_verbose) # Reset reporting.create_report for next test part monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) report_skipped_packages(title='Packages will not be installed', message='packages will not be installed:', package_repo_pairs=[ (('skipped01', None), 'bad_repo01'), (('skipped02', ('module', 'stream')), 'bad_repo02') ]) # FIXME(pstodulk): this is obviously wrong. repoid is currently pesid.. so test # is incorrect, and code is incorrect. even the message is missleading. # this is going to be fixed in close future. message = ('2 packages will not be installed:\n' '- skipped01 (repoid: bad_repo01)\n' '- skipped02 [module:stream] (repoid: bad_repo02)') # Verbose level should only control whether show_message is called, report entry should be created # in both cases. if is_verbose_mode_on: assert message in caplog.messages else: assert api.show_message.called == 0 assert reporting.create_report.called == 1 assert reporting.create_report.report_fields[ 'title'] == 'Packages will not be installed' assert reporting.create_report.report_fields['summary'] == message
def test_inhibit_if_deprecated_directives_used(monkeypatch): """Tests whether the upgrade is inhibited when deprecated directives are used in config.""" created_report = create_report_mocked() monkeypatch.setattr(reporting, 'create_report', created_report) ssh_config = OpenSshConfig(permit_root_login=[], deprecated_directives=['ShowPatchLevel']) inhibit_if_deprecated_directives_used(ssh_config) fail_description = 'Report entry was not created when deprecated directive found in the ssh config.' assert created_report.called == 1, fail_description fail_description = 'Report doesn\'t have information about deprecated directive in the title.' assert 'deprecated directive' in created_report.report_fields[ 'title'].lower(), fail_description fail_description = 'Report doesn\'t contain the (mocked) deprecated directive present in the config.' # The report should have the directive in a preserved form (same as found in configuration) assert 'ShowPatchLevel' in created_report.report_fields[ 'summary'], fail_description assert created_report.report_fields[ 'severity'] == 'high', 'Report has incorrect severity.' fail_description = 'Report should have the inhibition flag set when deprecated directive is present.' assert 'inhibitor' in created_report.report_fields[ 'flags'], fail_description assert created_report.report_fields[ 'remediations'], 'Report should carry some remediation information.'
def test_pesid_to_target_repoids_translation(monkeypatch, caplog): """ Tests whether the actor is able to correctly translate target pesids resulting from event processing when it is supplied with a valid dictionary that maps pesids to target repoids. """ monkeypatch.setattr(api, 'show_message', show_message_mocked()) monkeypatch.setattr(peseventsscanner, '_get_repositories_mapping', lambda dummy_target_pesids: {'repo': 'mapped'}) monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setenv('LEAPP_VERBOSE', '1') to_install = { ('pkg01', None): 'repo', ('pkg02', ('module', 'stream')): 'repo', ('skipped01', None): 'not_mapped', ('skipped02', ('module', 'stream')): 'not_mapped' } map_repositories(to_install) msg = ( '2 packages may not be installed or upgraded due to repositories unknown to leapp:\n' '- skipped01 (repoid: not_mapped)\n' '- skipped02 [module:stream] (repoid: not_mapped)') assert msg in caplog.messages assert reporting.create_report.called == 1 assert reporting.create_report.report_fields['title'] == ( 'Packages from unknown repositories may not be installed') assert reporting.create_report.report_fields['summary'] == msg assert to_install == { ('pkg01', None): 'mapped', ('pkg02', ('module', 'stream')): 'mapped' }
def test_no_hybrid_image(monkeypatch, is_symlink, realpath_match, is_bios, agent_installed, tmpdir): grubenv_efi = tmpdir.join('grubenv_efi') grubenv_efi.write('grubenv') grubenv_efi_false = tmpdir.join('grubenv_efi_false') grubenv_efi.write('nope') grubenv_boot = tmpdir.join('grubenv_boot') grubenv_target = grubenv_efi if realpath_match else grubenv_efi_false if is_symlink: grubenv_boot.mksymlinkto(grubenv_target) firmw = BIOS_FIRMWARE if is_bios else EFI_FIRMWARE inst_rpms = INSTALLED_AGENT if agent_installed else NOT_INSTALLED_AGENT monkeypatch.setattr(checkhybridimage, 'BIOS_PATH', grubenv_boot.strpath) monkeypatch.setattr(checkhybridimage, 'EFI_PATH', grubenv_efi.strpath) monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setattr( api, 'current_actor', CurrentActorMocked(arch='x86_64', msgs=[firmw, inst_rpms])) monkeypatch.setattr(api, "produce", produce_mocked()) checkhybridimage.check_hybrid_image() assert not reporting.create_report.called assert not api.produce.called
def test_actor_execution(monkeypatch, has_server): """ Parametrized helper function for test_actor_* functions. First generate list of RPM models based on set arguments. Then, run the actor feeded with our RPM list. Finally, assert Reports according to set arguments. Parameters: has_server (bool): postgresql-server installed """ # Couple of random packages rpms = [_generate_rpm_with_name('sed'), _generate_rpm_with_name('htop')] if has_server: # Add postgresql-server rpms += [_generate_rpm_with_name('postgresql-server')] curr_actor_mocked = CurrentActorMocked( msgs=[InstalledRedHatSignedRPM(items=rpms)]) monkeypatch.setattr(api, 'current_actor', curr_actor_mocked) monkeypatch.setattr(reporting, "create_report", create_report_mocked()) # Executed actor feeded with out fake RPMs report_installed_packages(_context=api) if has_server: # Assert for postgresql-server package installed assert reporting.create_report.called == 1 else: # Assert for no postgresql packages installed assert not reporting.create_report.called
def test_checktargetrepos_no_rhsm(monkeypatch, enable_repos, custom_target_repos, custom_target_repofile): mocked_consume = MockedConsume(_TARGET_REPOS_CUSTOM if custom_target_repos else _TARGET_REPOS_NO_CUSTOM) if custom_target_repofile: mocked_consume._msgs.append(_CUSTOM_TARGET_REPOFILE) envars = {'LEAPP_ENABLE_REPOS': 'hill,spencer'} if enable_repos else {} monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(envars=envars)) monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setattr(rhsm, 'skip_rhsm', lambda: True) monkeypatch.setattr(api, 'consume', mocked_consume) checktargetrepos.process() if not custom_target_repos: assert reporting.create_report.called == 1 assert 'inhibitor' in reporting.create_report.report_fields.get( 'flags', []) elif not enable_repos and custom_target_repos and not custom_target_repofile: assert reporting.create_report.called == 1 assert 'inhibitor' not in reporting.create_report.report_fields.get( 'flags', []) else: assert reporting.create_report.called == 0
def test_map_repositories(monkeypatch): monkeypatch.setattr(api, 'show_message', show_message_mocked()) monkeypatch.setattr(library, '_get_repositories_mapping', lambda: {'repo': 'mapped'}) monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setenv('LEAPP_VERBOSE', '1') to_install = { 'pkg01': 'repo', 'pkg02': 'repo', 'skipped01': 'not_mapped', 'skipped02': 'not_mapped' } map_repositories(to_install) msgs = [ '2 packages will not be installed or upgraded due to repositories unknown to leapp:', '- skipped01', '- skipped02' ] assert api.show_message.called == 1 assert api.show_message.msg == '\n'.join(msgs) assert reporting.create_report.called == 1 assert reporting.create_report.report_fields[ 'title'] == 'Packages will not be installed' assert reporting.create_report.report_fields['summary'] == '\n'.join(msgs) assert to_install == {'pkg01': 'mapped', 'pkg02': 'mapped'}
def test_filter_out_pkgs_in_blacklisted_repos(monkeypatch, caplog): monkeypatch.setattr(api, 'show_message', show_message_mocked()) monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setattr(peseventsscanner, 'get_repositories_blacklisted', get_repos_blacklisted_mocked(set(['blacklisted']))) monkeypatch.setenv('LEAPP_VERBOSE', '1') to_install = { 'pkg01': 'repo01', 'pkg02': 'repo02', 'skipped01': 'blacklisted', 'skipped02': 'blacklisted', } msg = '2 {}\n{}'.format( SKIPPED_PKGS_MSG, '\n'.join([ '- {pkg} (repoid: {repo})'.format(pkg=pkg, repo=repo) for pkg, repo in filter( # pylint: disable=deprecated-lambda lambda item: item[1] == 'blacklisted', to_install.items()) ])) filter_out_pkgs_in_blacklisted_repos(to_install) assert msg in caplog.messages assert reporting.create_report.called == 1 assert reporting.create_report.report_fields['summary'] == msg assert reporting.create_report.report_fields['title'] == ( 'Packages available in excluded repositories will not be installed') assert to_install == {'pkg01': 'repo01', 'pkg02': 'repo02'}
def test_map_repositories(monkeypatch, caplog): monkeypatch.setattr(api, 'show_message', show_message_mocked()) monkeypatch.setattr(peseventsscanner, '_get_repositories_mapping', lambda: {'repo': 'mapped'}) monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setenv('LEAPP_VERBOSE', '1') to_install = { 'pkg01': 'repo', 'pkg02': 'repo', 'skipped01': 'not_mapped', 'skipped02': 'not_mapped' } map_repositories(to_install) msg = ( '2 packages may not be installed or upgraded due to repositories unknown to leapp:\n' '- skipped01 (repoid: not_mapped)\n' '- skipped02 (repoid: not_mapped)') assert msg in caplog.messages assert reporting.create_report.called == 1 assert reporting.create_report.report_fields['title'] == ( 'Packages from unknown repositories may not be installed') assert reporting.create_report.report_fields['summary'] == msg assert to_install == {'pkg01': 'mapped', 'pkg02': 'mapped'}
def test_non_ibmz_arch(monkeypatch): monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(architecture.ARCH_X86_64)) monkeypatch.setattr(reporting, "create_report", testutils.create_report_mocked()) cpu.process() assert not reporting.create_report.called
def test_migration(monkeypatch): for packages, services, migrate in [ (['ntp'], ['ntpd'], ['ntpd']), (['ntp', 'ntpdate'], ['ntpd'], ['ntpd']), (['ntpdate'], ['ntpdate'], ['ntpdate']), (['ntp', 'ntpdate'], ['ntpdate'], ['ntpdate']), (['ntp', 'ntpdate'], ['ntpd', 'ntpdate'], ['ntpd', 'ntpdate']), (['ntp', 'ntpdate', 'ntp-perl'], ['ntpd', 'ntpdate'], ['ntpd', 'ntpdate']), (['ntp', 'ntpdate'], ['ntpd', 'ntpdate', 'ntp-wait'], ['ntpd', 'ntpdate']), (['ntp', 'ntpdate', 'ntp-perl'], ['ntpd', 'ntpdate', 'ntp-wait'], ['ntpd', 'ntpdate', 'ntp-wait']), ]: monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setattr(library, 'check_service', lambda service: service[:-8] in services) monkeypatch.setattr(library, 'is_file', lambda _: True) monkeypatch.setattr(library, 'get_tgz64', lambda _: '') decision = library.check_ntp(set(packages)) assert reporting.create_report.called == 1 assert 'configuration will be migrated' in reporting.create_report.report_fields[ 'title'] for service in ['ntpd', 'ntpdate']: migrated = re.search( r'\b{}\b'.format(service), reporting.create_report.report_fields['title']) is not None assert migrated == (service in migrate) assert decision.migrate_services == migrate
def test_report_target_version(monkeypatch, version): monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(dst_ver=version)) monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) SUMMARY_FMT = 'will be set to {}.' library.process() assert reporting.create_report.called == 1 assert SUMMARY_FMT.format(version) in reporting.create_report.report_fields['summary']
def test_actor_execution_with_unsigned_data(monkeypatch): def consume_unsigned_message_mocked(*models): installed_rpm = [ RPM(name='sample02', version='0.1', release='1.sm01', epoch='1', packager=RH_PACKAGER, arch='noarch', pgpsig='SOME_OTHER_SIG_X'), RPM(name='sample04', version='0.1', release='1.sm01', epoch='1', packager=RH_PACKAGER, arch='noarch', pgpsig='SOME_OTHER_SIG_X'), RPM(name='sample06', version='0.1', release='1.sm01', epoch='1', packager=RH_PACKAGER, arch='noarch', pgpsig='SOME_OTHER_SIG_X'), RPM(name='sample08', version='0.1', release='1.sm01', epoch='1', packager=RH_PACKAGER, arch='noarch', pgpsig='SOME_OTHER_SIG_X')] yield InstalledUnsignedRPM(items=installed_rpm) monkeypatch.setattr(api, "consume", consume_unsigned_message_mocked) monkeypatch.setattr(api, "produce", produce_mocked()) monkeypatch.setattr(api, "show_message", lambda x: True) monkeypatch.setattr(reporting, "create_report", create_report_mocked()) packages = library.get_unsigned_packages() assert len(packages) == 4 library.generate_report(packages) assert reporting.create_report.called == 1 assert 'Packages not signed by Red Hat found' in reporting.create_report.report_fields['title'] assert all(r['remediations']['context'][0] == 'yum' and r['remediations']['context'][1] == '-y' and r['remediations']['context'][2] == 'remove' and 'sample' in r['remediations']['context'][3] for r in reporting.create_report.report_fields['remediations'])
def test_render_report( monkeypatch, restricted_driver_names_on_host, restricted_pci_ids_on_host, restricted_devices_drivers, restricted_devices_pcis, inhibit_upgrade, exp_line_length, caplog, ): """Check report appearance.""" monkeypatch.setattr( reporting, "create_report", create_report_mocked(), ) reporting.create_report( render_report( restricted_driver_names_on_host=restricted_driver_names_on_host, restricted_pci_ids_on_host=restricted_pci_ids_on_host, restricted_devices_drivers=restricted_devices_drivers, restricted_devices_pcis=restricted_devices_pcis, inhibit_upgrade=inhibit_upgrade, )) logger.info(reporting.create_report.report_fields["summary"]) assert sum(len(m.split("\n")) for m in caplog.messages) == exp_line_length
def test_filter_out_pkgs_in_blacklisted_repos(monkeypatch): monkeypatch.setattr(api, 'show_message', show_message_mocked()) monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setattr(library, 'get_repositories_blacklisted', get_repos_blacklisted_mocked(set(['blacklisted']))) monkeypatch.setenv('LEAPP_VERBOSE', '1') to_install = { 'pkg01': 'repo01', 'pkg02': 'repo02', 'skipped01': 'blacklisted', 'skipped02': 'blacklisted' } filter_out_pkgs_in_blacklisted_repos(to_install) msgs = [ '2 packages will not be installed due to blacklisted repositories:', '- skipped01', '- skipped02' ] assert api.show_message.called == 1 assert api.show_message.msg == '\n'.join(msgs) assert reporting.create_report.called == 1 assert reporting.create_report.report_fields['summary'] == '\n'.join(msgs) assert reporting.create_report.report_fields[ 'title'] == 'Packages will not be installed' assert to_install == {'pkg01': 'repo01', 'pkg02': 'repo02'}
def test_basic_checkpcidrivers( monkeypatch, driver_name, pci_id, inhibit_upgrade, num_msgs, ): """Check the main actor function.""" pci_devices.devices[0].driver = driver_name pci_devices.devices[0].pci_id = pci_id monkeypatch.setattr( api, "current_actor", CurrentActorMocked(msgs=[pci_devices, restricted_pci_devices]), ) monkeypatch.setattr( reporting, "create_report", create_report_mocked(), ) monkeypatch.setattr( CurrentActorMocked, "produce", produce_mocked(), ) checkpcidrivers_main() if inhibit_upgrade: assert len(CurrentActorMocked.produce.model_instances) == 1 assert CurrentActorMocked.produce.model_instances[0].report[ "flags"] == ["inhibitor"] if num_msgs and not inhibit_upgrade: assert ("flags" not in CurrentActorMocked.produce.model_instances[0].report) assert len(CurrentActorMocked.produce.model_instances) == num_msgs
def test_inhibition_multiple_rescue_entries_present(monkeypatch): """Tests whether the upgrade process is inhibited when multiple rescue boot entries are present.""" mocked_report = create_report_mocked() monkeypatch.setattr(architecture, 'matches_architecture', lambda dummy: True) monkeypatch.setattr(reporting, 'create_report', mocked_report) boot_entries = [ BootEntry(title='entry_1'), BootEntry(title='entry_1_Rescue'), BootEntry(title='entry_2'), BootEntry(title='entry_2_rescue-ver2.3' ), # Typically is the `rescue` substring surrounded ] inhibit_if_multiple_zipl_rescue_entries_present( SourceBootLoaderConfiguration(entries=boot_entries)) assert mocked_report.called, 'Report should be created when multiple rescue entries are present.' fail_description = 'The correct rescue entries are not present in the report summary.' report_summary = mocked_report.report_fields['summary'] for expected_rescue_entry in ['entry_1_Rescue', 'entry_2_rescue-ver2.3']: assert expected_rescue_entry in report_summary, fail_description fail_description = 'Upgrade should be inhibited on multiple rescue entries.' assert 'inhibitor' in mocked_report.report_fields[ 'flags'], fail_description
def test_enough_space_available(monkeypatch): monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) get_avail_bytes_on_boot = fake_get_avail_bytes_on_boot( MIN_AVAIL_BYTES_FOR_BOOT) check_avail_space_on_boot(get_avail_bytes_on_boot) assert reporting.create_report.called == 0
def test_inhibit_on_duplicate_repos_no_dups(monkeypatch): monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setattr(api, 'current_logger', logger_mocked()) rhsm._inhibit_on_duplicate_repos([_gen_repofile("foo")]) assert not api.current_logger.warnmsg assert reporting.create_report.called == 0
def test_uninstalled(monkeypatch): for config_default in (False, True): monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setattr(checkchrony, 'is_config_default', lambda: config_default) checkchrony.check_chrony(False) assert reporting.create_report.called == 0
def test_inhibition(monkeypatch): monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) utils.process_lines([l.strip() for l in TEST_DATA.splitlines()], ( 'wins', 'winbind', ), '/nss_path') assert reporting.create_report.called == 1 assert 'inhibitor' in reporting.create_report.report_fields['flags']
def test_valid_architectures(monkeypatch): monkeypatch.setattr(reporting, "create_report", create_report_mocked()) monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(arch=architecture.ARCH_ACCEPTED[0])) checksystemarch.check_architecture() assert reporting.create_report.called == 0
def test_checktargetrepos_rhsm(monkeypatch): monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setattr(rhsm, 'skip_rhsm', lambda: False) monkeypatch.setattr(api, 'consume', MockedConsume()) monkeypatch.setattr(checktargetrepos, 'get_target_major_version', lambda: '8') checktargetrepos.process() assert reporting.create_report.called == 0
def test_scan_invalid_file_csv(monkeypatch): monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) with pytest.raises(StopActorExecution): scan_repositories('files/tests/sample04.csv') assert reporting.create_report.called == 1 assert 'inhibitor' in reporting.create_report.report_fields['flags'] assert 'Repositories map file is invalid' in reporting.create_report.report_fields[ 'title']
def test_installed_nodefconf(monkeypatch): monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setattr(checkchrony, 'is_config_default', lambda: False) checkchrony.check_chrony(True) assert reporting.create_report.called == 1 assert reporting.create_report.report_fields['title'] == 'chrony using non-default configuration'
def test_inhibit_on_duplicate_repos_no_dups(monkeypatch): monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setattr(api, 'current_logger', LoggerMocked()) rhsm._inhibit_on_duplicate_repos(YUM_REPOINFO_TYPICAL) assert api.current_logger.warnmsg is None assert reporting.create_report.called == 0
def test_nomigration(monkeypatch): monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setattr(library, 'check_service', lambda _: False) monkeypatch.setattr(library, 'is_file', lambda _: False) monkeypatch.setattr(library, 'get_tgz64', lambda _: '') library.check_ntp(set(['chrony', 'linuxptp', 'xterm'])) assert reporting.create_report.called == 0
def test_pes_data_not_found(monkeypatch): def read_or_fetch_mocked(filename, directory="/etc/leapp/files", service=None, allow_empty=False): fetch._raise_error('pes-data.json', 'epic fail!') monkeypatch.setattr(fetch, 'read_or_fetch', read_or_fetch_mocked) monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setattr(api, 'current_actor', CurrentActorMocked()) with pytest.raises(StopActorExecutionError): get_events('/etc/leapp', 'pes-data.json')
def test_sku_report_has_no_skus(monkeypatch): monkeypatch.setattr(rhsm, 'skip_rhsm', lambda: False) monkeypatch.setattr(api, 'consume', lambda x: (RHSMInfo(attached_skus=[]),)) monkeypatch.setattr(checkrhsmsku, 'create_report', create_report_mocked()) checkrhsmsku.process() assert checkrhsmsku.create_report.called == 1 assert checkrhsmsku.create_report.report_fields['title'] == 'The system is not registered or subscribed.' assert checkrhsmsku.create_report.report_fields['severity'] == 'high' assert 'inhibitor' in checkrhsmsku.create_report.report_fields['flags']