diff options
author | Guido Günther <agx@sigxcpu.org> | 2017-08-02 01:32:37 -0300 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2017-08-02 10:35:05 -0300 |
commit | 7b32cac1ebc6e297b423ab1ab08f41ef5fe5b502 (patch) | |
tree | 2f00fc5ac6fa5bae8f608f0bcf712bd5047adb4e /tests/component | |
parent | 8283155f4a12f770ec078b531a306ddd9d6e8b3b (diff) |
dch: test customizations
and fail properly when the file can't be found
Diffstat (limited to 'tests/component')
-rw-r--r-- | tests/component/deb/test_dch.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/component/deb/test_dch.py b/tests/component/deb/test_dch.py new file mode 100644 index 00000000..053597e6 --- /dev/null +++ b/tests/component/deb/test_dch.py @@ -0,0 +1,63 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2017 Guido Günther <agx@sigxcpu.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# <http://www.gnu.org/licenses/> + +import os + +from tests.component import ComponentTestBase +from tests.component.deb import DEB_TEST_DATA_DIR +from tests.component.deb.fixtures import RepoFixtures + +import gbp.scripts.dch +from gbp.scripts.dch import main as dch + +from nose.tools import ok_ + + +def _dsc_file(pkg, version, dir='dsc-3.0'): + return os.path.join(DEB_TEST_DATA_DIR, dir, '%s_%s.dsc' % (pkg, version)) + + +DEFAULT_DSC = _dsc_file('hello-debhelper', '2.6-2') + + +class TestDch(ComponentTestBase): + """Test importing of new upstream versions""" + pkg = "hello-debhelper" + def_branches = ['master', 'upstream', 'pristine-tar'] + + @RepoFixtures.quilt30(DEFAULT_DSC) + def test_user_customizations(self, repo): + os.chdir(repo.path) + # Non-existent customization file + ok_(dch(['arg0', '--customizations=customizations.py']) == 1, + "dch did no fail as expected") + + # Create user customizations file + with open('customizations.py', 'w') as fobj: + fobj.write("""def format_changelog_entry(commit_info, options, last_commit=False): + return ['testentry'] +""") + # Add the file so we have a change + repo.add_files(['customizations.py']) + repo.commit_all(msg="test customizations") + ok_(dch(['arg0', '-S', '-a', '--customizations=customizations.py']) == 0, + "dch did no succeed as expected") + with open("debian/changelog") as f: + cl = f.read() + ok_('* testentry\n' in cl) + del gbp.scripts.dch.user_customizations['format_changelog_entry'] |