summaryrefslogtreecommitdiff
path: root/tests/20_test_rpm.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/20_test_rpm.py')
-rw-r--r--tests/20_test_rpm.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/20_test_rpm.py b/tests/20_test_rpm.py
index 98ffbc9b..adf205f5 100644
--- a/tests/20_test_rpm.py
+++ b/tests/20_test_rpm.py
@@ -158,10 +158,15 @@ class TestSpecFile(RpmTestBase):
def test_parse_raw(self):
"""Test parsing of a valid spec file"""
+ assert_raises(NoSpecError, SpecFile, None, None)
+ assert_raises(NoSpecError, SpecFile, 'filename', 'filedata')
+
+ """
with assert_raises(NoSpecError):
SpecFile(None, None)
with assert_raises(NoSpecError):
SpecFile('filename', 'filedata')
+ """
spec_filepath = os.path.join(SPEC_DIR, 'gbp-test.spec')
with open(spec_filepath, 'r') as spec_fd:
@@ -233,22 +238,36 @@ class TestSpecFile(RpmTestBase):
eq_(spec.protected('_patches')(), {})
prev = spec.protected('_delete_tag')('invalidtag', None)
+ assert_raises(GbpError, spec.protected('_set_tag'),
+ 'Version', None, '', prev)
+ assert_raises(GbpError, spec.set_tag,
+ 'invalidtag', None, 'value')
+
+ """
with assert_raises(GbpError):
# Check that setting empty value fails
spec.protected('_set_tag')('Version', None, '', prev)
with assert_raises(GbpError):
# Check that setting invalid tag with public method fails
spec.set_tag('invalidtag', None, 'value')
+ """
# Mangle macros
prev = spec.protected('_delete_special_macro')('patch', -1)
spec.protected('_delete_special_macro')('patch', 123)
spec.protected('_set_special_macro')('patch', 0, 'my new args', prev)
+ assert_raises(GbpError, spec.protected('_delete_special_macro'),
+ 'invalidmacro', 0)
+ assert_raises(GbpError, spec.protected('_set_special_macro'),
+ 'invalidmacro', 0, 'args', prev)
+
+ """
with assert_raises(GbpError):
spec.protected('_delete_special_macro')('invalidmacro', 0)
with assert_raises(GbpError):
spec.protected('_set_special_macro')('invalidmacro', 0, 'args',
prev)
+ """
# Check resulting spec file
spec.write_spec_file()
@@ -260,12 +279,21 @@ class TestSpecFile(RpmTestBase):
spec = SpecFileTester(spec_filepath)
# Unknown/invalid section name
+ assert_raises(GbpError, spec.protected('_set_section'),
+ 'patch', 'new content\n')
+ """
with assert_raises(GbpError):
spec.protected('_set_section')('patch', 'new content\n')
+ """
# Multiple sections with the same name
+ assert_raises(GbpError, spec.protected('_set_section'),
+ 'files', '%{_sysconfdir}/foo\n')
+
+ """
with assert_raises(GbpError):
spec.protected('_set_section')('files', '%{_sysconfdir}/foo\n')
+ """
def test_changelog(self):
"""Test changelog methods"""
@@ -360,13 +388,27 @@ class TestUtilityFunctions(RpmTestBase):
def test_guess_spec(self):
"""Test guess_spec() function"""
# Spec not found
+ assert_raises(NoSpecError, guess_spec,
+ DATA_DIR, recursive=False)
+
+ """
with assert_raises(NoSpecError):
guess_spec(DATA_DIR, recursive=False)
+ """
+
# Multiple spec files
+ assert_raises(NoSpecError, guess_spec,
+ DATA_DIR, recursive=True)
+ assert_raises(NoSpecError, guess_spec,
+ SPEC_DIR, recursive=False)
+
+ """
with assert_raises(NoSpecError):
guess_spec(DATA_DIR, recursive=True)
with assert_raises(NoSpecError):
guess_spec(SPEC_DIR, recursive=False)
+ """
+
# Spec found
spec = guess_spec(SPEC_DIR, recursive=False,
preferred_name = 'gbp-test2.spec')
@@ -388,10 +430,18 @@ class TestUtilityFunctions(RpmTestBase):
repo.commit_all('Add spec file')
# Spec not found
+ assert_raises(NoSpecError, guess_spec_repo,
+ repo, 'HEAD~1', recursive=True)
+ assert_raises(NoSpecError, guess_spec_repo,
+ repo, 'HEAD', recursive=False)
+
+ """
with assert_raises(NoSpecError):
guess_spec_repo(repo, 'HEAD~1', recursive=True)
with assert_raises(NoSpecError):
guess_spec_repo(repo, 'HEAD', recursive=False)
+ """
+
# Spec found
spec = guess_spec_repo(repo, 'HEAD', 'packaging', recursive=False)
spec = guess_spec_repo(repo, 'HEAD', recursive=True)
@@ -400,8 +450,14 @@ class TestUtilityFunctions(RpmTestBase):
eq_(spec.specpath, 'packaging/gbp-test.spec')
# Test spec_from_repo()
+ assert_raises(NoSpecError, spec_from_repo,
+ repo, 'HEAD~1', 'packaging/gbp-test.spec')
+
+ """
with assert_raises(NoSpecError):
spec_from_repo(repo, 'HEAD~1', 'packaging/gbp-test.spec')
+ """
+
spec = spec_from_repo(repo, 'HEAD', 'packaging/gbp-test.spec')
eq_(spec.specfile, 'gbp-test.spec')