Beispiel #1
0
    def test_bts791577(self):
        # Verify obsolete config files are correctly parsed

        # bonus points for testing also conffiles with spaces in the filename
        pkgstatus = """Conffiles:
 /etc/reportbug.conf 17b8e0850fa74d18b96ce5856321de0d
 /etc/reportbug with spaces.conf feedcafefeedcafefeedcafefeedcafe
 /etc/reportbug.conf.obsolete deadbeefdeadbeefdeadbeefdeadbeef obsolete
 /etc/reportbug with spaces and obsolete.conf cafebabecafebabecafebabecafebabe obsolete
        """

        pkg = 'test_bts791577'

        expected_conffiles = [
            '/etc/reportbug.conf', '/etc/reportbug with spaces.conf',
            '/etc/reportbug.conf.obsolete',
            '/etc/reportbug with spaces and obsolete.conf'
        ]

        __save = utils.get_command_output
        utils.get_command_output = mock.MagicMock(return_value=pkgstatus)
        result = utils.get_package_status(pkg)
        conffile = [x[0] for x in result[4]]
        utils.get_command_output = __save
        del __save
        self.assertListEqual(conffile, expected_conffiles)
Beispiel #2
0
    def test_get_changed_config_files(self):
        status = utils.get_package_status('dpkg')

        (pkgversion, pkgavail, depends, recommends, conffiles, maintainer,
         installed, origin, vendor, reportinfo, priority, desc, src_name,
         fulldesc, state, suggests, section) = status

        confinfo, changed = utils.get_changed_config_files(conffiles)
        self.assertIsNotNone(confinfo)
Beispiel #3
0
    def test_get_changed_config_files(self):

        status = utils.get_package_status('dpkg')

        (pkgversion, pkgavail, depends, recommends, conffiles, maintainer,
         installed, origin, vendor, reportinfo, priority, desc, src_name,
         fulldesc, state, suggests, section) = status

        confinfo, changed = utils.get_changed_config_files(conffiles)
        self.assertIsNotNone(confinfo)
Beispiel #4
0
    def test_bts650659(self):
        # verify that the dependency list doesn't have tailing white spaces

        status = utils.get_package_status('reportbug')
        (pkgversion, pkgavail, depends, recommends, conffiles, maintainer,
         installed, origin, vendor, reportinfo, priority, desc, src_name,
         fulldesc, state, suggests, section) = status

        for l in [depends, recommends, suggests]:
            result = utils.get_dependency_info('reportbug', l)
            for line in result.split('\n'):
                self.assertEqual(line.rstrip(), line)
Beispiel #5
0
    def test_bts650659(self):
        # verify that the dependency list doesn't have tailing white spaces

        status = utils.get_package_status('reportbug')
        (pkgversion, pkgavail, depends, recommends, conffiles, maintainer,
         installed, origin, vendor, reportinfo, priority, desc, src_name,
         fulldesc, state, suggests, section) = status

        for l in [depends, recommends, suggests]:
            result = utils.get_dependency_info('reportbug', l)
            for line in result.split('\n'):
                self.assertEqual(line.rstrip(), line)
Beispiel #6
0
    def test_bts683116(self):
        """Check Description and Description-LANG are recognized"""

        pkginfo = """Package: reportbug
Status: install ok installed
Version: 6.6.3
%s: reports bugs in the Debian distribution
                """
        pkg = 'reportbug'

        __save = subprocess.getoutput
        subprocess.getoutput = mock.MagicMock(return_value=pkginfo % 'Description')
        result = utils.available_package_description(pkg)
        self.assertEqual('reports bugs in the Debian distribution', result)
        subprocess.getoutput = mock.MagicMock(return_value=pkginfo % 'Description-en')
        result = utils.available_package_description(pkg)
        self.assertEqual('reports bugs in the Debian distribution', result)
        subprocess.getoutput = __save
        del __save

        __save = subprocess.getoutput
        subprocess.getoutput = mock.MagicMock(return_value=pkginfo % 'Description')
        result = utils.get_package_status(pkg)
        self.assertEqual('reports bugs in the Debian distribution', result[11])
        subprocess.getoutput = mock.MagicMock(return_value=pkginfo % 'Description-en')
        result = utils.get_package_status(pkg)
        self.assertEqual('reports bugs in the Debian distribution', result[11])
        subprocess.getoutput = __save
        del __save

        __save = utils.get_dpkg_database
        utils.get_dpkg_database = mock.MagicMock(return_value=[pkginfo % 'Description', ])
        result = utils.get_package_info([((pkg,), pkg)])
        self.assertEqual('reports bugs in the Debian distribution', result[0][3])
        utils.get_dpkg_database = mock.MagicMock(return_value=[pkginfo % 'Description-en', ])
        result = utils.get_package_info([((pkg,), pkg)])
        self.assertEqual('reports bugs in the Debian distribution', result[0][3])
        utils.get_dpkg_database = __save
        del __save
Beispiel #7
0
    def test_get_package_status(self):

        status = utils.get_package_status('non-existing-package')

        (pkgversion, pkgavail, depends, recommends, conffiles, maintainer,
         installed, origin, vendor, reportinfo, priority, desc, src_name,
         fulldesc, state, suggests, section) = status

        self.assertIsNone(pkgversion)
        self.assertIsNone(pkgavail)
        self.assertEqual(depends, ())
        self.assertEqual(recommends, ())
        self.assertEqual(conffiles, ())
        self.assertIsNone(maintainer)
        self.assertFalse(installed)
        self.assertIsNone(origin)
        self.assertEqual(vendor, '')
        self.assertIsNone(reportinfo)
        self.assertIsNone(priority)
        self.assertIsNone(desc)
        self.assertIsNone(src_name)
        self.assertEqual(fulldesc, '')
        self.assertEqual(state, '')
        self.assertEqual(suggests, ())
        self.assertIsNone(section)

        # Using an 'Essential: yes' package, what's better than 'dpkg'?
        status = utils.get_package_status('dpkg')

        (pkgversion, pkgavail, depends, recommends, conffiles, maintainer,
         installed, origin, vendor, reportinfo, priority, desc, src_name,
         fulldesc, state, suggests, section) = status

        self.assertIsNotNone(pkgversion)
        self.assertEqual(pkgavail, 'dpkg')
        # let's just check Depends is not null
        self.assertIsNotNone(depends)
        self.assertIsNotNone(maintainer)
        self.assertTrue(installed)
        self.assertEqual(origin, 'debian')
        self.assertEqual(priority, 'required')
        self.assertIsNotNone(desc)
        self.assertIsNotNone(fulldesc)
        self.assertEqual(state, 'installed')
        self.assertEqual(section, 'admin')

        # it exploits the 'statuscache', it's already called before
        # so it's now in the cache
        status = utils.get_package_status('dpkg')

        status = utils.get_package_status('reportbug', avail=True)

        (pkgversion, pkgavail, depends, recommends, conffiles, maintainer,
         installed, origin, vendor, reportinfo, priority, desc, src_name,
         fulldesc, state, suggests, section) = status

        self.assertIsNotNone(pkgversion)
        self.assertEqual(pkgavail, 'reportbug')
        # let's just check Depends is not null
        self.assertIsNotNone(depends)
        self.assertIsNotNone(maintainer)
        self.assertEqual(priority, 'standard')
        self.assertIsNotNone(desc)
        self.assertIsNotNone(fulldesc)

        status = utils.get_package_status('python-matplotlib')

        (pkgversion, pkgavail, depends, recommends, conffiles, maintainer,
         installed, origin, vendor, reportinfo, priority, desc, src_name,
         fulldesc, state, suggests, section) = status

        self.assertIsNotNone(recommends)
Beispiel #8
0
    def test_get_package_status(self):
        status = utils.get_package_status('non-existing-package')

        (pkgversion, pkgavail, depends, recommends, conffiles, maintainer,
         installed, origin, vendor, reportinfo, priority, desc, src_name,
         fulldesc, state, suggests, section) = status

        self.assertIsNone(pkgversion)
        self.assertIsNone(pkgavail)
        self.assertEqual(depends, ())
        self.assertEqual(recommends, ())
        self.assertEqual(conffiles, ())
        self.assertIsNone(maintainer)
        self.assertFalse(installed)
        self.assertIsNone(origin)
        self.assertEqual(vendor, '')
        self.assertIsNone(reportinfo)
        self.assertIsNone(priority)
        self.assertIsNone(desc)
        self.assertIsNone(src_name)
        self.assertEqual(fulldesc, '')
        self.assertEqual(state, '')
        self.assertEqual(suggests, ())
        self.assertIsNone(section)

        # Using an 'Essential: yes' package, what's better than 'dpkg'?
        status = utils.get_package_status('dpkg')

        (pkgversion, pkgavail, depends, recommends, conffiles, maintainer,
         installed, origin, vendor, reportinfo, priority, desc, src_name,
         fulldesc, state, suggests, section) = status

        self.assertIsNotNone(pkgversion)
        self.assertEqual(pkgavail, 'dpkg')
        # let's just check Depends is not null
        self.assertIsNotNone(depends)
        self.assertIsNotNone(maintainer)
        self.assertTrue(installed)
        self.assertEqual(origin, 'debian')
        self.assertEqual(priority, 'required')
        self.assertIsNotNone(desc)
        self.assertIsNotNone(fulldesc)
        self.assertEqual(state, 'installed')
        self.assertEqual(section, 'admin')

        # it exploits the 'statuscache', it's already called before
        # so it's now in the cache
        status = utils.get_package_status('dpkg')

        status = utils.get_package_status('reportbug', avail=True)

        (pkgversion, pkgavail, depends, recommends, conffiles, maintainer,
         installed, origin, vendor, reportinfo, priority, desc, src_name,
         fulldesc, state, suggests, section) = status

        self.assertIsNotNone(pkgversion)
        self.assertEqual(pkgavail, 'reportbug')
        # let's just check Depends is not null
        self.assertIsNotNone(depends)
        self.assertIsNotNone(maintainer)
        self.assertEqual(priority, 'standard')
        self.assertIsNotNone(desc)
        self.assertIsNotNone(fulldesc)

        status = utils.get_package_status('python-matplotlib')

        (pkgversion, pkgavail, depends, recommends, conffiles, maintainer,
         installed, origin, vendor, reportinfo, priority, desc, src_name,
         fulldesc, state, suggests, section) = status

        self.assertIsNotNone(recommends)