diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_rpm.py | 38 | ||||
-rw-r--r-- | tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec | 13 | ||||
-rw-r--r-- | tests/test_rpm_data/specs/gbp-test-reference2.spec | 3 | ||||
-rw-r--r-- | tests/test_rpm_data/specs/gbp-test2-reference.spec | 12 | ||||
-rw-r--r-- | tests/test_rpm_data/specs/gbp-test2-reference2.spec | 13 |
5 files changed, 75 insertions, 4 deletions
diff --git a/tests/test_rpm.py b/tests/test_rpm.py index b6d1c699..f9f08dde 100644 --- a/tests/test_rpm.py +++ b/tests/test_rpm.py @@ -20,7 +20,7 @@ import filecmp import os import shutil import tempfile -from nose.tools import assert_raises +from nose.tools import assert_raises, eq_ from gbp.errors import GbpError from gbp.rpm import (SrcRpmFile, SpecFile, parse_srpm, NoSpecError, guess_spec, @@ -179,15 +179,16 @@ class TestSpecFile(object): spec.write_spec_file() assert filecmp.cmp(tmp_spec, reference_spec) is True - # Test adding the VCS tag + # Test adding the VCS tag and adding changelog reference_spec = os.path.join(SPEC_DIR, 'gbp-test-reference2.spec') spec.set_tag('VCS', None, 'myvcstag') + spec.set_changelog("* Wed Feb 05 2014 Name <email> 1\n- New entry\n") spec.write_spec_file() assert filecmp.cmp(tmp_spec, reference_spec) is True def test_update_spec2(self): """Another test for spec autoupdate functionality""" - tmp_spec = os.path.join(self.tmpdir, 'gbp-test.spec') + tmp_spec = os.path.join(self.tmpdir, 'gbp-test2.spec') shutil.copy2(os.path.join(SPEC_DIR, 'gbp-test2.spec'), tmp_spec) reference_spec = os.path.join(SPEC_DIR, 'gbp-test2-reference2.spec') @@ -199,10 +200,12 @@ class TestSpecFile(object): spec.write_spec_file() assert filecmp.cmp(tmp_spec, reference_spec) is True - # Test updating patches again and removing the VCS tag + # Test updating patches again, removing the VCS tag and re-writing + # changelog reference_spec = os.path.join(SPEC_DIR, 'gbp-test2-reference.spec') spec.update_patches(['new.patch'], {'new.patch': {'if': '1'}}) spec.set_tag('VCS', None, '') + spec.set_changelog("* Wed Feb 05 2014 Name <email> 2\n- New entry\n\n") spec.write_spec_file() assert filecmp.cmp(tmp_spec, reference_spec) is True @@ -245,6 +248,33 @@ class TestSpecFile(object): spec.write_spec_file() assert filecmp.cmp(tmp_spec, reference_spec) is True + def test_modifying_err(self): + """Test error conditions of modification methods""" + spec_filepath = os.path.join(SPEC_DIR, 'gbp-test2.spec') + spec = SpecFileTester(spec_filepath) + + # Unknown/invalid section name + with assert_raises(GbpError): + spec.protected('_set_section')('patch', 'new content\n') + + # Multiple sections with the same name + with assert_raises(GbpError): + spec.protected('_set_section')('files', '%{_sysconfdir}/foo\n') + + def test_changelog(self): + """Test changelog methods""" + spec_filepath = os.path.join(SPEC_DIR, 'gbp-test2.spec') + spec = SpecFile(spec_filepath) + + # Read changelog + eq_(spec.get_changelog(), + "* Tue Feb 04 2014 Name <email> 1\n- My change\n\n\n") + + # Set changelog and check again + new_text = "* Wed Feb 05 2014 Name <email> 2\n- New entry\n\n\n" + spec.set_changelog(new_text) + eq_(spec.get_changelog(), new_text) + def test_quirks(self): """Test spec that is broken/has anomalities""" spec_filepath = os.path.join(SPEC_DIR, 'gbp-test-quirks.spec') diff --git a/tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec b/tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec index dd9e2ec2..8a92725d 100644 --- a/tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec +++ b/tests/test_rpm_data/rpmbuild/SPECS/gbp-test2.spec @@ -18,6 +18,12 @@ VCS: myoldvcstag %description Package for testing the RPM functionality of git-buildpackage. +%package empty +Summary: Empty subpackage + +%description empty +Empty subpackage for the %{name} test package. + %prep %setup -T -n %{name}-%{version} -c -a 10 @@ -40,8 +46,15 @@ cp -R * %{buildroot}/%{_datadir}/%{name} install %{SOURCE0} %{buildroot}/%{_datadir}/%{name} +%changelog +* Tue Feb 04 2014 Name <email> 1 +- My change + %files %defattr(-,root,root,-) %dir %{_datadir}/%{name} %{_datadir}/%{name} + +%files empty +%defattr(-,root,root,-) diff --git a/tests/test_rpm_data/specs/gbp-test-reference2.spec b/tests/test_rpm_data/specs/gbp-test-reference2.spec index 1cd922b2..0fbe0260 100644 --- a/tests/test_rpm_data/specs/gbp-test-reference2.spec +++ b/tests/test_rpm_data/specs/gbp-test-reference2.spec @@ -42,3 +42,6 @@ install %{SOURCE0} %{buildroot}/%{_datadir}/%{name} %defattr(-,root,root,-) %dir %{_datadir}/%{name} %{_datadir}/%{name} +%changelog +* Wed Feb 05 2014 Name <email> 1 +- New entry diff --git a/tests/test_rpm_data/specs/gbp-test2-reference.spec b/tests/test_rpm_data/specs/gbp-test2-reference.spec index dfd4b91f..1882131f 100644 --- a/tests/test_rpm_data/specs/gbp-test2-reference.spec +++ b/tests/test_rpm_data/specs/gbp-test2-reference.spec @@ -17,6 +17,12 @@ Packager: Markus Lehtonen <markus.lehtonen@linux.intel.com> %description Package for testing the RPM functionality of git-buildpackage. +%package empty +Summary: Empty subpackage + +%description empty +Empty subpackage for the %{name} test package. + %prep %setup -T -n %{name}-%{version} -c -a 10 @@ -42,8 +48,14 @@ cp -R * %{buildroot}/%{_datadir}/%{name} install %{SOURCE0} %{buildroot}/%{_datadir}/%{name} +%changelog +* Wed Feb 05 2014 Name <email> 2 +- New entry %files %defattr(-,root,root,-) %dir %{_datadir}/%{name} %{_datadir}/%{name} + +%files empty +%defattr(-,root,root,-) diff --git a/tests/test_rpm_data/specs/gbp-test2-reference2.spec b/tests/test_rpm_data/specs/gbp-test2-reference2.spec index 0b93f0fa..d41f4503 100644 --- a/tests/test_rpm_data/specs/gbp-test2-reference2.spec +++ b/tests/test_rpm_data/specs/gbp-test2-reference2.spec @@ -19,6 +19,12 @@ VCS: myvcstag %description Package for testing the RPM functionality of git-buildpackage. +%package empty +Summary: Empty subpackage + +%description empty +Empty subpackage for the %{name} test package. + %prep %setup -T -n %{name}-%{version} -c -a 10 @@ -48,8 +54,15 @@ cp -R * %{buildroot}/%{_datadir}/%{name} install %{SOURCE0} %{buildroot}/%{_datadir}/%{name} +%changelog +* Tue Feb 04 2014 Name <email> 1 +- My change + %files %defattr(-,root,root,-) %dir %{_datadir}/%{name} %{_datadir}/%{name} + +%files empty +%defattr(-,root,root,-) |