Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_add_changelog_section(self):
f = open('test_modify_changelog2')
c = f.read()
f.close()
cl = changelog.Changelog(c)
cl.new_block(package='gnutls14',
version=changelog.Version('1:1.4.1-3'),
distributions='experimental',
urgency='low',
author='James Westby ')
self.assertRaises(changelog.ChangelogCreateError, cl.__str__)
cl.set_date('Sat, 16 Jul 2008 11:11:08 +0200')
cl.add_change('')
cl.add_change(' * Foo did not work, let us try bar')
cl.add_change('')
f = open('test_modify_changelog3')
c = f.read()
f.close()
clines = c.split('\n')
cslines = str(cl).split('\n')
def test_add_changelog_section(self):
f = open('test_modify_changelog2')
c = f.read()
f.close()
cl = changelog.Changelog(c)
cl.new_block(package='gnutls14',
version=changelog.Version('1:1.4.1-3'),
distributions='experimental',
urgency='low',
author='James Westby ')
self.assertRaises(changelog.ChangelogCreateError, cl.__str__)
cl.set_date('Sat, 16 Jul 2008 11:11:08 +0200')
cl.add_change('')
cl.add_change(' * Foo did not work, let us try bar')
cl.add_change('')
f = open('test_modify_changelog3')
c = f.read()
f.close()
def test_magic_version_properties(self):
f = open('test_changelog')
c = changelog.Changelog(f)
f.close()
self.assertEqual(c.debian_version, '1')
self.assertEqual(c.full_version, '1:1.4.1-1')
self.assertEqual(c.upstream_version, '1.4.1')
self.assertEqual(c.epoch, '1')
self.assertEqual(str(c.version), c.full_version)
def test_set_version_with_string(self):
f = open('test_modify_changelog1')
c1 = changelog.Changelog(f.read())
f.seek(0)
c2 = changelog.Changelog(f.read())
f.close()
c1.version = '1:2.3.5-2'
c2.version = changelog.Version('1:2.3.5-2')
self.assertEqual(c1.version, c2.version)
self.assertEqual((c1.full_version, c1.epoch, c1.upstream_version,
c1.debian_version),
(c2.full_version, c2.epoch, c2.upstream_version,
c2.debian_version))
def test_unicode_object_input(self):
f = open('test_changelog_unicode')
c_str = f.read()
f.close()
c_unicode = c_str.decode('utf-8')
c = changelog.Changelog(c_unicode)
self.assertEqual(unicode(c), c_unicode)
self.assertEqual(str(c), c_str)
def test_set_version_with_string(self):
f = open('test_modify_changelog1')
c1 = changelog.Changelog(f.read())
f.seek(0)
c2 = changelog.Changelog(f.read())
f.close()
c1.version = '1:2.3.5-2'
c2.version = changelog.Version('1:2.3.5-2')
self.assertEqual(c1.version, c2.version)
self.assertEqual((c1.full_version, c1.epoch, c1.upstream_version,
c1.debian_version),
(c2.full_version, c2.epoch, c2.upstream_version,
c2.debian_version))
self._test_version('20060611-0.0', None, '20060611', '0.0')
self._test_version('0.52.2-5.1', None, '0.52.2', '5.1')
self._test_version('7.0-035+1', None, '7.0', '035+1')
self._test_version('1.1.0+cvs20060620-1+2.6.15-8', None,
'1.1.0+cvs20060620-1+2.6.15', '8')
self._test_version('1.1.0+cvs20060620-1+1.0', None,
'1.1.0+cvs20060620', '1+1.0')
self._test_version('4.2.0a+stable-2sarge1', None, '4.2.0a+stable',
'2sarge1')
self._test_version('1.8RC4b', None, '1.8RC4b', None)
self._test_version('0.9~rc1-1', None, '0.9~rc1', '1')
self._test_version('2:1.0.4+svn26-1ubuntu1', '2', '1.0.4+svn26',
'1ubuntu1')
self._test_version('2:1.0.4~rc2-1', '2', '1.0.4~rc2', '1')
self.assertRaises(
ValueError, changelog.Version, 'a1:1.8.8-070403-1~priv1')
def _test_version(self, full_version, epoch, upstream, debian):
v = changelog.Version(full_version)
self.assertEqual(v.full_version, full_version, "Full version broken")
self.assertEqual(v.epoch, epoch, "Epoch broken")
self.assertEqual(v.upstream_version, upstream, "Upstram broken")
self.assertEqual(v.debian_version, debian, "Debian broken")
elif args.action == 'rewrite':
changelog.to_file(args.file)
elif args.action == 'extract':
for version in changelog.versions:
if version.name == args.version:
print version.get_release_notes()
break
else:
print >> sys.stderr, "ERROR: Couldn't find version '%s'." % (
args.version)
sys.exit(1)
elif args.action == 'add':
gitlab = GitlabRequest(url=args.gitlab_url, repo=args.repo,
token=args.token)
now = datetime.datetime.now()
version = Version(args.version,
int(now.day), MONTHS[now.month - 1], int(now.year))
last_version = None
since = None
if changelog.versions:
last_version = changelog.versions[0]
print >> sys.stderr, "INFO: Last version is '%s'." % (
last_version.name)
try:
last_tag = gitlab.get(
'repository/tags/%s' % last_version.name
)
except:
print >> sys.stderr, ("ERROR: Can't find previous release "
"'%s' on Gitlab." % last_version.name)
raise
since = dateutil.parser.parse(last_tag['commit']['committed_date'])
elif args.action == 'rewrite':
changelog.to_file(args.file)
elif args.action == 'extract':
for version in changelog.versions:
if version.name == args.version:
print version.get_release_notes()
break
else:
print >> sys.stderr, "ERROR: Couldn't find version '%s'." % (
args.version)
sys.exit(1)
elif args.action == 'add':
gitlab = GitlabRequest(url=args.gitlab_url, repo=args.repo,
token=args.token)
now = datetime.datetime.now()
version = Version(args.version,
int(now.day), MONTHS[now.month - 1], int(now.year))
last_version = None
since = None
if changelog.versions:
last_version = changelog.versions[0]
print >> sys.stderr, "INFO: Last version is '%s'." % (
last_version.name)
try:
last_tag = gitlab.get(
'repository/tags/%s' % last_version.name
)
except:
print >> sys.stderr, ("ERROR: Can't find previous release "
"'%s' on Gitlab." % last_version.name)
raise
since = dateutil.parser.parse(last_tag['commit']['committed_date'])