Example #1
0
    def __init__(self, bug, user=None, password=None, cache=False,
                nobuild=False, other_BZ=None):
        """ Constructor.
        :arg bug, the bug number on bugzilla
        :kwarg user, the username with which to log in in bugzilla.
        :kwarg password, the password associated with this account.
        :kwarg cache, boolean specifying whether the spec and srpm should
        be re-downloaded or not.
        :kwarg nobuild, boolean specifying whether to build or not the
        package.
        :kwarg other_BZ, url of an eventual other bugzilla system.
        """
        Helpers.__init__(self, cache, nobuild)
        self.bug_num = bug
        self.spec_url = None
        self.srpm_url = None
        self.spec_file = None
        self.srpm_file = None
        self.log = get_logger()
        if other_BZ:
            self.bugzilla = Bugzilla(url=other_BZ + '/xmlrpc.cgi')
        else:
            self.bugzilla = Bugzilla(url=BZ_URL)

        self.log.info("Trying bugzilla cookies for authentication")
        self.user = user
        self.bug = self.bugzilla.getbug(self.bug_num)
 def setUp(self):
     if not os.path.exists(TEST_WORK_DIR):
         os.makedirs(TEST_WORK_DIR)
     helper = Helpers()
     helper.set_work_dir(TEST_WORK_DIR)
     helper._get_file(TEST_SRPM)
     helper._get_file(TEST_SRC)
     helper._get_file(TEST_SPEC)
     del helper 
Example #3
0
 def __init__(self, base, plugin_path):
     Helpers.__init__(self)
     self.plugin_path = plugin_path
     self.version = None
     self.spec = base.spec
     self.srpm = base.srpm
     self.sources = base.sources
     self.encoder = ReviewJSONEncoder()
     self.decoder = JSONDecoder()
     self.results = []
     self.plug_in = None
     self.plug_out = None
     self.plug_err = None
Example #4
0
    def __init__(self, bug, user=None, password=None):
        """ Constructor.
        :arg bug, the bug number on bugzilla
        :kwarg user, the username with which to log in in bugzilla.
        :kwarg password, the password associated with this account.
        be re-downloaded or not.
        """
        Helpers.__init__(self)
        self.bug_num = bug
        self.spec_url = None
        self.srpm_url = None
        self.spec_file = None
        self.srpm_file = None
        self.log = get_logger()
        if Settings.other_bz:
            self.bugzilla = Bugzilla(url=Settings.other_bz + '/xmlrpc.cgi')
        else:
            self.bugzilla = Bugzilla(url=BZ_URL)

        self.log.info("Trying bugzilla cookies for authentication")
        self.user = user
        self.bug = self.bugzilla.getbug(self.bug_num)
Example #5
0
 def __init__(self, methodName='runTest'):
     unittest.TestCase.__init__(self, methodName)
     self.srpm_file = TEST_WORK_DIR + os.path.basename(TEST_SRPM)
     self.spec_file = TEST_WORK_DIR + os.path.basename(TEST_SPEC)
     self.source_file = TEST_WORK_DIR + os.path.basename(TEST_SRC)
     self.helper = Helpers()
Example #6
0
class MiscTests(unittest.TestCase):
    def __init__(self, methodName='runTest'):
        unittest.TestCase.__init__(self, methodName)
        self.srpm_file = TEST_WORK_DIR + os.path.basename(TEST_SRPM)
        self.spec_file = TEST_WORK_DIR + os.path.basename(TEST_SPEC)
        self.source_file = TEST_WORK_DIR + os.path.basename(TEST_SRC)
        self.helper = Helpers()

    def setUp(self):
        if not os.path.exists(TEST_WORK_DIR):
            os.makedirs(TEST_WORK_DIR)
        self.helper.set_work_dir(TEST_WORK_DIR)
        self.helper._get_file(TEST_SRPM)
        #self.helper._get_file(TEST_SRC)
        self.helper._get_file(TEST_SPEC)


    def test_spec_file(self):
        ''' Test the SpecFile class'''
        spec = SpecFile(self.spec_file) 
        # Test misc rpm values (Macro resolved)
        self.assertEqual(spec.name,'python-test')
        self.assertEqual(spec.version,'1.0')
        # resolve the dist-tag
        dist = self.helper._run_cmd('rpm --eval %dist')[:-1]
        self.assertEqual(spec.release,'1'+dist)
        # test misc rpm values (without macro resolve)
        self.assertEqual(spec.find_tag('Release'), ['1%{?dist}'])
        self.assertEqual(spec.find_tag('License'), ['GPLv2+'])
        self.assertEqual(spec.find_tag('Group'), ['Development/Languages'])
        # Test rpm value not there
        self.assertEqual(spec.find_tag('PreReq'), [])
        # Test get sections
        expected = {'%clean': ['rm -rf $RPM_BUILD_ROOT']}
        self.assertEqual(spec.get_section('%clean'), expected)
        expected = {'%build': ['%{__python} setup.py build']}
        self.assertEqual(spec.get_section('%build'), expected)
        expected = {'%install': ['rm -rf $RPM_BUILD_ROOT', '%{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT']}
        self.assertEqual(spec.get_section('%install'),expected)
        expected = {'%files': ['%defattr(-,root,root,-)', '%doc COPYING', '%{python_sitelib}/*']}
        self.assertEqual(spec.get_section('%files'),expected)
        # Test get_sources (return the Source/Patch lines with macros resolved)
        expected = {'Source0': 'http://timlau.fedorapeople.org/files/test/review-test/python-test-1.0.tar.gz'}
        self.assertEqual(spec.get_sources(), expected)
        # Test find
        regex = re.compile(r'^Release\s*:\s*(.*)')
        res = spec.find(regex)
        if res:
            self.assertEqual(res.groups(), ('1%{?dist}',))
        else:
            self.assertTrue(False)
            
        
        
    def test_source_file(self):
        """ Test the SourceFile class """
        source = Source()
        # set the work dir
        source.set_work_dir(TEST_WORK_DIR)
        # download the upstream source file
        source.get_source(TEST_SRC)
        # check that source exists and source.filename point to the right location
        self.assertEqual(source.filename, self.source_file)
        self.assertTrue(os.path.exists(self.source_file))
        self.assertEqual(source.check_source_md5(), "289cb714af3a85fe36a51fa3612b57ad")
        
    def test_srpm_file(self):
        """ Test the SRPMFile class """
        srpm = SRPMFile(self.srpm_file)
        # install the srpm
        srpm.install()
        self.assertTrue(srpm.is_installed)
        src_files = glob.glob(os.path.expanduser('~/rpmbuild/SOURCES/*'))
        expected = os.path.expanduser('~/rpmbuild/SOURCES/python-test-1.0.tar.gz')
        self.assertTrue(expected in src_files)
        # Generate the config file for the current OS run
        release = self.helper._run_cmd('rpm --eval %{fedora}')[:-1]
        arch = self.helper._run_cmd('arch')[:-1]
        srpm.mock_config = 'fedora-%s-%s' % (release, arch)
        # Do the mock build
        srpm.build(silence=True)
        self.assertTrue(srpm.is_build)
        # Retrieve the list of files in the mock folder and below
        rpm_files = []
        for root, dirs, files in os.walk(srpm.get_mock_dir()):
            rpm_files.extend(files)
        dist = self.helper._run_cmd('rpm --eval %dist')[:-1]
        expected = os.path.expanduser('python-test-1.0-1%(dist)s.noarch.rpm') % {'dist': dist}
        self.assertTrue(expected in rpm_files)