def test_set_repo_status_enable_all_disable_all(self, mock_repolib): repolib_instance = mock_repolib.return_value self._inject_mock_valid_consumer('fake_id') repos = [Repo('zoo'), Repo('zebra'), Repo('zip')] items = [('1', '*'), ('0', '*')] self.cc.use_overrides = True self.cc._set_repo_status(repos, repolib_instance, items) expected_overrides = [{ 'contentLabel': 'zebra', 'name': 'enabled', 'value': '0' }, { 'contentLabel': 'zoo', 'name': 'enabled', 'value': '0' }, { 'contentLabel': 'zip', 'name': 'enabled', 'value': '0' }] match_dict_list = Matcher(self.assert_items_equals, expected_overrides) self.cc.cp.setContentOverrides.assert_called_once_with( 'fake_id', match_dict_list) repolib_instance.update.assert_called()
def test_set_repo_status_with_wildcards(self, mock_repolib): repolib_instance = mock_repolib.return_value self._inject_mock_valid_consumer('fake_id') repos = [Repo('zoo'), Repo('zebra'), Repo('zip')] items = ['z*'] self.cc.use_overrides = True self.cc._set_repo_status(repos, repolib_instance, items, False) expected_overrides = [{'contentLabel': i.id, 'name': 'enabled', 'value': '0'} for i in repos] match_dict_list = Matcher(self.assert_items_equals, expected_overrides) self.cc.cp.setContentOverrides.assert_called_once_with('fake_id', match_dict_list) repolib_instance.update.assert_called()
def test_set_repo_status(self, mock_repolib): repolib_instance = mock_repolib.return_value self._inject_mock_valid_consumer('fake_id') repos = [Repo('x'), Repo('y'), Repo('z')] items = ['x', 'y'] self.cc.use_overrides = True self.cc._set_repo_status(repos, repolib_instance, items, False) expected_overrides = [{'contentLabel': i, 'name': 'enabled', 'value': '0'} for i in items] # The list of overrides sent to setContentOverrides is really a set of # dictionaries (since we don't know the order of the overrides). # However, since the dict class is not hashable, we cssert_items_equalsan't actually use # a set. So we need a custom matcher to make sure that the # JSON passed in to setContentOverrides is what we expect. match_dict_list = Matcher(self.assert_items_equals, expected_overrides) self.cc.cp.setContentOverrides.assert_called_once_with('fake_id', match_dict_list) repolib_instance.update.assert_called()