Ejemplo n.º 1
0
    def test_source_file(self):
        """ Test the SourceFile class """
        if os.path.exists('python-test'):
            shutil.rmtree('python-test')
        sys.argv = ['fedora-review', '-n', 'python-test']
        Settings.init(True)
        ReviewDirs.reset()
        ReviewDirs.workdir_setup('.', True)
        bug = NameBug('python-test')
        bug.find_urls()
        bug.download_files()

        spec = SpecFile(bug.spec_file)
        sources = Sources(spec)
        source = Source(sources, 'Source0', TEST_SRC)
        # check that source exists and source.filename point to the right location
        expected = os.path.abspath('./upstream/python-test-1.0.tar.gz')
        self.assertEqual(source.filename, expected)
        self.assertEqual(source.is_archive(), True)
        self.assertTrue(os.path.exists(source.filename))
        self.assertEqual(
            source.check_source_checksum(),
            "7ef644ee4eafa62cfa773cad4056cdcea592e27dacd5ae"
            "b4e8b11f51f5bf60d3")
        os.chdir(self.startdir)
Ejemplo n.º 2
0
    def test_exclude(self):
        ''' test --exclude/-x option. '''
        self.init_test(['fedora-review',
                        '-n','python-test',
                        '-x', 'CheckRequires'])

        bug = NameBug(Settings.name)
        bug.find_urls()
        bug.download_files()
        checks = Checks(bug.spec_file, bug.srpm_file)
        self.assertFalse('CheckRequires' in checks.get_checks()) 
Ejemplo n.º 3
0
 def test_desktop_file_bug(self):
     os.chdir('desktop-file')
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     sys.argv = ['fedora-review', '-rpn', 'python-test']
     Settings.init(True)
     ReviewDirs.reset()
     bug = NameBug('python-test')
     check = self.run_single_check(bug, 'CheckDesktopFileInstall')
     self.assertEqual(check.state, 'pass')
     os.chdir(self.startdir)
Ejemplo n.º 4
0
    def test_single(self):
        ''' test --single/-s option '''
        self.init_test(['fedora-review',
                        '-n','python-test',
                        '-s', 'CheckRequires'])

        bug = NameBug(Settings.name)
        bug.find_urls()
        bug.download_files()
        checks = Checks(bug.spec_file, bug.srpm_file)
        self.assertEqual(len(checks.checks), 1)
        check = checks.checks[0]
        self.assertEqual(check.name, 'CheckRequires') 
Ejemplo n.º 5
0
 def test_bad_specfile(self):
     os.chdir('bad-spec')
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     sys.argv = ['fedora-review', '-pn', 'python-test']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     bug = NameBug('python-test')
     check = self.run_single_check(bug, 'CheckSpecAsInSRPM')
     self.assertEqual(check.state, 'fail')
     self.assertTrue('#TestTag' in check.attachments[0].text)
     os.chdir(self.startdir)
Ejemplo n.º 6
0
 def test_rpm_spec(self):
     sys.argv = ['fedora-review', '-rn', 'python-test']
     Settings.init(True)
     ReviewDirs.reset()
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     bug = NameBug('python-test')
     bug.find_urls()
     expected = 'src/test/python-test-1.0-1.fc16.src.rpm'
     self.assertTrue(bug.srpm_url.endswith(expected))
     expected = 'src/test/python-test/srpm-unpacked/python-test.spec'
     self.assertTrue(bug.spec_url.endswith(expected))
     os.chdir(self.startdir)
Ejemplo n.º 7
0
 def test_all_checks(self):
     ''' Run all automated review checks'''
     self.bug = NameBug('R-Rdummypkg')
     self.bug.find_urls()
     self.bug.download_files()
     self.checks = Checks(self.bug.spec_file, self.bug.srpm_file)
     self.checks.run_checks(writedown=False)
     for check in self.checks.checks:
         if check.is_applicable():
             self.assertTrue(check.header == 'Generic'
                             or check.header == 'R')
             result = check.get_result()
             self.assertTrue(result.result in ['pass', 'pending', 'fail'])
     os.chdir('..')
Ejemplo n.º 8
0
    def test_name(self):
        """ Test -name option """
        self.init_test(['fedora-review','-n','python-test'])
        bug = NameBug(Settings.name)

        bug.find_urls()
        expected = abs_file_url('./python-test-1.0-1.fc16.src.rpm')
        self.assertEqual(expected, bug.srpm_url)
        expected = abs_file_url('./python-test.spec')
        self.assertEqual(expected, bug.spec_url),

        bug.download_files()
        expected = os.path.abspath('./python-test-1.0-1.fc16.src.rpm')
        self.assertEqual(expected, bug.srpm_file),
        expected = os.path.abspath('./python-test.spec')
        self.assertEqual(expected, bug.spec_file),
Ejemplo n.º 9
0
 def test_md5sum_diff_fail(self):
     os.chdir('md5sum-diff-fail')
     sys.argv = ['fedora-review', '-rpn', 'python-test']
     Settings.init(True)
     ReviewDirs.reset()
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     bug = NameBug('python-test')
     bug.find_urls()
     checks = Checks(bug.spec_file, bug.srpm_file)
     checks.set_single_check('CheckSourceMD5')
     self.assertEqual(len(checks.checks), 1)
     check = checks.checks[0]
     check.run()
     self.assertEqual(check.state, 'fail')
     expected = 'diff -r also reports differences'
     self.assertTrue(expected in check.attachments[0].text)
     os.chdir(self.startdir)
Ejemplo n.º 10
0
 def run(self):
     self.log.debug("Command  line: " + ' '.join(sys.argv))
     try:
         Settings.init()
         make_report = True
         if Settings.list_checks:
             self.__list_checks()
             make_report = False
         elif Settings.version:
             self.__print_version()
             make_report = False
         elif Settings.url:
             self.log.info("Processing bug on url: " + Settings.url)
             self.bug = UrlBug(Settings.url)
         elif Settings.bug:
             self.log.info("Processing bugzilla bug: " + Settings.bug)
             self.bug = BugzillaBug(Settings.bug, user=Settings.user)
         elif Settings.name:
             self.log.info("Processing local files: " + Settings.name)
             self.bug = NameBug(Settings.name)
         if make_report:
             self.__do_report()
         return 0
     except BugException as err:
         print str(err)
         return 2
     except HandledError as err:
         print str(err)
         return 2
     except SettingsError as err:
         self.log.error("Incompatible settings: " + str(err))
         return 2
     except ReviewDirExistsError as err:
         print("The directory %s is in the way, please remove." % err.value)
         return 4
     except CleanExitError as err:
         self.log.debug('Processing CleanExit')
         return 2
     except:
         self.log.debug("Exception down the road...", exc_info=True)
         self.log.error("Exception down the road...")
         return 1
     return 0
Ejemplo n.º 11
0
    def test_rpm_spec(self):
        """ Test --rpm-spec/-r option """
        self.init_test(['fedora-review','-rn','python-test'],
                       'desktop-file')
        if os.path.exists('python-test'):
            shutil.rmtree('python-test')
        ReviewDirs.reset()
        bug = NameBug(Settings.name)
        bug.find_urls()

        expected = abs_file_url('../python-test-1.0-1.fc16.src.rpm')
        self.assertEqual(expected, bug.srpm_url)
        expected = abs_file_url('./srpm-unpacked/python-test.spec')
        self.assertEqual(expected, bug.spec_url),

        bug.download_files()
        expected = os.path.abspath('../python-test-1.0-1.fc16.src.rpm')
        self.assertEqual(expected, bug.srpm_file),
        expected = os.path.abspath('./srpm-unpacked/python-test.spec')
        self.assertEqual(expected, bug.spec_file),
        os.chdir(startdir)
Ejemplo n.º 12
0
 def test_sources(self):
     if os.path.exists('python-test'):
         shutil.rmtree('python-test')
     sys.argv = ['fedora-review', '-n', 'python-test']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     checks.set_single_check('CheckSourceMD5')
     self.assertEqual(len(checks.checks), 1)
     check = checks.checks[0]
     check.run()
     result = check.get_result()
     self.log.debug('result : ' + result.result)
     if result.output_extra:
         self.log.debug("Result extra text: " + result.output_extra)
     self.assertEqual(result.result, 'pass')
     os.chdir(self.startdir)