Browse Source

Merge "Expose version_between as a real function"

tags/3.7.0^0
Zuul 1 year ago
parent
commit
db5aa8b3ae

+ 3
- 3
keystoneauth1/discover.py View File

@@ -323,7 +323,7 @@ def version_to_string(version):
323 323
     return ".".join(map(_str_or_latest, version))
324 324
 
325 325
 
326
-def _version_between(min_version, max_version, candidate):
326
+def version_between(min_version, max_version, candidate):
327 327
     """Determine whether a candidate version is within a specified range.
328 328
 
329 329
     :param min_version: The minimum version that is acceptable.
@@ -714,7 +714,7 @@ class Discover(object):
714 714
             if _latest_soft_match(min_version, data['version']):
715 715
                 return data
716 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 718
                     min_version, max_version, data['version']):
719 719
                 return data
720 720
 
@@ -1235,7 +1235,7 @@ class EndpointData(object):
1235 1235
         else:
1236 1236
             # `is_between` means version bounds were specified *and* the URL
1237 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 1239
                 min_version, max_version, url_version)
1240 1240
             exact_match = (is_between and max_version and
1241 1241
                            max_version[0] == url_version[0])

+ 3
- 3
keystoneauth1/tests/unit/test_discovery.py View File

@@ -395,14 +395,14 @@ class DiscoverUtils(utils.TestCase):
395 395
 
396 396
     def test_version_between(self):
397 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 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 403
         def exc(excls, minver, maxver, cand):
404 404
             self.assertRaises(excls,
405
-                              discover._version_between, minver, maxver, cand)
405
+                              discover.version_between, minver, maxver, cand)
406 406
 
407 407
         # candidate required
408 408
         exc(ValueError, (1, 0), (1, 0), None)

+ 5
- 0
releasenotes/notes/version-between-b4b0bcf4cecfb9e4.yaml View File

@@ -0,0 +1,5 @@
1
+---
2
+features:
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.

Loading…
Cancel
Save