Back to index

apport  2.4
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
test_backend_apt_dpkg.T Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_check_files_md5
def test_get_version
def test_get_available_version
def test_get_dependencies
def test_get_source
def test_get_package_origin
def test_is_distro_package
def test_get_architecture
def test_get_files
def test_get_file_package
def test_get_file_package_uninstalled
def test_get_file_package_diversion
def test_get_modified_conffiles
def test_get_system_architecture
def test_get_library_paths
def test_compare_versions
def test_enabled
def test_get_kernel_pacakge
def test_package_name_glob
def test_install_packages_versioned
def test_install_packages_unversioned
def test_install_packages_system
def test_install_packages_error
def test_install_packages_permanent_sandbox
def test_install_packages_permanent_sandbox_repack
def test_get_source_tree_sandbox

Public Attributes

 orig_conf
 workdir
 has_dbgsym
 cachedir
 rootdir
 configdir

Static Public Attributes

int stderr = 0

Private Member Functions

def _setup_foonux_config

Detailed Description

Definition at line 32 of file test_backend_apt_dpkg.py.


Member Function Documentation

Set up directories and configuration for install_packages()

Definition at line 578 of file test_backend_apt_dpkg.py.

00578 
00579     def _setup_foonux_config(self):
00580         '''Set up directories and configuration for install_packages()'''
00581 
00582         self.cachedir = os.path.join(self.workdir, 'cache')
00583         self.rootdir = os.path.join(self.workdir, 'root')
00584         self.configdir = os.path.join(self.workdir, 'config')
00585         os.mkdir(self.cachedir)
00586         os.mkdir(self.rootdir)
00587         os.mkdir(self.configdir)
00588         os.mkdir(os.path.join(self.configdir, 'Foonux 1.2'))
00589         with open(os.path.join(self.configdir, 'Foonux 1.2', 'sources.list'), 'w') as f:
00590             f.write('deb http://archive.ubuntu.com/ubuntu/ lucid main\n')
00591             f.write('deb-src http://archive.ubuntu.com/ubuntu/ lucid main\n')
00592             f.write('deb http://ddebs.ubuntu.com/ lucid main\n')
00593 
00594 # only execute if dpkg is available
try:

Here is the caller graph for this function:

Definition at line 33 of file test_backend_apt_dpkg.py.

00033 
00034     def setUp(self):
00035         # save and restore configuration file
00036         self.orig_conf = impl.configuration
00037         self.workdir = tempfile.mkdtemp()
00038 
00039         try:
00040             impl.get_available_version('coreutils-dbgsym')
00041             self.has_dbgsym = True
00042         except ValueError:
00043             self.has_dbgsym = False

Definition at line 44 of file test_backend_apt_dpkg.py.

00044 
00045     def tearDown(self):
00046         impl.configuration = self.orig_conf
00047         shutil.rmtree(self.workdir)

_check_files_md5().

Definition at line 48 of file test_backend_apt_dpkg.py.

00048 
00049     def test_check_files_md5(self):
00050         '''_check_files_md5().'''
00051 
00052         td = tempfile.mkdtemp()
00053         try:
00054             f1 = os.path.join(td, 'test 1.txt')
00055             f2 = os.path.join(td, 'test:2.txt')
00056             sumfile = os.path.join(td, 'sums.txt')
00057             with open(f1, 'w') as fd:
00058                 fd.write('Some stuff')
00059             with open(f2, 'w') as fd:
00060                 fd.write('More stuff')
00061             # use one relative and one absolute path in checksums file
00062             with open(sumfile, 'wb') as fd:
00063                 fd.write(b'2e41290da2fa3f68bd3313174467e3b5  ' + f1[1:].encode() + b'\n')
00064                 fd.write(b'f6423dfbc4faf022e58b4d3f5ff71a70  ' + f2.encode() + b'\n')
00065                 fd.write(b'deadbeef000001111110000011110000  /bin/\xc3\xa4')
00066             self.assertEqual(impl._check_files_md5(sumfile), [], 'correct md5sums')
00067 
00068             with open(f1, 'w') as fd:
00069                 fd.write('Some stuff!')
00070             self.assertEqual(impl._check_files_md5(sumfile), [f1[1:]], 'file 1 wrong')
00071             with open(f2, 'w') as fd:
00072                 fd.write('More stuff!')
00073             self.assertEqual(impl._check_files_md5(sumfile), [f1[1:], f2], 'files 1 and 2 wrong')
00074             with open(f1, 'w') as fd:
00075                 fd.write('Some stuff')
00076             self.assertEqual(impl._check_files_md5(sumfile), [f2], 'file 2 wrong')
00077 
00078             # check using a direct md5 list as argument
00079             with open(sumfile, 'rb') as fd:
00080                 self.assertEqual(impl._check_files_md5(fd.read()),
00081                                  [f2], 'file 2 wrong')
00082 
00083         finally:
00084             shutil.rmtree(td)

compare_versions.

Definition at line 274 of file test_backend_apt_dpkg.py.

00274 
00275     def test_compare_versions(self):
00276         '''compare_versions.'''
00277 
00278         self.assertEqual(impl.compare_versions('1', '2'), -1)
00279         self.assertEqual(impl.compare_versions('1.0-1ubuntu1', '1.0-1ubuntu2'), -1)
00280         self.assertEqual(impl.compare_versions('1.0-1ubuntu1', '1.0-1ubuntu1'), 0)
00281         self.assertEqual(impl.compare_versions('1.0-1ubuntu2', '1.0-1ubuntu1'), 1)
00282         self.assertEqual(impl.compare_versions('1:1.0-1', '2007-2'), 1)
00283         self.assertEqual(impl.compare_versions('1:1.0-1~1', '1:1.0-1'), -1)

enabled.

Definition at line 284 of file test_backend_apt_dpkg.py.

00284 
00285     def test_enabled(self):
00286         '''enabled.'''
00287 
00288         impl.configuration = '/nonexisting'
00289         self.assertEqual(impl.enabled(), True)
00290 
00291         f = tempfile.NamedTemporaryFile()
00292         impl.configuration = f.name
00293         f.write('# configuration file\nenabled = 1'.encode())
00294         f.flush()
00295         self.assertEqual(impl.enabled(), True)
00296         f.close()
00297 
00298         f = tempfile.NamedTemporaryFile()
00299         impl.configuration = f.name
00300         f.write('# configuration file\n  enabled =0  '.encode())
00301         f.flush()
00302         self.assertEqual(impl.enabled(), False)
00303         f.close()
00304 
00305         f = tempfile.NamedTemporaryFile()
00306         impl.configuration = f.name
00307         f.write('# configuration file\nnothing here'.encode())
00308         f.flush()
00309         self.assertEqual(impl.enabled(), True)
00310         f.close()

get_architecture().

Definition at line 148 of file test_backend_apt_dpkg.py.

00148 
00149     def test_get_architecture(self):
00150         '''get_architecture().'''
00151 
00152         self.assertRaises(ValueError, impl.get_architecture, 'nonexisting')
00153         # just assume that bash uses the native architecture
00154         d = subprocess.Popen(['dpkg', '--print-architecture'],
00155                              stdout=subprocess.PIPE)
00156         system_arch = d.communicate()[0].decode().strip()
00157         assert d.returncode == 0
00158         self.assertEqual(impl.get_architecture('bash'), system_arch)

get_available_version().

Definition at line 92 of file test_backend_apt_dpkg.py.

00092 
00093     def test_get_available_version(self):
00094         '''get_available_version().'''
00095 
00096         self.assertTrue(impl.get_available_version('libc6').startswith('2'))
00097         self.assertRaises(ValueError, impl.get_available_version, 'nonexisting')

get_dependencies().

Definition at line 98 of file test_backend_apt_dpkg.py.

00098 
00099     def test_get_dependencies(self):
00100         '''get_dependencies().'''
00101 
00102         # package with both Depends: and Pre-Depends:
00103         d = impl.get_dependencies('bash')
00104         self.assertTrue(len(d) > 2)
00105         self.assertTrue('libc6' in d)
00106         for dep in d:
00107             self.assertTrue(impl.get_version(dep))
00108 
00109         # Pre-Depends: only
00110         d = impl.get_dependencies('coreutils')
00111         self.assertTrue(len(d) >= 1)
00112         self.assertTrue('libc6' in d)
00113         for dep in d:
00114             self.assertTrue(impl.get_version(dep))
00115 
00116         # Depends: only
00117         d = impl.get_dependencies('libc6')
00118         self.assertTrue(len(d) >= 1)
00119         for dep in d:
00120             self.assertTrue(impl.get_version(dep))

get_file_package() on installed files.

Definition at line 165 of file test_backend_apt_dpkg.py.

00165 
00166     def test_get_file_package(self):
00167         '''get_file_package() on installed files.'''
00168 
00169         self.assertEqual(impl.get_file_package('/bin/bash'), 'bash')
00170         self.assertEqual(impl.get_file_package('/bin/cat'), 'coreutils')
00171         self.assertEqual(impl.get_file_package('/etc/blkid.tab'), 'libblkid1')
00172         self.assertEqual(impl.get_file_package('/nonexisting'), None)

get_file_package() for a diverted file.

Definition at line 233 of file test_backend_apt_dpkg.py.

00233 
00234     def test_get_file_package_diversion(self):
00235         '''get_file_package() for a diverted file.'''
00236 
00237         # pick first diversion we have
00238         p = subprocess.Popen('LC_ALL=C dpkg-divert --list | head -n 1',
00239                              shell=True, stdout=subprocess.PIPE)
00240         out = p.communicate()[0].decode('UTF-8')
00241         assert p.returncode == 0
00242         assert out
00243         fields = out.split()
00244         file = fields[2]
00245         pkg = fields[-1]
00246 
00247         self.assertEqual(impl.get_file_package(file), pkg)

get_file_package() on uninstalled packages.

Definition at line 173 of file test_backend_apt_dpkg.py.

00173 
00174     def test_get_file_package_uninstalled(self):
00175         '''get_file_package() on uninstalled packages.'''
00176 
00177         # determine distro release code name
00178         lsb_release = subprocess.Popen(['lsb_release', '-sc'],
00179                                        stdout=subprocess.PIPE)
00180         release_name = lsb_release.communicate()[0].decode('UTF-8').strip()
00181         assert lsb_release.returncode == 0
00182 
00183         # generate a test Contents.gz
00184         basedir = tempfile.mkdtemp()
00185         try:
00186             mapdir = os.path.join(basedir, 'dists', release_name)
00187             os.makedirs(mapdir)
00188             with gzip.open(os.path.join(mapdir, 'Contents-%s.gz' %
00189                                         impl.get_system_architecture()), 'w') as f:
00190                 f.write(b'''
00191 foo header
00192 FILE                                                    LOCATION
00193 usr/bin/frobnicate                                      foo/frob
00194 usr/bin/frob                                            foo/frob-utils
00195 bo/gu/s                                                 na/mypackage
00196 ''')
00197 
00198             self.assertEqual(impl.get_file_package('usr/bin/frob', False, mapdir), None)
00199             # must not match frob (same file name prefix)
00200             self.assertEqual(impl.get_file_package('usr/bin/frob', True, mapdir), 'frob-utils')
00201             self.assertEqual(impl.get_file_package('/usr/bin/frob', True, mapdir), 'frob-utils')
00202 
00203             # invalid mirror
00204             impl.set_mirror('file:///foo/nonexisting')
00205             self.assertRaises(IOError, impl.get_file_package, 'usr/bin/frob', True)
00206 
00207             # valid mirror, no cache directory
00208             impl.set_mirror('file://' + basedir)
00209             self.assertEqual(impl.get_file_package('usr/bin/frob', True), 'frob-utils')
00210             self.assertEqual(impl.get_file_package('/usr/bin/frob', True), 'frob-utils')
00211 
00212             # valid mirror, test caching
00213             cache_dir = os.path.join(basedir, 'cache')
00214             os.mkdir(cache_dir)
00215             self.assertEqual(impl.get_file_package('usr/bin/frob', True, cache_dir), 'frob-utils')
00216             self.assertEqual(len(os.listdir(cache_dir)), 1)
00217             cache_file = os.listdir(cache_dir)[0]
00218             self.assertTrue(cache_file.startswith('Contents-'))
00219             self.assertEqual(impl.get_file_package('/bo/gu/s', True, cache_dir), 'mypackage')
00220 
00221             # valid cache, should not need to access the mirror
00222             impl.set_mirror('file:///foo/nonexisting')
00223             self.assertEqual(impl.get_file_package('/bo/gu/s', True, cache_dir), 'mypackage')
00224 
00225             # outdated cache, must refresh the cache and hit the invalid
00226             # mirror
00227             now = int(time.time())
00228             os.utime(os.path.join(cache_dir, cache_file), (now, now - 90000))
00229 
00230             self.assertRaises(IOError, impl.get_file_package, '/bo/gu/s', True, cache_dir)
00231         finally:
00232             shutil.rmtree(basedir)

get_files().

Definition at line 159 of file test_backend_apt_dpkg.py.

00159 
00160     def test_get_files(self):
00161         '''get_files().'''
00162 
00163         self.assertRaises(ValueError, impl.get_files, 'nonexisting')
00164         self.assertTrue('/bin/bash' in impl.get_files('bash'))

get_kernel_package().

Definition at line 311 of file test_backend_apt_dpkg.py.

00311 
00312     def test_get_kernel_pacakge(self):
00313         '''get_kernel_package().'''
00314 
00315         self.assertTrue('linux' in impl.get_kernel_package())

get_library_paths().

Definition at line 264 of file test_backend_apt_dpkg.py.

00264 
00265     def test_get_library_paths(self):
00266         '''get_library_paths().'''
00267 
00268         paths = impl.get_library_paths()
00269         # must be nonempty without line breaks
00270         self.assertNotEqual(paths, '')
00271         self.assertTrue(':' in paths)
00272         self.assertTrue('/lib' in paths)
00273         self.assertTrue('\n' not in paths)

get_modified_conffiles()

Definition at line 248 of file test_backend_apt_dpkg.py.

00248 
00249     def test_get_modified_conffiles(self):
00250         '''get_modified_conffiles()'''
00251 
00252         # very shallow
00253         self.assertEqual(type(impl.get_modified_conffiles('bash')), type({}))
00254         self.assertEqual(type(impl.get_modified_conffiles('apport')), type({}))
00255         self.assertEqual(type(impl.get_modified_conffiles('nonexisting')), type({}))

get_package_origin().

Definition at line 128 of file test_backend_apt_dpkg.py.

00128 
00129     def test_get_package_origin(self):
00130         '''get_package_origin().'''
00131 
00132         # determine distro name
00133         distro = subprocess.check_output(['lsb_release', '-si']).decode('UTF-8').strip()
00134 
00135         self.assertRaises(ValueError, impl.get_package_origin, 'nonexisting')
00136         # this assumes that this package is not installed
00137         self.assertRaises(ValueError, impl.get_package_origin, 'robocode-doc')
00138         # this assumes that bash is native
00139         self.assertEqual(impl.get_package_origin('bash'), distro)
00140         # no non-native test here, hard to come up with a generic one

get_source().

Definition at line 121 of file test_backend_apt_dpkg.py.

00121 
00122     def test_get_source(self):
00123         '''get_source().'''
00124 
00125         self.assertRaises(ValueError, impl.get_source, 'nonexisting')
00126         self.assertEqual(impl.get_source('bash'), 'bash')
00127         self.assertTrue('glibc' in impl.get_source('libc6'))

Definition at line 565 of file test_backend_apt_dpkg.py.

00565 
00566     def test_get_source_tree_sandbox(self):
00567         self._setup_foonux_config()
00568         out_dir = os.path.join(self.workdir, 'out')
00569         os.mkdir(out_dir)
00570         impl._build_apt_sandbox(self.rootdir, os.path.join(self.configdir, 'Foonux 1.2', 'sources.list'))
00571         res = impl.get_source_tree('base-files', out_dir, sandbox=self.rootdir,
00572                                    apt_update=True)
00573         self.assertTrue(os.path.isdir(os.path.join(res, 'debian')))
00574         # this needs to be updated when the release in _setup_foonux_config
00575         # changes
00576         self.assertTrue(res.endswith('/base-files-5.0.0ubuntu20'),
00577                         'unexpected version: ' + res.split('/')[-1])

Here is the call graph for this function:

get_system_architecture().

Definition at line 256 of file test_backend_apt_dpkg.py.

00256 
00257     def test_get_system_architecture(self):
00258         '''get_system_architecture().'''
00259 
00260         arch = impl.get_system_architecture()
00261         # must be nonempty without line breaks
00262         self.assertNotEqual(arch, '')
00263         self.assertTrue('\n' not in arch)

get_version().

Definition at line 85 of file test_backend_apt_dpkg.py.

00085 
00086     def test_get_version(self):
00087         '''get_version().'''
00088 
00089         self.assertTrue(impl.get_version('libc6').startswith('2'))
00090         self.assertRaises(ValueError, impl.get_version, 'nonexisting')
00091         self.assertRaises(ValueError, impl.get_version, 'wukrainian')

install_packages() with errors

Definition at line 475 of file test_backend_apt_dpkg.py.

00475 
00476     def test_install_packages_error(self):
00477         '''install_packages() with errors'''
00478 
00479         # sources.list with invalid format
00480         self._setup_foonux_config()
00481         with open(os.path.join(self.configdir, 'Foonux 1.2', 'sources.list'), 'w') as f:
00482             f.write('bogus format')
00483 
00484         try:
00485             impl.install_packages(self.rootdir, self.configdir, 'Foonux 1.2',
00486                                   [('tzdata', None)], False, self.cachedir)
00487             self.fail('install_packages() unexpectedly succeeded with broken sources.list')
00488         except SystemError as e:
00489             self.assertTrue('bogus' in str(e))
00490             self.assertFalse('Exception' in str(e))
00491 
00492         # sources.list with wrong server
00493         with open(os.path.join(self.configdir, 'Foonux 1.2', 'sources.list'), 'w') as f:
00494             f.write('deb http://archive.ubuntu.com/nosuchdistro/ lucid main\n')
00495 
00496         try:
00497             impl.install_packages(self.rootdir, self.configdir, 'Foonux 1.2',
00498                                   [('tzdata', None)], False, self.cachedir)
00499             self.fail('install_packages() unexpectedly succeeded with broken server URL')
00500         except SystemError as e:
00501             self.assertTrue('nosuchdistro' in str(e), str(e))
00502             self.assertTrue('index files failed to download' in str(e))

Here is the call graph for this function:

install_packages() with a permanent sandbox

Definition at line 504 of file test_backend_apt_dpkg.py.

00504 
00505     def test_install_packages_permanent_sandbox(self):
00506         '''install_packages() with a permanent sandbox'''
00507 
00508         self._setup_foonux_config()
00509         zonetab = os.path.join(self.rootdir, 'usr/share/zoneinfo/zone.tab')
00510 
00511         impl.install_packages(self.rootdir, self.configdir, 'Foonux 1.2',
00512                               [('tzdata', None)], False, self.cachedir, permanent_rootdir=True)
00513 
00514         # This will now be using a Cache with our rootdir.
00515         archives = apt_pkg.config.find_dir('Dir::Cache::archives')
00516         tzdata = glob.glob(os.path.join(archives, 'tzdata*.deb'))
00517         if not tzdata:
00518             self.fail('tzdata was not downloaded')
00519         tzdata_written = os.path.getctime(tzdata[0])
00520         zonetab_written = os.path.getctime(zonetab)
00521 
00522         impl.install_packages(self.rootdir, self.configdir, 'Foonux 1.2',
00523                               [('coreutils', None), ('tzdata', None)], False, self.cachedir,
00524                               permanent_rootdir=True)
00525 
00526         if not glob.glob(os.path.join(archives, 'coreutils*.deb')):
00527             self.fail('coreutils was not downloaded.')
00528             self.assertEqual(os.path.getctime(tzdata[0]), tzdata_written,
00529                              'tzdata downloaded twice.')
00530             self.assertEqual(zonetab_written, os.path.getctime(zonetab),
00531                              'zonetab written twice.')
00532             self.assertTrue(os.path.exists(
00533                 os.path.join(self.rootdir, 'usr/bin/stat')))
00534 
00535         # Prevent packages from downloading.
00536         apt_pkg.config.set('Acquire::http::Proxy', 'http://nonexistent')
00537         self.assertRaises(SystemExit, impl.install_packages, self.rootdir,
00538                           self.configdir, 'Foonux 1.2', [('libc6', None)], False,
00539                           self.cachedir, permanent_rootdir=True)
00540         # These packages exist, so attempting to install them should not fail.
00541         impl.install_packages(self.rootdir, self.configdir, 'Foonux 1.2',
00542                               [('coreutils', None), ('tzdata', None)], False, self.cachedir,
00543                               permanent_rootdir=True)
00544         apt_pkg.config.set('Acquire::http::Proxy', '')

Here is the call graph for this function:

Definition at line 546 of file test_backend_apt_dpkg.py.

00546 
00547     def test_install_packages_permanent_sandbox_repack(self):
00548         self._setup_foonux_config()
00549         apache_bin_path = os.path.join(self.rootdir, 'usr/sbin/apache2')
00550         impl.install_packages(self.rootdir, self.configdir, 'Foonux 1.2',
00551                               [('apache2-mpm-worker', None)], False, self.cachedir,
00552                               permanent_rootdir=True)
00553         self.assertTrue(os.readlink(apache_bin_path).endswith('mpm-worker/apache2'))
00554         impl.install_packages(self.rootdir, self.configdir, 'Foonux 1.2',
00555                               [('apache2-mpm-event', None)], False, self.cachedir,
00556                               permanent_rootdir=True)
00557         self.assertTrue(os.readlink(apache_bin_path).endswith('mpm-event/apache2'),
00558                         'should have installed mpm-event, but have mpm-worker.')
00559         impl.install_packages(self.rootdir, self.configdir, 'Foonux 1.2',
00560                               [('apache2-mpm-worker', None)], False, self.cachedir,
00561                               permanent_rootdir=True)
00562         self.assertTrue(os.readlink(apache_bin_path).endswith('mpm-worker/apache2'),
00563                         'should have installed mpm-worker, but have mpm-event.')

Here is the call graph for this function:

install_packages() with system configuration

Definition at line 430 of file test_backend_apt_dpkg.py.

00430 
00431     def test_install_packages_system(self):
00432         '''install_packages() with system configuration'''
00433 
00434         # trigger an unrelated package query here to get the cache set up,
00435         # reproducing an install failure when the internal caches are not
00436         # reset properly
00437         impl.get_version('dash')
00438 
00439         self._setup_foonux_config()
00440         result = impl.install_packages(self.rootdir, None, None,
00441                                        [('coreutils', impl.get_version('coreutils')),
00442                                         ('tzdata', '1.1'),
00443                                        ], False, self.cachedir)
00444 
00445         self.assertTrue(os.path.exists(os.path.join(self.rootdir,
00446                                                     'usr/bin/stat')))
00447         self.assertTrue(os.path.exists(os.path.join(self.rootdir,
00448                                                     'usr/share/zoneinfo/zone.tab')))
00449 
00450         # complains about obsolete packages
00451         self.assertEqual(len(result.splitlines()), 1)
00452         self.assertTrue('tzdata' in result)
00453         self.assertTrue('1.1' in result)
00454 
00455         # caches packages
00456         cache = os.listdir(os.path.join(self.cachedir, 'system', 'apt',
00457                                         'var', 'cache', 'apt', 'archives'))
00458         cache_names = [p.split('_')[0] for p in cache]
00459         self.assertTrue('coreutils' in cache_names)
00460         self.assertEqual('coreutils-dbgsym' in cache_names, self.has_dbgsym)
00461         self.assertTrue('tzdata' in cache_names)
00462 
00463         # works with relative paths and existing cache
00464         os.unlink(os.path.join(self.rootdir, 'usr/bin/stat'))
00465         orig_cwd = os.getcwd()
00466         try:
00467             os.chdir(self.workdir)
00468             impl.install_packages('root', None, None,
00469                                   [('coreutils', None)], False, 'cache')
00470         finally:
00471             os.chdir(orig_cwd)
00472             self.assertTrue(os.path.exists(os.path.join(self.rootdir,
00473                                                         'usr/bin/stat')))

Here is the call graph for this function:

install_packages() without versions and no cache

Definition at line 405 of file test_backend_apt_dpkg.py.

00405 
00406     def test_install_packages_unversioned(self):
00407         '''install_packages() without versions and no cache'''
00408 
00409         self._setup_foonux_config()
00410         impl.install_packages(self.rootdir, self.configdir, 'Foonux 1.2',
00411                               [('coreutils', None),
00412                                ('tzdata', None),
00413                               ], False, None)
00414 
00415         self.assertTrue(os.path.exists(os.path.join(self.rootdir,
00416                                                     'usr/bin/stat')))
00417         self.assertTrue(os.path.exists(os.path.join(self.rootdir,
00418                                                     'usr/lib/debug/usr/bin/stat')))
00419         self.assertTrue(os.path.exists(os.path.join(self.rootdir,
00420                                                     'usr/share/zoneinfo/zone.tab')))
00421 
00422         # does not clobber config dir
00423         self.assertEqual(os.listdir(self.configdir), ['Foonux 1.2'])
00424         self.assertEqual(os.listdir(os.path.join(self.configdir, 'Foonux 1.2')),
00425                          ['sources.list'])
00426 
00427         # no cache
00428         self.assertEqual(os.listdir(self.cachedir), [])

Here is the call graph for this function:

install_packages() with versions and with cache

Definition at line 325 of file test_backend_apt_dpkg.py.

00325 
00326     def test_install_packages_versioned(self):
00327         '''install_packages() with versions and with cache'''
00328 
00329         self._setup_foonux_config()
00330         impl.install_packages(self.rootdir, self.configdir, 'Foonux 1.2',
00331                               [('coreutils', '7.4-2ubuntu2'),
00332                                ('libc6', '2.11.1-0ubuntu7'),
00333                                ('tzdata', '2010i-1'),
00334                               ], False, self.cachedir)
00335 
00336         self.assertTrue(os.path.exists(os.path.join(self.rootdir,
00337                                                     'usr/bin/stat')))
00338         self.assertTrue(os.path.exists(os.path.join(self.rootdir,
00339                                                     'usr/lib/debug/usr/bin/stat')))
00340         self.assertTrue(os.path.exists(os.path.join(self.rootdir,
00341                                                     'usr/share/zoneinfo/zone.tab')))
00342         self.assertTrue(os.path.exists(os.path.join(self.rootdir,
00343                                                     'usr/share/doc/libc6/copyright')))
00344 
00345         # does not clobber config dir
00346         self.assertEqual(os.listdir(self.configdir), ['Foonux 1.2'])
00347         self.assertEqual(os.listdir(os.path.join(self.configdir, 'Foonux 1.2')),
00348                          ['sources.list'])
00349 
00350         # caches packages
00351         cache = os.listdir(os.path.join(self.cachedir, 'Foonux 1.2', 'apt',
00352                                         'var', 'cache', 'apt', 'archives'))
00353         cache_names = [p.split('_')[0] for p in cache]
00354         self.assertTrue('coreutils' in cache_names)
00355         self.assertTrue('coreutils-dbgsym' in cache_names)
00356         self.assertTrue('tzdata' in cache_names)
00357         self.assertTrue('libc6' in cache_names)
00358         self.assertTrue('libc6-dbg' in cache_names)
00359 
00360         # installs cached packages
00361         os.unlink(os.path.join(self.rootdir, 'usr/bin/stat'))
00362         impl.install_packages(self.rootdir, self.configdir, 'Foonux 1.2',
00363                               [('coreutils', '7.4-2ubuntu2'),
00364                               ], False, self.cachedir)
00365         self.assertTrue(os.path.exists(
00366             os.path.join(self.rootdir, 'usr/bin/stat')))
00367 
00368         # complains about obsolete packages
00369         result = impl.install_packages(self.rootdir, self.configdir,
00370                                        'Foonux 1.2', [('gnome-common', '1.1')])
00371         self.assertEqual(len(result.splitlines()), 1)
00372         self.assertTrue('gnome-common' in result)
00373         self.assertTrue('1.1' in result)
00374         # ... but installs the current version anyway
00375         self.assertTrue(os.path.exists(
00376             os.path.join(self.rootdir, 'usr/bin/gnome-autogen.sh')))
00377 
00378         # does not crash on nonexisting packages
00379         result = impl.install_packages(self.rootdir, self.configdir,
00380                                        'Foonux 1.2', [('buggerbogger', None)])
00381         self.assertEqual(len(result.splitlines()), 1)
00382         self.assertTrue('buggerbogger' in result)
00383         self.assertTrue('not exist' in result)
00384 
00385         # can interleave with other operations
00386         dpkg = subprocess.Popen(['dpkg-query', '-Wf${Version}', 'dash'],
00387                                 stdout=subprocess.PIPE)
00388         coreutils_version = dpkg.communicate()[0].decode()
00389         self.assertEqual(dpkg.returncode, 0)
00390 
00391         self.assertEqual(impl.get_version('dash'), coreutils_version)
00392         self.assertRaises(ValueError, impl.get_available_version, 'buggerbogger')
00393 
00394         # still installs packages after above operations
00395         os.unlink(os.path.join(self.rootdir, 'usr/bin/stat'))
00396         impl.install_packages(self.rootdir, self.configdir, 'Foonux 1.2',
00397                               [('coreutils', '7.4-2ubuntu2'),
00398                                ('dpkg', None),
00399                               ], False, self.cachedir)
00400         self.assertTrue(os.path.exists(os.path.join(self.rootdir,
00401                                                     'usr/bin/stat')))
00402         self.assertTrue(os.path.exists(os.path.join(self.rootdir,
00403                                                     'usr/bin/dpkg')))

Here is the call graph for this function:

is_distro_package().

Definition at line 141 of file test_backend_apt_dpkg.py.

00141 
00142     def test_is_distro_package(self):
00143         '''is_distro_package().'''
00144 
00145         self.assertRaises(ValueError, impl.is_distro_package, 'nonexisting')
00146         self.assertTrue(impl.is_distro_package('bash'))
00147         # no False test here, hard to come up with a generic one

package_name_glob().

Definition at line 316 of file test_backend_apt_dpkg.py.

00316 
00317     def test_package_name_glob(self):
00318         '''package_name_glob().'''
00319 
00320         self.assertTrue(len(impl.package_name_glob('a*')) > 5)
00321         self.assertTrue('bash' in impl.package_name_glob('ba*h'))
00322         self.assertEqual(impl.package_name_glob('bash'), ['bash'])
00323         self.assertEqual(impl.package_name_glob('xzywef*'), [])

Here is the call graph for this function:


Member Data Documentation

Definition at line 581 of file test_backend_apt_dpkg.py.

Definition at line 583 of file test_backend_apt_dpkg.py.

Definition at line 40 of file test_backend_apt_dpkg.py.

Definition at line 35 of file test_backend_apt_dpkg.py.

Definition at line 582 of file test_backend_apt_dpkg.py.

Definition at line 596 of file test_backend_apt_dpkg.py.

Definition at line 36 of file test_backend_apt_dpkg.py.


The documentation for this class was generated from the following file: