Merge "Expose version_between as a real function"
This commit is contained in:
commit
db5aa8b3ae
@ -323,7 +323,7 @@ def version_to_string(version):
|
||||
return ".".join(map(_str_or_latest, version))
|
||||
|
||||
|
||||
def _version_between(min_version, max_version, candidate):
|
||||
def version_between(min_version, max_version, candidate):
|
||||
"""Determine whether a candidate version is within a specified range.
|
||||
|
||||
:param min_version: The minimum version that is acceptable.
|
||||
@ -714,7 +714,7 @@ class Discover(object):
|
||||
if _latest_soft_match(min_version, data['version']):
|
||||
return data
|
||||
# Only validate version bounds if versions were specified
|
||||
if min_version and max_version and _version_between(
|
||||
if min_version and max_version and version_between(
|
||||
min_version, max_version, data['version']):
|
||||
return data
|
||||
|
||||
@ -1235,7 +1235,7 @@ class EndpointData(object):
|
||||
else:
|
||||
# `is_between` means version bounds were specified *and* the URL
|
||||
# version is between them.
|
||||
is_between = min_version and max_version and _version_between(
|
||||
is_between = min_version and max_version and version_between(
|
||||
min_version, max_version, url_version)
|
||||
exact_match = (is_between and max_version and
|
||||
max_version[0] == url_version[0])
|
||||
|
@ -395,14 +395,14 @@ class DiscoverUtils(utils.TestCase):
|
||||
|
||||
def test_version_between(self):
|
||||
def good(minver, maxver, cand):
|
||||
self.assertTrue(discover._version_between(minver, maxver, cand))
|
||||
self.assertTrue(discover.version_between(minver, maxver, cand))
|
||||
|
||||
def bad(minver, maxver, cand):
|
||||
self.assertFalse(discover._version_between(minver, maxver, cand))
|
||||
self.assertFalse(discover.version_between(minver, maxver, cand))
|
||||
|
||||
def exc(excls, minver, maxver, cand):
|
||||
self.assertRaises(excls,
|
||||
discover._version_between, minver, maxver, cand)
|
||||
discover.version_between, minver, maxver, cand)
|
||||
|
||||
# candidate required
|
||||
exc(ValueError, (1, 0), (1, 0), None)
|
||||
|
5
releasenotes/notes/version-between-b4b0bcf4cecfb9e4.yaml
Normal file
5
releasenotes/notes/version-between-b4b0bcf4cecfb9e4.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Exposed ``keystoneauth1.discover.version_between`` as a public function
|
||||
that can be used to determine if a given version is within a range.
|
Loading…
Reference in New Issue
Block a user