Exemplo n.º 1
0
    def test_cache(self):
        ''' --cache option test. '''
        def get_mtime(pattern):
            '''¸Return mtime for first path matching pattern. '''
            pattern = os.path.join(os.getcwd(), pattern)
            path = glob(pattern)[0]
            return os.stat(path).st_mtime

        loglevel = os.environ['REVIEW_LOGLEVEL']
        os.environ['REVIEW_LOGLEVEL'] = 'ERROR'
        self.init_opt_test(['-b', '818805'], 'options')
        os.environ['REVIEW_LOGLEVEL'] = loglevel
        bug = BugzillaBug(Settings.bug)
        bug.find_urls()
        bug.download_files()
        srpm_org_time = get_mtime('srpm/openerp-client*.src.rpm')
        Checks(bug.spec_file, bug.srpm_file)
        upstream_org_time = get_mtime('upstream/openerp-client*.gz')
        del bug

        os.chdir(self.startdir)
        loglevel = os.environ['REVIEW_LOGLEVEL']
        os.environ['REVIEW_LOGLEVEL'] = 'ERROR'
        self.init_opt_test(['-cb', '818805'], 'options')
        os.environ['REVIEW_LOGLEVEL'] = loglevel
        bug = BugzillaBug(Settings.bug)
        bug.find_urls()
        bug.download_files()
        srpm_new_time = get_mtime('srpm/openerp-client*.src.rpm')
        Checks(bug.spec_file, bug.srpm_file)
        upstream_new_time = get_mtime('upstream/openerp-client*.gz')

        self.assertEqual(upstream_org_time, upstream_new_time, 'upstream')
        self.assertEqual(srpm_org_time, srpm_new_time, 'srpm')
Exemplo n.º 2
0
 def test_bugzilla_bug(self):
     ''' Scanning of bugzilla bugpage test. '''
     subprocess.check_call('mkdir -p tmp/python-test || :', shell=True)
     self.init_test('tmp',
                    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)
Exemplo n.º 3
0
class TestBugzilla(FR_TestCase):
    ''' Test the bugzilla-specific parts. '''
    TEST_BUG = '672280'

    @unittest.skipIf(NO_NET, 'No network available')
    def test_find_urls(self):
        ''' See that we can find URLs in bugzilla's bug page. '''
        self.init_test('bugzilla',
                       argv=['-b', self.TEST_BUG], wd='python-test')
        self.bug = BugzillaBug(self.TEST_BUG)
        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.init_test('bugzilla',
                       argv=['-b', self.TEST_BUG], wd='python-test')
        self.bug = BugzillaBug(self.TEST_BUG)    # pylint: disable=W0201
        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))
Exemplo n.º 4
0
    def test_bug(self):
        """ Test -bug option """
        self.init_opt_test(['-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)
Exemplo n.º 5
0
 def test_find_urls(self):
     ''' See that we can find URLs in bugzilla's bug page. '''
     self.init_test('bugzilla',
                    argv=['-b', self.TEST_BUG], wd='python-test')
     self.bug = BugzillaBug(self.TEST_BUG)
     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'))
Exemplo n.º 6
0
    def test_download_files(self):
        '''
        Test that we can download the spec and srpm from a bugzilla report
        '''
        self.init_test('bugzilla',
                       argv=['-b', self.TEST_BUG], wd='python-test')
        self.bug = BugzillaBug(self.TEST_BUG)    # pylint: disable=W0201
        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))