Back to index

apport  2.4
test_backend_rpm.py
Go to the documentation of this file.
00001 import unittest, imp, subprocess, sys, os
00002 
00003 try:
00004     if os.environ.get('APPORT_TEST_LOCAL'):
00005         impl = imp.load_source('', 'backends/packaging_rpm.py').impl
00006     else:
00007         from apport.packaging_impl import impl
00008 except ImportError:
00009     print('%s: Skipping, rpm module not available' % sys.argv[0])
00010     sys.exit(0)
00011 
00012 
00013 class T(unittest.TestCase):
00014 
00015     def test_get_dependencies(self):
00016         '''get_dependencies().'''
00017 
00018         deps = impl.get_dependencies('bash')
00019         self.assertNotEqual(deps, [])
00020 
00021     def test_get_header(self):
00022         '''_get_header().'''
00023 
00024         hdr = impl._get_header('alsa-utils')
00025         self.assertEqual(hdr['n'], 'alsa-utils')
00026 
00027     def test_get_headers_by_tag(self):
00028         '''_get_headers_by_tag().'''
00029 
00030         headersByTag = impl._get_headers_by_tag('basenames', '/bin/bash')
00031         self.assertEqual(len(headersByTag), 1)
00032         self.assertTrue(headersByTag[0]['n'].startswith('bash'))
00033 
00034     def test_get_system_architecture(self):
00035         '''get_system_architecture().'''
00036 
00037         arch = impl.get_system_architecture()
00038         # must be nonempty without line breaks
00039         self.assertNotEqual(arch, '')
00040         self.assertTrue('\n' not in arch)
00041 
00042     def test_get_version(self):
00043         '''get_version().'''
00044 
00045         ver = impl.get_version('bash')
00046         self.assertNotEqual(ver, None)
00047         ver = impl.get_version('alsa-utils')
00048         self.assertNotEqual(ver, None)
00049 
00050 
00051 # only execute if rpm is available
00052 try:
00053     if subprocess.call(['rpm', '--help'], stdout=subprocess.PIPE,
00054                        stderr=subprocess.PIPE) == 0:
00055         unittest.main()
00056 except OSError:
00057     print('%s: Skipping, rpm not available' % sys.argv[0])