def test_package_install(self): '''package installation/removal This will just do some very shallow tests if this is not run as root. ''' # test package; this is most likely not installed yet (test suite will # abort if it is) test_package = 'lrzsz' # use real OSLib here, not test suite's fake implementation o = OSLib() self.assertRaises(ValueError, o.install_package, 'nonexisting', None) # this should not crash, since it is not installed o.remove_package('nonexisting', None) if os.getuid() != 0: return self.failIf(o.package_installed(test_package), '%s must not be installed for this test' % test_package) # test without progress reporting o.install_package(test_package, None) self.assert_(o.package_installed(test_package)) o.remove_package(test_package, None) self.failIf(o.package_installed(test_package))
def test_package_query(self): '''package querying''' # use real OSLib here, not test suite's fake implementation o = OSLib() self.assertEqual(o.package_installed('coreutils'), True) self.assertEqual(o.package_installed('nonexisting'), False) self.assertEqual(o.is_package_free('coreutils'), True) self.assertRaises(ValueError, o.is_package_free, 'nonexisting') (short, long) = o.package_description('bash') self.assert_('sh' in short.lower()) self.assert_('shell' in long) self.failIf('size:' in long) self.assertRaises(ValueError, o.package_description, 'nonexisting') self.assertRaises(ValueError, o.package_files, 'nonexisting') coreutils_files = o.package_files('coreutils') self.assert_('/bin/cat' in coreutils_files) self.assert_('/bin/tail' in coreutils_files or '/usr/bin/tail' in coreutils_files)