Exemple #1
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
Exemple #2
0
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
Exemple #3
0
    def process(self):
        installed_packages = set()

        signed_rpms = self.consume(InstalledRedHatSignedRPM)
        for rpm_pkgs in signed_rpms:
            for pkg in rpm_pkgs.items:
                installed_packages.add(pkg.name)

        self.produce(check_ntp(installed_packages))