def test_normalize_pack_version(self): # Already a valid semver version string self.assertEqual(normalize_pack_version('0.2.0'), '0.2.0') self.assertEqual(normalize_pack_version('0.2.1'), '0.2.1') self.assertEqual(normalize_pack_version('1.2.1'), '1.2.1') # Not a valid semver version string self.assertEqual(normalize_pack_version('0.2'), '0.2.0') self.assertEqual(normalize_pack_version('0.3'), '0.3.0') self.assertEqual(normalize_pack_version('1.3'), '1.3.0') self.assertEqual(normalize_pack_version('2.0'), '2.0.0')
def test_normalize_pack_version(self): # Already a valid semver version string self.assertEqual(normalize_pack_version("0.2.0"), "0.2.0") self.assertEqual(normalize_pack_version("0.2.1"), "0.2.1") self.assertEqual(normalize_pack_version("1.2.1"), "1.2.1") # Not a valid semver version string self.assertEqual(normalize_pack_version("0.2"), "0.2.0") self.assertEqual(normalize_pack_version("0.3"), "0.3.0") self.assertEqual(normalize_pack_version("1.3"), "1.3.0") self.assertEqual(normalize_pack_version("2.0"), "2.0.0")
def __init__(self, **values): name = values.get('name', None) # Note: If some version values are not explicitly surrounded by quotes they are recognized # as numbers so we cast them to string if values.get('version', None): values['version'] = str(values['version']) # Special case for old version which didn't follow semver format (e.g. 0.1, 1.0, etc.) # In case the version doesn't match that format, we simply append ".0" to the end (e.g. # 0.1 -> 0.1.0, 1.0, -> 1.0.0, etc.) if NORMALIZE_PACK_VERSION: new_version = normalize_pack_version(version=values['version']) if new_version != values['version']: LOG.warning('Pack "%s" contains invalid semver version specifer, casting it to a ' 'full semver version specifier (%s -> %s).\n' 'Short versions will become INVALID in StackStorm 2.2, and the pack ' 'will stop working. Update the pack version in "pack.yaml".' % (name, values['version'], new_version)) values['version'] = new_version super(PackAPI, self).__init__(**values)
def __init__(self, **values): name = values.get('name', None) # Note: If some version values are not explicitly surrounded by quotes they are recognized # as numbers so we cast them to string if values.get('version', None): values['version'] = str(values['version']) # Special case for old version which didn't follow semver format (e.g. 0.1, 1.0, etc.) # In case the version doesn't match that format, we simply append ".0" to the end (e.g. # 0.1 -> 0.1.0, 1.0, -> 1.0.0, etc.) if NORMALIZE_PACK_VERSION: new_version = normalize_pack_version(version=values['version']) if new_version != values['version']: LOG.warning( 'Pack "%s" contains invalid semver version specifer, casting it to a ' 'full semver version specifier (%s -> %s).\n' 'Short versions will become INVALID in StackStorm 2.2, and the pack ' 'will stop working. Update the pack version in "pack.yaml".' % (name, values['version'], new_version)) values['version'] = new_version super(PackAPI, self).__init__(**values)