summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-05-17 21:06:53 +0000
committerGerrit Code Review <review@openstack.org>2018-05-17 21:06:53 +0000
commitdb5aa8b3aee6d46a105fe62ef504aff92dc96318 (patch)
treef7fc9690b82e3b5c1e1527e3891e28bcdbde019b
parentc3ef1a11b50c82d1544b5f846ad5b02fface1cdc (diff)
parent9e45781eaba457afc90650c13306c309b907f77a (diff)
Merge "Expose version_between as a real function"3.7.0
-rw-r--r--keystoneauth1/discover.py6
-rw-r--r--keystoneauth1/tests/unit/test_discovery.py6
-rw-r--r--releasenotes/notes/version-between-b4b0bcf4cecfb9e4.yaml5
3 files changed, 11 insertions, 6 deletions
diff --git a/keystoneauth1/discover.py b/keystoneauth1/discover.py
index a2d584c..8fe8481 100644
--- a/keystoneauth1/discover.py
+++ b/keystoneauth1/discover.py
@@ -323,7 +323,7 @@ def version_to_string(version):
323 return ".".join(map(_str_or_latest, version)) 323 return ".".join(map(_str_or_latest, version))
324 324
325 325
326def _version_between(min_version, max_version, candidate): 326def version_between(min_version, max_version, candidate):
327 """Determine whether a candidate version is within a specified range. 327 """Determine whether a candidate version is within a specified range.
328 328
329 :param min_version: The minimum version that is acceptable. 329 :param min_version: The minimum version that is acceptable.
@@ -714,7 +714,7 @@ class Discover(object):
714 if _latest_soft_match(min_version, data['version']): 714 if _latest_soft_match(min_version, data['version']):
715 return data 715 return data
716 # Only validate version bounds if versions were specified 716 # Only validate version bounds if versions were specified
717 if min_version and max_version and _version_between( 717 if min_version and max_version and version_between(
718 min_version, max_version, data['version']): 718 min_version, max_version, data['version']):
719 return data 719 return data
720 720
@@ -1235,7 +1235,7 @@ class EndpointData(object):
1235 else: 1235 else:
1236 # `is_between` means version bounds were specified *and* the URL 1236 # `is_between` means version bounds were specified *and* the URL
1237 # version is between them. 1237 # version is between them.
1238 is_between = min_version and max_version and _version_between( 1238 is_between = min_version and max_version and version_between(
1239 min_version, max_version, url_version) 1239 min_version, max_version, url_version)
1240 exact_match = (is_between and max_version and 1240 exact_match = (is_between and max_version and
1241 max_version[0] == url_version[0]) 1241 max_version[0] == url_version[0])
diff --git a/keystoneauth1/tests/unit/test_discovery.py b/keystoneauth1/tests/unit/test_discovery.py
index 53e6394..15490cf 100644
--- a/keystoneauth1/tests/unit/test_discovery.py
+++ b/keystoneauth1/tests/unit/test_discovery.py
@@ -395,14 +395,14 @@ class DiscoverUtils(utils.TestCase):
395 395
396 def test_version_between(self): 396 def test_version_between(self):
397 def good(minver, maxver, cand): 397 def good(minver, maxver, cand):
398 self.assertTrue(discover._version_between(minver, maxver, cand)) 398 self.assertTrue(discover.version_between(minver, maxver, cand))
399 399
400 def bad(minver, maxver, cand): 400 def bad(minver, maxver, cand):
401 self.assertFalse(discover._version_between(minver, maxver, cand)) 401 self.assertFalse(discover.version_between(minver, maxver, cand))
402 402
403 def exc(excls, minver, maxver, cand): 403 def exc(excls, minver, maxver, cand):
404 self.assertRaises(excls, 404 self.assertRaises(excls,
405 discover._version_between, minver, maxver, cand) 405 discover.version_between, minver, maxver, cand)
406 406
407 # candidate required 407 # candidate required
408 exc(ValueError, (1, 0), (1, 0), None) 408 exc(ValueError, (1, 0), (1, 0), None)
diff --git a/releasenotes/notes/version-between-b4b0bcf4cecfb9e4.yaml b/releasenotes/notes/version-between-b4b0bcf4cecfb9e4.yaml
new file mode 100644
index 0000000..36620d5
--- /dev/null
+++ b/releasenotes/notes/version-between-b4b0bcf4cecfb9e4.yaml
@@ -0,0 +1,5 @@
1---
2features:
3 - |
4 Exposed ``keystoneauth1.discover.version_between`` as a public function
5 that can be used to determine if a given version is within a range.