diff options
author | Daniel Dehennin <daniel.dehennin@baby-gnu.org> | 2012-05-30 21:30:45 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2013-03-29 13:08:23 +0100 |
commit | a9bf9cfd4b31076c54d4e377c1b31b5bd69f8661 (patch) | |
tree | 0df3fdd5a8a7bf006432c4eac1a5048e6f62bbd3 /tests | |
parent | ea544accfd549d76618a10d831ce7e830fd0785a (diff) | |
download | git-buildpackage-a9bf9cfd4b31076c54d4e377c1b31b5bd69f8661.tar.gz git-buildpackage-a9bf9cfd4b31076c54d4e377c1b31b5bd69f8661.tar.bz2 git-buildpackage-a9bf9cfd4b31076c54d4e377c1b31b5bd69f8661.zip |
Move debian/changelog manipulation to gbp.deb.changelog.ChangeLog.
spawn_dch switch gbp.command.wrappers.Command.
* gbp/deb/changelog.py (ChangeLog.spawn_dch): static method adapted from
gbp.scripts.dch and converted to gbp.command_wrappers.Command.
(add_entry): New method adapted from
gbp.scripts.dch.add_changelog_entry.
(add_section): New method adapted from
gbp.scripts.dch.add_changelog_entry. Remove DebianGitRepository and
options, this has nothing to do with changelog management.
* tests/test_Changelog.py: Test new methods.
* gbp/scripts/dch.py: Remove useless functions: system(), spawn_dch(),
add_changelog_section() and add_changelog_entry().
Update calls accordingly.
(fixup_trailer): Use spawn_dch() method of ChangeLog class.
(process_options): dch_options became a list.
(main): Use add_section() and add_entry() methods of ChangeLog object.
Take care of upstream version since ChangeLog.add_section() does not
manage it anymore.
Update exception handling, ChangeLog.spawn_dch() can raise
"CommandExecFailed" exception.
Closes: #672954
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_Changelog.py | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/test_Changelog.py b/tests/test_Changelog.py index c67aaa06..5516d032 100644 --- a/tests/test_Changelog.py +++ b/tests/test_Changelog.py @@ -223,3 +223,88 @@ def test_parse_sections(): >>> cl.sections[1].version '0.5.31' """ + +def test_add_section(): + """ + Test if we can add a section to an existant changelog + + Methods tested: + - L{gbp.deb.changelog.ChangeLog.__init__} + - L{gbp.deb.changelog.ChangeLog._parse} + - L{gbp.deb.changelog.ChangeLog.add_section} + - L{gbp.deb.changelog.ChangeLog.spawn_dch} + + >>> import os + >>> import tempfile + >>> import shutil + >>> import gbp.deb.changelog + >>> olddir = os.path.abspath(os.path.curdir) + >>> testdir = tempfile.mkdtemp(prefix='gbp-test-changelog-') + >>> testdebdir = os.path.join(testdir, 'debian') + >>> testclname = os.path.join(testdebdir, "changelog") + >>> os.mkdir(testdebdir) + >>> clh = open(os.path.join(testdebdir, "changelog"), "w") + >>> clh.write(cl_debian) + >>> clh.close() + >>> os.chdir(testdir) + >>> os.path.abspath(os.path.curdir) == testdir + True + >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname) + >>> cl.add_section(msg=["Test add section"], distribution=None, author="Debian Maintainer", email="maint@debian.org") + >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname) + >>> cl.version + '0.5.33' + >>> cl.debian_version + '0.5.33' + >>> cl['Distribution'] + 'UNRELEASED' + >>> 'Test add section' in cl['Changes'] + True + >>> os.chdir(olddir) + >>> os.path.abspath(os.path.curdir) == olddir + True + >>> shutil.rmtree(testdir, ignore_errors=True) + """ + +def test_add_entry(): + """ + Test if we can add an entry to an existant changelog + + Methods tested: + - L{gbp.deb.changelog.ChangeLog.__init__} + - L{gbp.deb.changelog.ChangeLog._parse} + - L{gbp.deb.changelog.ChangeLog.add_entry} + - L{gbp.deb.changelog.ChangeLog.spawn_dch} + + >>> import os + >>> import tempfile + >>> import shutil + >>> import gbp.deb.changelog + >>> olddir = os.path.abspath(os.path.curdir) + >>> testdir = tempfile.mkdtemp(prefix='gbp-test-changelog-') + >>> testdebdir = os.path.join(testdir, 'debian') + >>> testclname = os.path.join(testdebdir, "changelog") + >>> os.mkdir(testdebdir) + >>> clh = open(os.path.join(testdebdir, "changelog"), "w") + >>> clh.write(cl_debian) + >>> clh.close() + >>> os.chdir(testdir) + >>> os.path.abspath(os.path.curdir) == testdir + True + >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname) + >>> cl.add_section(msg=["Test add section"], distribution=None, author="Debian Maintainer", email="maint@debian.org") + >>> cl.add_entry(msg=["Test add entry"], author="Debian Maintainer", email="maint@debian.org") + >>> cl = gbp.deb.changelog.ChangeLog(filename=testclname) + >>> cl.version + '0.5.33' + >>> cl.debian_version + '0.5.33' + >>> cl['Distribution'] + 'UNRELEASED' + >>> 'Test add entry' in cl['Changes'] + True + >>> os.chdir(olddir) + >>> os.path.abspath(os.path.curdir) == olddir + True + >>> shutil.rmtree(testdir, ignore_errors=True) + """ |