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_equality(self):
v = VersionInfo('1.0')
self.assertEqual(v, VersionInfo('1.0'))
self.assertNotEqual(v, VersionInfo('1.1'))
self.assertNotEqual(v, VersionInfo('1.0', '1.0.0'))
self.assertNotEqual(v, VersionInfo('1.0', aliases=['latest']))
v = VersionInfo('1.0', '1.0.0')
self.assertNotEqual(v, VersionInfo('1.0'))
self.assertNotEqual(v, VersionInfo('1.1'))
self.assertEqual(v, VersionInfo('1.0', '1.0.0'))
self.assertNotEqual(v, VersionInfo('1.0', aliases=['latest']))
v = VersionInfo('1.0', aliases=['latest'])
self.assertNotEqual(v, VersionInfo('1.0'))
self.assertNotEqual(v, VersionInfo('1.1'))
self.assertNotEqual(v, VersionInfo('1.0', '1.0.0'))
self.assertEqual(v, VersionInfo('1.0', aliases=['latest']))
message = subprocess.check_output(['git', 'log', '-1', '--pretty=%B'],
universal_newlines=True).rstrip()
if expected_message:
self.assertEqual(message, expected_message)
else:
self.assertRegex(message,
r'^Set title of \S+ to 1\.0\.1 with mike \S+$')
assertDirectory('.', {
'versions.json',
'1.0',
'1.0/file.txt'
})
with open('versions.json') as f:
self.assertEqual(list(versions.Versions.loads(f.read())), [
versions.VersionInfo('1.0', '1.0.1'),
])
def test_remove_version(self):
versions = Versions()
versions.add('1.0')
v = versions.remove('1.0')
self.assertEqual(v, VersionInfo('1.0'))
self.assertEqual(list(versions), [])
def test_add(self):
versions = Versions()
v = versions.add('1.0')
self.assertEqual(v, VersionInfo('1.0'))
self.assertEqual(list(versions), [
VersionInfo('1.0'),
])
def test_update_alias_aliases(self):
versions = Versions()
versions.add('1.0', '1.0.0', ['latest'])
diff = versions.update('latest', aliases=['greatest'])
self.assertEqual(diff, {'greatest'})
self.assertEqual(list(versions), [
VersionInfo('1.0', '1.0.0', ['latest', 'greatest']),
])
def test_equality(self):
v = VersionInfo('1.0')
self.assertEqual(v, VersionInfo('1.0'))
self.assertNotEqual(v, VersionInfo('1.1'))
self.assertNotEqual(v, VersionInfo('1.0', '1.0.0'))
self.assertNotEqual(v, VersionInfo('1.0', aliases=['latest']))
v = VersionInfo('1.0', '1.0.0')
self.assertNotEqual(v, VersionInfo('1.0'))
self.assertNotEqual(v, VersionInfo('1.1'))
self.assertEqual(v, VersionInfo('1.0', '1.0.0'))
self.assertNotEqual(v, VersionInfo('1.0', aliases=['latest']))
v = VersionInfo('1.0', aliases=['latest'])
self.assertNotEqual(v, VersionInfo('1.0'))
self.assertNotEqual(v, VersionInfo('1.1'))
self.assertNotEqual(v, VersionInfo('1.0', '1.0.0'))
self.assertEqual(v, VersionInfo('1.0', aliases=['latest']))
def add(self, version, title=None, aliases=[], update_aliases=False):
v = _ensure_version(version)
removed_aliases = []
for i in aliases:
key = self.find(i)
if key and key[0] != v:
if not update_aliases or len(key) == 1:
raise ValueError('{!r} already exists'.format(i))
removed_aliases.append(key)
if v in self._data:
self._data[v].update(title, aliases)
else:
if self.find(version):
raise ValueError('{!r} already exists'.format(version))
self._data[v] = VersionInfo(version, title, aliases)
for i in removed_aliases:
self._data[i[0]].aliases.remove(i[1])
return self._data[v]