def test_no_sat_installed(): rpms = InstalledRpms(context_wrap(no_sat)) with pytest.raises(SkipComponent) as sc: SatelliteVersion(rpms, None) assert "Not a Satellite machine" in str(sc) rpms = InstalledRpms(context_wrap(installed_rpms_611x_confilct)) with pytest.raises(SkipComponent) as sc: SatelliteVersion(rpms, None) assert "unable to determine Satellite version" in str(sc)
def test_doc_examples(): sat_rpms = InstalledRpms(context_wrap(installed_rpms_62)) cap_rpms = InstalledRpms(context_wrap(installed_rpms_62_cap)) env = { 'sat_ver': SatelliteVersion(sat_rpms, None), 'cap_ver': CapsuleVersion(cap_rpms, None), } failed, total = doctest.testmod(satellite_version, globs=env) assert failed == 0
def test_get_sat60(): rpms = InstalledRpms(context_wrap(installed_rpms_60)) expected = ('6.0.8', '6.0.8', None, 6, 0) result = SatelliteVersion(rpms, None) assert result.major == expected[-2] assert result.minor == expected[-1] assert result.full == expected[0] assert result.release == expected[2] assert result.version == expected[1]
def test_get_sat62_version(): rpms = InstalledRpms(context_wrap(installed_rpms_62)) expected = ('satellite-6.2.0.11-1.el7sat', '6.2.0.11', '1.el7sat', 6, 2) result = SatelliteVersion(rpms, None) assert result.major == expected[-2] assert result.minor == expected[-1] assert result.full == expected[0] assert result.version == expected[1] assert result.release == expected[2]
def test_get_sat61_version_both(): rpms = InstalledRpms(context_wrap(installed_rpms_61)) sat = Satellite6Version(context_wrap(satellite_version_rb)) expected = ('6.1.3', '6.1.3', None, 6, 1) result = SatelliteVersion(rpms, sat) assert result.major == expected[-2] assert result.minor == expected[-1] assert result.full == expected[0] assert result.release == expected[2] assert result.version == expected[1]
def test_get_sat5_version(): rpms = InstalledRpms(context_wrap(installed_rpms_5)) expected = ('satellite-schema-5.6.0.10-1.el6sat', '5.6.0.10', '1.el6sat', 5, 6) result = SatelliteVersion(rpms, None) assert result.major == expected[-2] assert result.minor == expected[-1] assert result.full == expected[0] assert result.release == expected[2] assert result.version == expected[1]
def test_both_pkgs(): rpms = InstalledRpms(context_wrap(BOTH_CAPSULE_AND_FOREMAN_PKGS_INSTALLED)) capsule = CapsuleVersion(rpms, None) assert capsule is not None assert capsule.version == '6.9.0.11' both_satellite_and_capsule_rpms = InstalledRpms(context_wrap(BOTH_CAPSULE_AND_SATELLITE_PKGS_INSTALLED)) satellite = SatelliteVersion(both_satellite_and_capsule_rpms, None) assert satellite is not None assert satellite.version == '6.9.0.11' with pytest.raises(SkipComponent): CapsuleVersion(both_satellite_and_capsule_rpms, satellite)
def test_get_sat61_version(): rpms = InstalledRpms(context_wrap(installed_rpms_61)) expected = ('6.1.7', '6.1.7', None, 6, 1) result = SatelliteVersion(None, rpms) assert result.major == expected[-2] assert result.minor == expected[-1] assert result.full == expected[0] assert result.release == expected[2] assert result.version == expected[1] sat = Satellite6Version(context_wrap(satellite_version_rb)) expected = ('6.1.3', '6.1.3', None, 6, 1) result = SatelliteVersion(sat, None) assert result.major == expected[-2] assert result.minor == expected[-1] assert result.full == expected[0] assert result.release == expected[2] assert result.version == expected[1] rpms = InstalledRpms(context_wrap(installed_rpms_6110)) expected = ('6.1.10', '6.1.10', None, 6, 1) result = SatelliteVersion(None, rpms) assert result.major == expected[-2] assert result.minor == expected[-1] assert result.full == expected[0] assert result.release == expected[2] assert result.version == expected[1] rpms = InstalledRpms(context_wrap(installed_rpms_6111)) expected = ('6.1.11', '6.1.11', None, 6, 1) result = SatelliteVersion(None, rpms) assert result.major == expected[-2] assert result.minor == expected[-1] assert result.full == expected[0] assert result.release == expected[2] assert result.version == expected[1]
def test_none(): with pytest.raises(SkipComponent) as sc: SatelliteVersion(None, None) assert "No RPMs list, unable to determine Satellite version" in str(sc)