def test_conf(self): base = support.Base() self.assertIsInstance(base.conf.installroot, unicode) # reasonable default self.assertEqual(base.conf.installroot, '/') # assignable dnf.conf.installroot = '/mnt/rootimage'
def setUp(self): conf = dnf.conf.Conf() base = support.Base(conf) base.repos.add(support.MockRepo('main', conf)) base.conf.reposdir = '/dev/null' base.conf.plugins = False base.output = support.MockOutput() repo = base.repos['main'] repo.baseurl = ['http:///dnf-test'] repo.basecachedir = base.conf.cachedir walk = [ ( repo.basecachedir, [os.path.basename(repo._cachedir)], [repo.id + '.solv'], ), (repo._cachedir, ['repodata', 'packages'], ['metalink.xml']), (repo._cachedir + '/repodata', [], ['foo.xml', 'bar.xml.bz2']), (repo._cachedir + '/packages', [], ['foo.rpm']), ] os.walk = self.walk = mock.Mock(return_value=walk) self.base = base self.cli = dnf.cli.cli.Cli(base)
def test_update_not_found(self): base = support.Base() base._sack = support.mock_sack('updates') base._goal = goal = mock.create_autospec(dnf.goal.Goal) with self.assertRaises(dnf.exceptions.MarkingError) as context: base.upgrade('non-existent') self.assertEqual(context.exception.pkg_spec, 'non-existent') self.assertEqual(goal.mock_calls, [])
def test_iter_userinstalled_badfromrepo(self): """Test iter_userinstalled with a package installed from a bad repository.""" base = support.Base() base._sack = support.mock_sack('main') base._priv_yumdb = support.MockYumDB() pkg, = base.sack.query().installed().filter(name='pepper') base._yumdb.get_package(pkg).get = {'reason': 'user', 'from_repo': 'anakonda'}.get iterator = base.iter_userinstalled() self.assertRaises(StopIteration, next, iterator)
def setUp(self): self._base = support.Base() self._base._sack = support.mock_sack('main') self._base._goal = self._goal = mock.create_autospec(dnf.goal.Goal)
def test_instance(self): base = support.Base()
def test_translate_comps_pkg_types(self): base = support.Base() num = base._translate_comps_pkg_types(('mandatory', 'optional')) self.assertEqual(num, 12)