1# -*- coding: utf-8 -*- 2 3# Copyright (C) 2012-2018 Red Hat, Inc. 4# 5# This copyrighted material is made available to anyone wishing to use, 6# modify, copy, or redistribute it subject to the terms and conditions of 7# the GNU General Public License v.2, or (at your option) any later version. 8# This program is distributed in the hope that it will be useful, but WITHOUT 9# ANY WARRANTY expressed or implied, including the implied warranties of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 11# Public License for more details. You should have received a copy of the 12# GNU General Public License along with this program; if not, write to the 13# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 14# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the 15# source code or documentation are not subject to the GNU General Public 16# License and may only be used or replicated with the express permission of 17# Red Hat, Inc. 18# 19 20from __future__ import absolute_import 21from __future__ import unicode_literals 22 23import rpm 24 25import tests.support 26 27 28class DistroSyncAll(tests.support.ResultTestCase): 29 30 REPOS = ["distro"] 31 INIT_SACK = True 32 33 def test_distro_sync_all(self): 34 self.base.distro_sync() 35 self.assertIn(rpm.RPMPROB_FILTER_OLDPACKAGE, self.base._rpm_probfilter) 36 packages = tests.support.installed_but(self.sack, "pepper", "librita").run() 37 q = self.sack.query().available().filter(name=["pepper", "librita"]) 38 packages.extend(q) 39 self.assertResult(self.base, packages) 40 41 42class DistroSync(tests.support.ResultTestCase): 43 44 REPOS = ["main", "updates"] 45 BASE_CLI = True 46 47 def test_distro_sync(self): 48 installed = self._get_installed(self.base) 49 original_pkg = list(filter(lambda p: p.name == "hole", installed)) 50 self.base.distro_sync_userlist(('bla', 'hole')) 51 obsolete_pkg = list(filter(lambda p: p.name == "tour", installed)) 52 53 installed2 = self._get_installed(self.base) 54 updated_pkg = list(filter(lambda p: p.name == "hole", installed2)) 55 self.assertLength(updated_pkg, 1) 56 self.assertLength(original_pkg, 1) 57 self.assertLength(updated_pkg, 1) 58 59 # holy pkg upgraded from version 1 to 2 and obsoletes tour 60 self.assertEqual(original_pkg[0].version, "1") 61 self.assertEqual(updated_pkg[0].version, "2") 62 installed.remove(original_pkg[0]) 63 installed.remove(obsolete_pkg[0]) 64 installed2.remove(updated_pkg[0]) 65 self.assertEqual(installed, installed2) 66