import unittest
-from tests.testutils import DebianGitTestRepo, OsReleaseFile
+from tests.testutils import (DebianGitTestRepo, OsReleaseFile,
+ get_dch_default_urgency)
from gbp.scripts import dch
import os
import re
+# Older dch compatibility
+default_urgency = get_dch_default_urgency()
+
# For Ubuntu compatibility
os_release = OsReleaseFile('/etc/lsb-release')
# OS release codename and snapshot of version 0.9-2~1
if os_release['DISTRIB_ID'] == 'Ubuntu':
os_codename = os_release['DISTRIB_CODENAME']
- snap_header_0_9 = r'^test-package\s\(0.9-1ubuntu1~1\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=medium'
+ snap_header_0_9 = r'^test-package\s\(0.9-1ubuntu1~1\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=%s' % default_urgency
new_version_0_9 = '0.9-1ubuntu1'
else:
os_codename = 'unstable'
- snap_header_0_9 = r'^test-package\s\(0.9-2~1\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=medium'
+ snap_header_0_9 = r'^test-package\s\(0.9-2~1\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=%s' % default_urgency
new_version_0_9 = '0.9-2'
# Snapshot of version 1.0-1~1
-snap_header_1 = r'^test-package\s\(1.0-1~1\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=medium'
+snap_header_1 = r'^test-package\s\(1.0-1~1\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=%s' % default_urgency
# Snapshot of version 1.0-1~2
-snap_header_1_2 = r'^test-package\s\(1.0-1~2\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=medium'
+snap_header_1_2 = r'^test-package\s\(1.0-1~2\.gbp([0-9a-f]{6})\)\sUNRELEASED;\surgency=%s' % default_urgency
snap_mark = r'\s{2}\*{2}\sSNAPSHOT\sbuild\s@'
deb_tag = "debian/0.9-1"
deb_tag_msg = "Pre stable release version 0.9-1"
-cl_debian = """test-package (0.9-1) unstable; urgency=medium
+cl_debian = """test-package (0.9-1) unstable; urgency=%s
[ Debian Maintainer ]
* New pre stable upstream release
-- Debian Maintainer <maint@debian.org> Mon, 17 Oct 2011 10:15:22 +0200
-"""
+""" % default_urgency
@unittest.skipIf(not os.path.exists('/usr/bin/dch'), "Dch not found")
def test_dch_main_new_upstream_version(self):
"""Test dch.py like git-dch script does: new upstream version"""
lines = self.run_dch()
- self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=medium\n", lines[0])
+ self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=%s\n" % default_urgency, lines[0])
self.assertIn(""" * added debian/control\n""", lines)
"""Test dch.py like git-dch script does: new upstream version - release"""
options = ["--release"]
lines = self.run_dch(options)
- self.assertEqual("test-package (1.0-1) %s; urgency=medium\n" % os_codename, lines[0])
+ self.assertEqual("test-package (1.0-1) %s; urgency=%s\n" % (os_codename, default_urgency), lines[0])
self.assertIn(""" * added debian/control\n""", lines)
"""Test dch.py like git-dch script does: new upstream version - guess last commit"""
options = ["--auto"]
lines = self.run_dch(options)
- self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=medium\n", lines[0])
+ self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=%s\n" % default_urgency, lines[0])
self.assertIn(""" * added debian/control\n""", lines)
"""Test dch.py like git-dch script does: new upstream version - auto - release"""
options = ["--auto", "--release"]
lines = self.run_dch(options)
- self.assertEqual("test-package (1.0-1) %s; urgency=medium\n" % os_codename, lines[0])
+ self.assertEqual("test-package (1.0-1) %s; urgency=%s\n" % (os_codename, default_urgency), lines[0])
self.assertIn(""" * added debian/control\n""", lines)
"""Test dch.py like git-dch script does: new upstream version - set distribution"""
options = ["--distribution=testing", "--force-distribution"]
lines = self.run_dch(options)
- self.assertEqual("test-package (1.0-1) testing; urgency=medium\n", lines[0])
+ self.assertEqual("test-package (1.0-1) testing; urgency=%s\n" % default_urgency, lines[0])
self.assertIn(""" * added debian/control\n""", lines)
"""Test dch.py like git-dch script does: new upstream version - release - set distribution"""
options = ["--release", "--distribution=testing", "--force-distribution"]
lines = self.run_dch(options)
- self.assertEqual("test-package (1.0-1) testing; urgency=medium\n", lines[0])
+ self.assertEqual("test-package (1.0-1) testing; urgency=%s\n" % default_urgency, lines[0])
self.assertIn(""" * added debian/control\n""", lines)
self.repo.create_tag("debian/0.9-1", msg="Pre stable release version 0.9-1", commit="HEAD~2")
self.repo.delete_tag("upstream/1.0")
lines = self.run_dch()
- self.assertEqual("test-package (%s) UNRELEASED; urgency=medium\n" % new_version_0_9, lines[0])
+ self.assertEqual("test-package (%s) UNRELEASED; urgency=%s\n" % (new_version_0_9, default_urgency), lines[0])
self.assertIn(""" * added debian/control\n""", lines)
self.repo.delete_tag("upstream/1.0")
options = ["--release"]
lines = self.run_dch(options)
- self.assertEqual("test-package (%s) %s; urgency=medium\n" % (new_version_0_9, os_codename), lines[0])
+ self.assertEqual("test-package (%s) %s; urgency=%s\n" % (new_version_0_9, os_codename, default_urgency), lines[0])
self.assertIn(""" * added debian/control\n""", lines)
self.repo.delete_tag("upstream/1.0")
options = ["--auto"]
lines = self.run_dch(options)
- self.assertEqual("test-package (%s) UNRELEASED; urgency=medium\n" % new_version_0_9, lines[0])
+ self.assertEqual("test-package (%s) UNRELEASED; urgency=%s\n" % (new_version_0_9, default_urgency), lines[0])
self.assertIn(""" * added debian/control\n""", lines)
self.repo.delete_tag("upstream/1.0")
options = ["--auto", "--release"]
lines = self.run_dch(options)
- self.assertEqual("test-package (%s) %s; urgency=medium\n" % (new_version_0_9, os_codename), lines[0])
+ self.assertEqual("test-package (%s) %s; urgency=%s\n" % (new_version_0_9, os_codename, default_urgency), lines[0])
self.assertIn(""" * added debian/control\n""", lines)