Ejemplo n.º 1
0
class TestRChecks(unittest.TestCase):

    def setUp(self):
        sys.argv = ['fedora-review','-rpn','R-Rdummypkg']
        os.chdir('test-R')
        if os.path.exists('R-Rdummypkg'):
             shutil.rmtree('R-Rdummypkg')
        Settings.init(True)
        ReviewDirs.reset()

    @unittest.skipIf(no_net, 'No network available')
    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.º 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_flags_2(self):
     ''' Flag defined in python, not set by user' '''
     self.init_test('test_misc',
                    argv=['-n','python-test', '--cache',
                          '--no-build'])
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     self.assertFalse(checks.flags['EPEL5'])
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_flags_3(self):
        ''' Flag not defined , set by user' '''

        self.init_test('test_misc',
                       argv=['-n','python-test', '--cache',
                             '--no-build', '-D', 'EPEL8'])
        bug = NameBug('python-test')
        bug.find_urls()
        bug.download_files()
        with  self.assertRaises(ReviewError):
            checks = Checks(bug.spec_file, bug.srpm_file)
Ejemplo n.º 6
0
 def test_bad_specname(self):
     self.init_test('bad-specname',
                    argv=['-rn','python-test', '--cache'])
     ReviewDirs.reset(os.getcwd())
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     check = checks.checkdict['CheckSpecAsInSRPM']
     check.run()
     self.assertTrue(check.is_failed)
     self.assertIn('Bad spec filename:', check.result.output_extra)
Ejemplo n.º 7
0
    def test_flags_4(self):
        ''' Flag defined in shell script , set by user to value '''

        os.environ['XDG_DATA_HOME'] = os.getcwd()
        self.init_test('test_misc',
                       argv=['-n','python-test', '--cache',
                             '--no-build', '-D', 'EPEL6=foo'])
        bug = NameBug('python-test')
        bug.find_urls()
        bug.download_files()
        checks = Checks(bug.spec_file, bug.srpm_file)
        self.assertEqual(str(checks.flags['EPEL6']), 'foo')
Ejemplo n.º 8
0
 def test_rpm_spec(self):
     self.init_test('test_misc',
                    argv=['-rn','python-test', '--cache',
                          '--no-build'])
     ReviewDirs.reset()
     bug = NameBug('python-test')
     bug.find_urls()
     expected = 'src/test/test_misc/python-test-1.0-1.fc16.src.rpm'
     self.assertTrue(bug.srpm_url.endswith(expected))
     expected = 'src/test/test_misc/review-python-test/srpm-unpacked/python-test.spec'
     print bug.spec_url
     self.assertTrue(bug.spec_url.endswith(expected))
Ejemplo n.º 9
0
 def test_local_repo(self):
     self.init_test('test_misc',
                    argv=['-rn','python-test', '--local-repo',
                          'repo', '--cache'])
     ReviewDirs.reset(os.getcwd())
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     check = checks.checkdict['CheckPackageInstalls']
     check.run()
     self.assertTrue(check.is_passed)
     self.assertTrue(Mock.is_installed('dummy'))
Ejemplo n.º 10
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.º 11
0
 def test_sh_api(self):
     ''' Basic shell API test. '''
     self.init_test('test_ext',
                    argv=['-pn','python-test', '--cache',
                           '--no-build'])
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     checks.checkdict['CreateEnvCheck'].run()
     checks.checkdict['unittest-test2'].run()
     self.assertTrue(checks.checkdict['unittest-test2'].is_pending)
     self.assertNotIn('CheckLargeDocs', checks.checkdict)
Ejemplo n.º 12
0
 def test_107_source_same_as_name(self):
     """ Test the case when Source is equal to %{name}
     """
     srpm_file = os.path.join(os.path.abspath('.'),
                                   'test_regressions',
                                   'test_107_2-1.0-1.fc17.src.rpm')
     self.init_test('test_regressions',
                    argv=['-rn', srpm_file, '--cache'])
     ReviewDirs.reset(os.getcwd())
     bug = NameBug(srpm_file)
     bug.find_urls()
     self.assertNotEqual(None, bug.srpm_file)
     self.assertNotEqual(None, bug.spec_file)
Ejemplo n.º 13
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.º 14
0
 def test_md5sum_diff_fail(self):
     self.init_test('md5sum-diff-fail',
                    argv=['-rpn','python-test', '--cache',
                          '--no-build'])
     ReviewDirs.reset(os.getcwd())
     bug = NameBug('python-test')
     bug.find_urls()
     checks = Checks(bug.spec_file, bug.srpm_file).get_checks()
     checks.set_single_check('CheckSourceMD5')
     check = checks['CheckSourceMD5']
     check.run()
     self.assertTrue(check.is_failed)
     expected = 'diff -r also reports differences'
     self.assertTrue(expected in check.result.attachments[0].text)
Ejemplo n.º 15
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.º 16
0
 def test_prebuilt_sources(self):
     self.init_test('test_misc',
                    argv=['-n','python-test', '--prebuilt'])
     ReviewDirs.startdir = os.getcwd()
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     subprocess.check_call('touch orvar.rpm', shell=True)
     rpms = checks.srpm.get_used_rpms()
     self.assertEqual(len(rpms), 2)
     rpms = checks.srpm.get_used_rpms('.src.rpm')
     os.unlink('orvar.rpm')
     self.assertEqual(len(rpms), 1)
Ejemplo n.º 17
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.º 18
0
 def test_srv_opt(self):
     ''' Test check of no files in /srv, /opt and /usr/local. '''
     self.init_test('srv-opt',
                    argv=['-rn','dummy', '--cache',
                           '--no-build'])
     ReviewDirs.reset(os.getcwd())
     bug = NameBug('dummy')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     check = checks.checkdict['CreateEnvCheck'].run()
     check = checks.checkdict['check-srv-opt-local']
     check.run()
     self.assertTrue( '/srv' in check.result.output_extra)
     self.assertTrue( '/opt' in check.result.output_extra)
     self.assertTrue( '/usr/local' in check.result.output_extra)
Ejemplo n.º 19
0
 def test_perl_module(self):
     ''' test basic perl python + shell test '''
     self.init_test('perl',
                    argv=['-rn','perl-RPM-Specfile', '--no-build'])
     ReviewDirs.reset(os.getcwd())
     bug = NameBug('perl-RPM-Specfile')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     checks.checkdict['CreateEnvCheck'].run()
     check = checks.checkdict['PerlCheckBuildRequires']
     check.run()
     self.assertTrue(check.is_pending)
     check = checks.checkdict['perl-url-tag']
     check.run()
     self.assertTrue(check.is_pending)
Ejemplo n.º 20
0
 def test_sources(self):
     self.init_test('test_misc',
                    argv=['-n','python-test', '--cache',
                          '--no-build'])
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file).get_checks()
     checks.set_single_check('CheckSourceMD5')
     check = checks['CheckSourceMD5']
     check.run()
     result = check.result
     self.log.debug('test_source, result : ' + result.result)
     if result.output_extra:
        self.log.debug("Result extra text: " + result.output_extra)
     self.assertTrue(check.is_passed)
Ejemplo n.º 21
0
 def test_mock_uniqueext(self):
     self.init_test('test_misc',
                    argv=['-n','python-test'],
                    options='--uniqueext=hugo')
     bug = NameBug('python-test')
     bug.find_urls()
     bug.download_files()
     checks = Checks(bug.spec_file, bug.srpm_file)
     Mock.init()
     for dirt in glob.glob('results/*.*'):
         os.unlink(dirt)
     check = checks.checkdict['CheckBuild']
     check.run()
     self.assertTrue(check.is_passed)
     results = glob.glob('results/*.rpm')
     self.assertEqual(len(results), 2)
     for dirt in glob.glob('results/*.*'):
         os.unlink(dirt)
Ejemplo n.º 22
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.º 23
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.º 24
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.º 25
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.º 26
0
    def test_jsonapi(self):
        self.init_test('test_misc',
                       argv=['-rpn','python-test', '--no-build'])
        ReviewDirs.reset(os.getcwd())
        os.environ['REVIEW_EXT_DIRS'] = os.path.normpath(os.getcwd() + '/../api')

        bug = NameBug('python-test')
        bug.find_urls()
        bug.download_files()
        checks = Checks(bug.spec_file, bug.srpm_file).get_checks()
        test1 = checks['test1']
        test2 = checks['ExtShellTest2']
        self.assertEqual( test1.group, 'Generic')
        self.assertEqual( test1.type, 'EXTRA')
        self.assertEqual( test1.text, 'A check solely for test purposes.')

        self.assertEqual( test2.group, 'Generic')
        self.assertEqual( test2.type, 'EXTRA')
        self.assertEqual( test2.text,
                          'A second check solely for test purposes.')
Ejemplo n.º 27
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)
Ejemplo n.º 28
0
    def test_dirty_resultdir(self):
        self.init_test('test_misc',
                       argv=['-n','python-test', '--cache'])
        bug = NameBug('python-test')
        bug.find_urls()
        bug.download_files()
        checks = Checks(bug.spec_file, bug.srpm_file).get_checks()
        checks.set_single_check('CheckResultdir')
        check = checks['CheckResultdir']

        for dirt in glob.glob('results/*.*'):
            os.unlink(dirt)
        check.run()
        self.assertTrue(check.is_passed)

        subprocess.check_call('touch results/orvar.rpm', shell=True)
        self.assertRaises(ReviewError, check.run)
        Settings.nobuild = True
        check.run()
        self.assertTrue(check.is_passed)
        os.unlink('results/orvar.rpm')
Ejemplo n.º 29
0
class TestRChecks(FR_TestCase):

    R_TEST_SRPM =            'https://fedorahosted.org/releases/F/e' \
                             '/FedoraReview/R-Rdummypkg-1.0-2.fc15.src.rpm'
    R_TEST_SPEC = FR_TestCase.BASE_URL + 'R-Rdummypkg.spec'
    R_TEST_SRC  = FR_TestCase.BASE_URL + 'Rdummypkg_1.0.tar.gz'

    @unittest.skipIf(FAST_TEST, 'slow test disabled by REVIEW_FAST_TEST')
    def test_all_checks(self):
        ''' Run all automated review checks'''
        self.init_test('test-R',
                        argv=['-rpn','R-Rdummypkg', '--no-build'])
        ReviewDirs.reset()
        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.checkdict.itervalues():
            if check.is_passed or check.is_pending or check.is_failed:
                self.assertIn(check.group, ['Generic', 'R'])
Ejemplo n.º 30
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.º 31
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.º 32
0
    def test_sh_attach(self):
        ''' Test shell attachments. '''

        self.init_test('test_ext',
                       argv=['-rn','python-test', '--no-build'])
        ReviewDirs.reset(os.getcwd())
        bug = NameBug('python-test')
        bug.find_urls()
        bug.download_files()
        checks = Checks(bug.spec_file, bug.srpm_file).get_checks()
        checks['CreateEnvCheck'].run()
        check = checks['test-attachments']
        check.run()
        self.assertEqual(len(check.result.attachments), 2)
        a1 = filter( lambda a: 'attachment 1' in a.text,
                     check.result.attachments)[0]
        a2 = filter( lambda a: 'attachment 2' in a.text,
                     check.result.attachments)[0]
        self.assertEqual('Heading 1',  a1.header)
        self.assertEqual(8,  a1.order_hint)
        self.assertEqual('Heading 2',  a2.header)
        self.assertEqual(9,  a2.order_hint)
Ejemplo n.º 33
0
 def test_all_checks(self):
     ''' Run all automated review checks'''
     self.init_test('test-R',
                     argv=['-rpn','R-Rdummypkg', '--no-build'])
     ReviewDirs.reset()
     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.checkdict.itervalues():
         if check.is_passed or check.is_pending or check.is_failed:
             self.assertIn(check.group, ['Generic', 'R'])
Ejemplo n.º 34
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.º 35
0
class TestRChecks(unittest.TestCase):
    def setUp(self):
        sys.argv = ['fedora-review', '-rpn', 'R-Rdummypkg']
        os.chdir('test-R')
        if os.path.exists('R-Rdummypkg'):
            shutil.rmtree('R-Rdummypkg')
        Settings.init(True)
        ReviewDirs.reset()

    @unittest.skipIf(no_net, 'No network available')
    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.º 36
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.º 37
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.º 38
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.º 39
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.º 40
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.º 41
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)
Ejemplo n.º 42
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)