add tests for versionutils
Change-Id: Ie7648876115baff2e9e6debba0c1cc94a2d10896 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
7e38ca1474
commit
97d975879d
51
openstack_releases/tests/test_versionutils.py
Normal file
51
openstack_releases/tests/test_versionutils.py
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from oslotest import base
|
||||||
|
|
||||||
|
from openstack_releases import versionutils
|
||||||
|
|
||||||
|
|
||||||
|
class TestValidateVersion(base.BaseTestCase):
|
||||||
|
|
||||||
|
def test_valid_std(self):
|
||||||
|
errors = list(versionutils.validate_version('1.2.3'))
|
||||||
|
self.assertEqual(0, len(errors))
|
||||||
|
|
||||||
|
def test_invalid_std(self):
|
||||||
|
errors = list(versionutils.validate_version('1.2.3.4'))
|
||||||
|
self.assertEqual(1, len(errors))
|
||||||
|
|
||||||
|
def test_empty_std(self):
|
||||||
|
errors = list(versionutils.validate_version(''))
|
||||||
|
self.assertEqual(1, len(errors))
|
||||||
|
|
||||||
|
def test_valid_xstatic(self):
|
||||||
|
errors = list(versionutils.validate_version('1.2.3.4',
|
||||||
|
release_type='xstatic'))
|
||||||
|
self.assertEqual(0, len(errors))
|
||||||
|
|
||||||
|
def test_invalid_release_type(self):
|
||||||
|
errors = list(versionutils.validate_version('1.2.3',
|
||||||
|
release_type='nonesuch'))
|
||||||
|
self.assertEqual(1, len(errors))
|
||||||
|
|
||||||
|
def test_pre_not_allowed(self):
|
||||||
|
errors = list(versionutils.validate_version('1.2.3.0rc1',
|
||||||
|
pre_ok=False))
|
||||||
|
self.assertEqual(1, len(errors))
|
||||||
|
|
||||||
|
def test_pre_ok(self):
|
||||||
|
errors = list(versionutils.validate_version('1.2.3.0rc1'))
|
||||||
|
self.assertEqual(0, len(errors))
|
Loading…
Reference in New Issue
Block a user