Beispiel #1
0
 def test_common_dct_override(self, get_host_sat_version, common_versions_data):
     """Check common is overridden by version dct """
     get_host_sat_version.return_value = '6.1'
     common_versions_data.sat_dep_values = host_info.SatVersionDependentValues(
         {"6.1": self.rpms_61}, {"6.2": self.rpms_62}, common={'missing_version': 'fallback'}
     )
     assert 'fallback' == common_versions_data.sat_dep_values['missing_version']
     common_versions_data.sat_dep_values = host_info.SatVersionDependentValues(
         {"6.1": {'missing_version': 'override'}}, common={'missing_version': 'fallback'}
     )
     assert 'override' == common_versions_data.sat_dep_values['missing_version']
     common_versions_data.sat_dep_values = host_info.SatVersionDependentValues(
         {"6.1": self.rpms_61}, common={'missing_version': 'fallback'}
     )
     assert 'fallback' == common_versions_data.sat_dep_values['missing_version']
Beispiel #2
0
    def dep_versions_data(self):
        """Set up version dependent values for all test"""

        versions = AttrDict({
            'd_6_1':
            self.rpms_61,
            'd_6_2':
            self.rpms_62,
            'sat_dep_values':
            host_info.SatVersionDependentValues({"6.1": self.rpms_61},
                                                {"6.2": self.rpms_62}),
        })
        yield versions

        host_info.get_host_sat_version.cache_clear()
Beispiel #3
0
    def test_common_dct(self, get_host_sat_version, common_versions_data):
        """Check common dct handle missing keys"""
        get_host_sat_version.return_value = '6.1'
        assert common_versions_data.d_6_1['id'] == common_versions_data.sat_dep_values['id']
        assert get_host_sat_version.called

        get_host_sat_version.return_value = '6.2'
        assert common_versions_data.d_6_2['id'] == common_versions_data.sat_dep_values['id']

        with pytest.raises(KeyError):
            common_versions_data.sat_dep_values['missing_version']
        common_versions_data.sat_dep_values = host_info.SatVersionDependentValues(
            common={'missing_version': 'fallback'}
        )
        # no keyerror with it added to common
        assert 'fallback' == common_versions_data.sat_dep_values['missing_version']
Beispiel #4
0
 def setUp(self):
     """Setup sat_version_dependent with common dict"""
     super(SatVersionDepCommonValuesTestCase, self).setUp()
     self.common = {}
     self.sat_dep_values = host_info.SatVersionDependentValues(
         {u"6.1": self.dct_6_1}, {u"6.2": self.dct_6_2}, common=self.common)
Beispiel #5
0
 def setUp(self):
     """Set up version dependent values for all test"""
     self.dct_6_1 = {'id': 'rhel-7-server-satellite-tools-6.1-rpms'}
     self.dct_6_2 = {'id': 'rhel-7-server-satellite-tools-6.2-rpms'}
     self.sat_dep_values = host_info.SatVersionDependentValues(
         {u"6.1": self.dct_6_1}, {u"6.2": self.dct_6_2})
Beispiel #6
0
 def common_versions_data(self, dep_versions_data):
     dep_versions_data.common = {}
     dep_versions_data.sat_dep_values = host_info.SatVersionDependentValues(
         {"6.1": dep_versions_data.d_6_1}, {"6.2": dep_versions_data.d_6_2},
         common={})
     return dep_versions_data