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_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')
def test_107_changelog_skipping(self): """ Test the case when sourceX is name and we use f-r -n so that file gets mixed up with a directory """ self.init_test('test_regressions', argv=['-rn', self.srpm_file]) ReviewDirs.reset(os.getcwd()) spec = SpecFile(self.spec_file) regex = re.compile('initial fedora') self.assertEqual(len(spec.find_all(regex)), 2) self.assertEqual(len(spec.find_all(regex, True)), 1)
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)
def test_spec_file(self): ''' Test the SpecFile class''' ReviewDirs.reset() ReviewDirs.workdir_setup('.', True) dest = Mock.get_builddir('SOURCES') if not os.path.exists(dest): os.makedirs(dest) self.helpers._get_file(TEST_SPEC, Mock.get_builddir('SOURCES')) 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.helpers._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) os.chdir(self.startdir)