summaryrefslogtreecommitdiff
path: root/keystoneauth1/tests/unit/test_discovery.py
diff options
context:
space:
mode:
Diffstat (limited to 'keystoneauth1/tests/unit/test_discovery.py')
-rw-r--r--keystoneauth1/tests/unit/test_discovery.py61
1 files changed, 36 insertions, 25 deletions
diff --git a/keystoneauth1/tests/unit/test_discovery.py b/keystoneauth1/tests/unit/test_discovery.py
index e9d2701..53e6394 100644
--- a/keystoneauth1/tests/unit/test_discovery.py
+++ b/keystoneauth1/tests/unit/test_discovery.py
@@ -323,52 +323,63 @@ class DiscoverUtils(utils.TestCase):
323 323
324 def test_version_args(self): 324 def test_version_args(self):
325 """Validate _normalize_version_args.""" 325 """Validate _normalize_version_args."""
326 def assert_min_max(in_ver, in_min, in_max, out_min, out_max): 326 def assert_min_max(in_ver, in_min, in_max, in_type, out_min, out_max):
327 self.assertEqual( 327 self.assertEqual(
328 (out_min, out_max), 328 (out_min, out_max),
329 discover._normalize_version_args(in_ver, in_min, in_max)) 329 discover._normalize_version_args(
330 in_ver, in_min, in_max, service_type=in_type))
330 331
331 def normalize_raises(ver, min, max): 332 def normalize_raises(ver, min, max, in_type):
332 self.assertRaises(ValueError, 333 self.assertRaises(
333 discover._normalize_version_args, ver, min, max) 334 ValueError,
335 discover._normalize_version_args,
336 ver, min, max, service_type=in_type)
334 337
335 assert_min_max(None, None, None, 338 assert_min_max(None, None, None, None,
336 None, None) 339 None, None)
337 assert_min_max(None, None, 'v1.2', 340 assert_min_max(None, None, 'v1.2', None,
338 None, (1, 2)) 341 None, (1, 2))
339 assert_min_max(None, 'v1.2', 'latest', 342 assert_min_max(None, 'v1.2', 'latest', None,
340 (1, 2), (discover.LATEST, discover.LATEST)) 343 (1, 2), (discover.LATEST, discover.LATEST))
341 assert_min_max(None, 'v1.2', '1.6', 344 assert_min_max(None, 'v1.2', '1.6', None,
342 (1, 2), (1, 6)) 345 (1, 2), (1, 6))
343 assert_min_max(None, 'v1.2', '1.latest', 346 assert_min_max(None, 'v1.2', '1.latest', None,
344 (1, 2), (1, discover.LATEST)) 347 (1, 2), (1, discover.LATEST))
345 assert_min_max(None, 'latest', 'latest', 348 assert_min_max(None, 'latest', 'latest', None,
346 (discover.LATEST, discover.LATEST), 349 (discover.LATEST, discover.LATEST),
347 (discover.LATEST, discover.LATEST)) 350 (discover.LATEST, discover.LATEST))
348 assert_min_max(None, 'latest', None, 351 assert_min_max(None, 'latest', None, None,
349 (discover.LATEST, discover.LATEST), 352 (discover.LATEST, discover.LATEST),
350 (discover.LATEST, discover.LATEST)) 353 (discover.LATEST, discover.LATEST))
351 assert_min_max(None, (1, 2), None, 354 assert_min_max(None, (1, 2), None, None,
352 (1, 2), (discover.LATEST, discover.LATEST)) 355 (1, 2), (discover.LATEST, discover.LATEST))
353 assert_min_max('', ('1', '2'), (1, 6), 356 assert_min_max('', ('1', '2'), (1, 6), None,
354 (1, 2), (1, 6)) 357 (1, 2), (1, 6))
355 assert_min_max(None, ('1', '2'), (1, discover.LATEST), 358 assert_min_max(None, ('1', '2'), (1, discover.LATEST), None,
356 (1, 2), (1, discover.LATEST)) 359 (1, 2), (1, discover.LATEST))
357 assert_min_max('v1.2', '', None, 360 assert_min_max('v1.2', '', None, None,
358 (1, 2), (1, discover.LATEST)) 361 (1, 2), (1, discover.LATEST))
359 assert_min_max('1.latest', None, '', 362 assert_min_max('1.latest', None, '', None,
360 (1, discover.LATEST), (1, discover.LATEST)) 363 (1, discover.LATEST), (1, discover.LATEST))
361 assert_min_max('v1', None, None, 364 assert_min_max('v1', None, None, None,
362 (1, 0), (1, discover.LATEST)) 365 (1, 0), (1, discover.LATEST))
363 assert_min_max('latest', None, None, 366 assert_min_max('latest', None, None, None,
364 (discover.LATEST, discover.LATEST), 367 (discover.LATEST, discover.LATEST),
365 (discover.LATEST, discover.LATEST)) 368 (discover.LATEST, discover.LATEST))
366 369 assert_min_max(None, None, 'latest', 'volumev2',
367 normalize_raises('v1', 'v2', None) 370 (2, 0), (2, discover.LATEST))
368 normalize_raises('v1', None, 'v2') 371 assert_min_max(None, None, None, 'volumev2',
369 normalize_raises(None, 'latest', 'v1') 372 (2, 0), (2, discover.LATEST))
370 normalize_raises(None, 'v1.2', 'v1.1') 373
371 normalize_raises(None, 'v1.2', 1) 374 normalize_raises('v1', 'v2', None, None)
375 normalize_raises('v1', None, 'v2', None)
376 normalize_raises(None, 'latest', 'v1', None)
377 normalize_raises(None, 'v1.2', 'v1.1', None)
378 normalize_raises(None, 'v1.2', 1, None)
379 normalize_raises('v2', None, None, 'volumev3')
380 normalize_raises('v3', None, None, 'volumev2')
381 normalize_raises(None, 'v2', None, 'volumev3')
382 normalize_raises(None, None, 'v3', 'volumev2')
372 383
373 def test_version_to_string(self): 384 def test_version_to_string(self):
374 def assert_string(out, inp): 385 def assert_string(out, inp):