示例#1
0
    def test_cache(self):
        def get_mtime(pattern):
            pattern = os.path.join(ReviewDirs.root, pattern)
            path = glob(pattern)[0]
            return os.stat(path).st_mtime

        self.init_test(["fedora-review", "-b", "818805"])
        if os.path.exists("818805-openerp-client"):
            shutil.rmtree("818805-openerp-client")
        bug = BugzillaBug(Settings.bug)
        bug.find_urls()
        bug.download_files()
        srpm_org_time = get_mtime("srpm/python-test-1.0*.src.rpm")
        spec = SpecFile(bug.spec_file)
        sources = Sources(spec)
        upstream_org_time = get_mtime("upstream/python-test*.gz")
        del bug

        self.init_test(["fedora-review", "-cb", "818805"])
        bug = BugzillaBug(Settings.bug)
        bug.find_urls()
        bug.download_files()
        srpm_new_time = get_mtime("srpm/python-test-1.0*.src.rpm")
        spec = SpecFile(bug.spec_file)
        sources = Sources(spec)
        upstream_new_time = get_mtime("upstream/python-test*.gz")

        self.assertEqual(upstream_org_time, upstream_new_time, "upstream")
        self.assertEqual(srpm_org_time, srpm_new_time, "srpm")
示例#2
0
 def test_bugzilla_bug(self):
     self.init_test('test_misc',
                    argv=['-b','817268'],
                    wd='python-test')
     bug = BugzillaBug('817268')
     bug.find_urls()
     expected ='http://dl.dropbox.com/u/17870887/python-faces-0.11.7-2' \
               '/python-faces-0.11.7-2.fc16.src.rpm'
     self.assertEqual(expected, bug.srpm_url)
     expected = 'http://dl.dropbox.com/u/17870887/python-faces-0.11.7-2/' \
                'python-faces.spec'
     self.assertEqual(expected, bug.spec_url)
     self.assertEqual(None, bug.spec_file)
     self.assertEqual(None, bug.srpm_file)
示例#3
0
 def test_bugzilla_bug(self):
     sys.argv = ['fedora-review','-b','817268']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     bug = BugzillaBug('817268')
     bug.find_urls()
     expected ='http://dl.dropbox.com/u/17870887/python-faces-0.11.7-2' \
               '/python-faces-0.11.7-2.fc16.src.rpm'
     self.assertEqual(expected, bug.srpm_url)
     expected = 'http://dl.dropbox.com/u/17870887/python-faces-0.11.7-2/' \
                'python-faces.spec'
     self.assertEqual(expected, bug.spec_url)
     self.assertEqual(None, bug.spec_file)
     self.assertEqual(None, bug.srpm_file)
     os.chdir(self.startdir)
示例#4
0
 def test_bugzilla_bug(self):
     sys.argv = ['fedora-review', '-b', '817268']
     Settings.init(True)
     ReviewDirs.reset()
     ReviewDirs.workdir_setup('.', True)
     bug = BugzillaBug('817268')
     bug.find_urls()
     expected ='http://dl.dropbox.com/u/17870887/python-faces-0.11.7-2' \
               '/python-faces-0.11.7-2.fc16.src.rpm'
     self.assertEqual(expected, bug.srpm_url)
     expected = 'http://dl.dropbox.com/u/17870887/python-faces-0.11.7-2/' \
                'python-faces.spec'
     self.assertEqual(expected, bug.spec_url)
     self.assertEqual(None, bug.spec_file)
     self.assertEqual(None, bug.srpm_file)
     os.chdir(self.startdir)
示例#5
0
    def test_bug(self):
        """ Test -bug option """
        self.init_test(["fedora-review", "-b", "818805"])
        bug = BugzillaBug(Settings.bug)

        bug.find_urls()
        home = "http://leamas.fedorapeople.org/openerp-client"
        expected = os.path.join(home, "openerp-client-6.1-2.fc16.src.rpm")
        self.assertEqual(expected, bug.srpm_url)
        expected = os.path.join(home, "openerp-client.spec")
        self.assertEqual(expected, bug.spec_url),

        bug.download_files()
        expected = os.path.abspath("srpm/openerp-client-6.1-2.fc16.src.rpm")
        self.assertEqual(expected, bug.srpm_file),
        expected = os.path.abspath("srpm/openerp-client.spec")
        self.assertEqual(expected, bug.spec_file)
示例#6
0
class TestBugzilla(FR_TestCase):
    TEST_BUG = '672280'

    @unittest.skipIf(NO_NET, 'No network available')
    def test_find_urls(self):
        self.init_test('bugzilla',
                       argv=['-b', self.TEST_BUG], wd='python-test')
        self.bug = BugzillaBug(self.TEST_BUG)
        ''' Test that we can get the urls from a bugzilla report'''
        rc = self.bug.find_urls()
        self.assertTrue(rc)
        home = 'http://timlau.fedorapeople.org/files/test/review-test'
        self.assertEqual(self.bug.srpm_url,
                         os.path.join(home,
                                      'python-test-1.0-1.fc14.src.rpm'))
        self.assertEqual(self.bug.spec_url,
                         os.path.join(home, 'python-test.spec'))


    @unittest.skipIf(NO_NET, 'No network available')
    def test_download_files(self):
        self.init_test('bugzilla',
                       argv=['-b', self.TEST_BUG], wd='python-test')
        self.bug = BugzillaBug(self.TEST_BUG)
        '''
        Test that we can download the spec and srpm from a bugzilla report
        '''
        self.bug.find_urls()
        rc = self.bug.download_files()
        self.assertTrue(rc)
        self.assertEqual(self.bug.srpm_url,
                         'http://timlau.fedorapeople.org/files/test'
                         '/review-test/python-test-1.0-1.fc14.src.rpm')
        self.assertEqual(self.bug.spec_url,
                         'http://timlau.fedorapeople.org/files/test/'
                          'review-test/python-test.spec')

        cd = os.path.abspath('./srpm')
        srpm = os.path.join(cd,  'python-test-1.0-1.fc14.src.rpm')
        spec = os.path.join(cd,  'python-test.spec')
        self.assertEqual(self.bug.srpm_file, srpm)
        self.assertEqual(self.bug.spec_file, spec)
        self.assertTrue(os.path.exists(srpm))
        self.assertTrue(os.path.exists(spec))
示例#7
0
 def test_find_urls(self):
     self.init_test('bugzilla',
                    argv=['-b', self.TEST_BUG], wd='python-test')
     self.bug = BugzillaBug(self.TEST_BUG)
     ''' Test that we can get the urls from a bugzilla report'''
     rc = self.bug.find_urls()
     self.assertTrue(rc)
     home = 'http://timlau.fedorapeople.org/files/test/review-test'
     self.assertEqual(self.bug.srpm_url,
                      os.path.join(home,
                                   'python-test-1.0-1.fc14.src.rpm'))
     self.assertEqual(self.bug.spec_url,
                      os.path.join(home, 'python-test.spec'))
示例#8
0
class TestBugzilla(unittest.TestCase):

    def setUp(self):
        sys.argv = ['test-bugzilla','-b',TEST_BUG ]
        Settings.init(TEST_BUG )
        ReviewDirs.workdir_setup('.', True)
        self.bug = BugzillaBug(TEST_BUG)

    @unittest.skipIf(no_net, 'No network available')
    def test_find_urls(self):
        ''' Test that we can get the urls from a bugzilla report'''
        rc = self.bug.find_urls()
        self.assertTrue(rc)
        home = 'http://timlau.fedorapeople.org/files/test/review-test'
        self.assertEqual(self.bug.srpm_url,
                         os.path.join(home, 
                                      'python-test-1.0-1.fc14.src.rpm'))
        self.assertEqual(self.bug.spec_url, 
                         os.path.join(home, 'python-test.spec'))


    @unittest.skipIf(no_net, 'No network available')
    def test_download_files(self):
        ''' 
        Test that we can download the spec and srpm from a bugzilla report
        '''
        self.bug.find_urls()
        rc = self.bug.download_files()
        self.assertTrue(rc)
        self.assertEqual(self.bug.srpm_url,
                         'http://timlau.fedorapeople.org/files/test' 
                         '/review-test/python-test-1.0-1.fc14.src.rpm')
        self.assertEqual(self.bug.spec_url,
                         'http://timlau.fedorapeople.org/files/test/'
                          'review-test/python-test.spec')
        
        cd = os.path.abspath('./srpm')
        srpm = os.path.join(cd,  'python-test-1.0-1.fc14.src.rpm')
        spec = os.path.join(cd,  'python-test.spec')
        self.assertEqual(self.bug.srpm_file, srpm)
        self.assertEqual(self.bug.spec_file, spec)
        self.assertTrue(os.path.exists(srpm))
        self.assertTrue(os.path.exists(spec))

    @unittest.skipIf(no_net, 'No network available')
    def test_login(self):
        ''' test login to bugzilla
        You need to use BZ_USER=<user> BZ_PASS=<password> make test to 
        active the login test
        '''
        # Test failed login
        with self.assertRaises(SettingsError):
            rc = self.bug.login('dummmy', 'dummy')
        if 'BZ_USER' in os.environ and 'BZ_PASS' in os.environ:
            user = os.environ['BZ_USER']
            password = os.environ['BZ_PASS']
            rc = self.bug.login(user=user, password=password)
            self.assertEqual(rc, True)
示例#9
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
示例#10
0
    def test_download_files(self):
        self.init_test('bugzilla',
                       argv=['-b', self.TEST_BUG], wd='python-test')
        self.bug = BugzillaBug(self.TEST_BUG)
        '''
        Test that we can download the spec and srpm from a bugzilla report
        '''
        self.bug.find_urls()
        rc = self.bug.download_files()
        self.assertTrue(rc)
        self.assertEqual(self.bug.srpm_url,
                         'http://timlau.fedorapeople.org/files/test'
                         '/review-test/python-test-1.0-1.fc14.src.rpm')
        self.assertEqual(self.bug.spec_url,
                         'http://timlau.fedorapeople.org/files/test/'
                          'review-test/python-test.spec')

        cd = os.path.abspath('./srpm')
        srpm = os.path.join(cd,  'python-test-1.0-1.fc14.src.rpm')
        spec = os.path.join(cd,  'python-test.spec')
        self.assertEqual(self.bug.srpm_file, srpm)
        self.assertEqual(self.bug.spec_file, spec)
        self.assertTrue(os.path.exists(srpm))
        self.assertTrue(os.path.exists(spec))
示例#11
0
    def test_bug(self):
        """ Test -bug option """
        self.init_test(['fedora-review','-b','818805'])
        bug = BugzillaBug(Settings.bug)

        bug.find_urls()
        home = 'http://leamas.fedorapeople.org/openerp-client'
        expected = os.path.join( home, 
                                 'openerp-client-6.1-2.fc16.src.rpm')
        self.assertEqual(expected, bug.srpm_url)
        expected = os.path.join(home, 'openerp-client.spec')
        self.assertEqual(expected, bug.spec_url),

        bug.download_files()
        expected = os.path.abspath(
                             'srpm/openerp-client-6.1-2.fc16.src.rpm')
        self.assertEqual(expected, bug.srpm_file),
        expected = os.path.abspath('srpm/openerp-client.spec')
        self.assertEqual(expected, bug.spec_file)
示例#12
0
    def test_cache(self):
        def get_mtime(pattern):
            pattern = os.path.join(ReviewDirs.root, pattern)
            path = glob(pattern)[0]
            return os.stat(path).st_mtime 

        self.init_test(['fedora-review','-b','818805'])
        if os.path.exists('818805-openerp-client'):
            shutil.rmtree('818805-openerp-client')
        bug = BugzillaBug(Settings.bug)
        bug.find_urls()
        bug.download_files()
        srpm_org_time = get_mtime('srpm/python-test-1.0*.src.rpm')
        spec = SpecFile(bug.spec_file)
        sources = Sources(spec)
        upstream_org_time = get_mtime('upstream/python-test*.gz')
        del bug

        self.init_test(['fedora-review','-cb','818805'])
        bug = BugzillaBug(Settings.bug)
        bug.find_urls()
        bug.download_files()
        srpm_new_time = get_mtime('srpm/python-test-1.0*.src.rpm')
        spec = SpecFile(bug.spec_file)
        sources = Sources(spec)
        upstream_new_time = get_mtime('upstream/python-test*.gz')

        self.assertEqual(upstream_org_time, upstream_new_time, 'upstream')
        self.assertEqual(srpm_org_time, srpm_new_time, 'srpm')
示例#13
0
 def setUp(self):
     sys.argv = ['test-bugzilla','-b',TEST_BUG ]
     Settings.init(TEST_BUG )
     ReviewDirs.workdir_setup('.', True)
     self.bug = BugzillaBug(TEST_BUG)