summaryrefslogtreecommitdiff
path: root/tests/unit/test_shell.py
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2016-05-03 14:18:34 -0700
committerTim Burke <tim.burke@gmail.com>2016-05-03 14:18:34 -0700
commitc3766319b93d60e30f55747f6cfc9ca915ff603c (patch)
tree22cfc307573254f77ec06f6c4829465f9d3f238a /tests/unit/test_shell.py
parent5b714f104d7564ff06525465d0eaabaa12a8cbb0 (diff)
downloadpython-swiftclient-c3766319b93d60e30f55747f6cfc9ca915ff603c.tar.gz
Pull option processing out to service.py
...because it seems silly that we do nearly the same thing in two different places Change-Id: Iafafe3c553d00652adb91ceefd0de1479cbcb5da
Diffstat (limited to 'tests/unit/test_shell.py')
-rw-r--r--tests/unit/test_shell.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/unit/test_shell.py b/tests/unit/test_shell.py
index 0b29952..f921721 100644
--- a/tests/unit/test_shell.py
+++ b/tests/unit/test_shell.py
@@ -1522,6 +1522,43 @@ class TestParsing(TestBase):
swiftclient.shell.main(args)
self._verify_opts(result[0], opts, os_opts, os_opts_dict)
+ def test_sloppy_versions(self):
+ os_opts = {"password": "secret",
+ "username": "user",
+ "auth_url": "http://example.com:5000/v3",
+ "identity-api-version": "3.0"}
+
+ # check os_identity_api_version is sufficient in place of auth_version
+ args = _make_args("stat", {}, os_opts, '-')
+ result = [None, None]
+ fake_command = self._make_fake_command(result)
+ with mock.patch.dict(os.environ, {}):
+ with mock.patch('swiftclient.shell.st_stat', fake_command):
+ swiftclient.shell.main(args)
+ expected_opts = {'auth_version': '3'} # NB: not '3.0'
+ expected_os_opts = {"password": "secret",
+ "username": "user",
+ "auth_url": "http://example.com:5000/v3"}
+ self._verify_opts(result[0], expected_opts, expected_os_opts, {})
+
+ os_opts = {"password": "secret",
+ "username": "user",
+ "auth_url": "http://example.com:5000/v2.0",
+ "identity-api-version": "2"}
+
+ # check os_identity_api_version is sufficient in place of auth_version
+ args = _make_args("stat", {}, os_opts, '-')
+ result = [None, None]
+ fake_command = self._make_fake_command(result)
+ with mock.patch.dict(os.environ, {}):
+ with mock.patch('swiftclient.shell.st_stat', fake_command):
+ swiftclient.shell.main(args)
+ expected_opts = {'auth_version': '2.0'} # NB: not '2'
+ expected_os_opts = {"password": "secret",
+ "username": "user",
+ "auth_url": "http://example.com:5000/v2.0"}
+ self._verify_opts(result[0], expected_opts, expected_os_opts, {})
+
def test_os_identity_api_version(self):
os_opts = {"password": "secret",
"username": "user",