summaryrefslogtreecommitdiff
path: root/tests/unit/test_utils.py
diff options
context:
space:
mode:
authorAlistair Coles <alistair.coles@hpe.com>2016-09-09 11:06:06 +0100
committerAlistair Coles <alistair.coles@hpe.com>2016-09-14 18:17:40 +0100
commite41158d79e4bcb280ec94365226f9423f72d7b66 (patch)
treeeeaf15a53c2384a93587d8b3052e882c0ee8902a /tests/unit/test_utils.py
parent4c955751d340a8f71a2eebdb3c58d90b36874a66 (diff)
downloadpython-swiftclient-e41158d79e4bcb280ec94365226f9423f72d7b66.tar.gz
Make tempurl subcommand insist on whole number seconds
Previously the tempurl subcommand would dump a traceback due to a TypeError if the seconds option was not an int value. With this patch it will now return the same error message as if the seconds option were negative or not a number. Also changes the error message to state that the seconds option should be a "whole number" rather than a "positive integer", since 0 is a valid value. Change-Id: Ie940d470f2be8006aa8eb7fe242f092457aeae21 Closes-Bug: #1621817
Diffstat (limited to 'tests/unit/test_utils.py')
-rw-r--r--tests/unit/test_utils.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py
index e820aff..67c39e0 100644
--- a/tests/unit/test_utils.py
+++ b/tests/unit/test_utils.py
@@ -170,15 +170,30 @@ class TestTempURL(unittest.TestCase):
self.assertEqual(url, expected_url)
def test_generate_temp_url_bad_seconds(self):
- with self.assertRaises(TypeError) as exc_manager:
+ with self.assertRaises(ValueError) as exc_manager:
u.generate_temp_url(self.url, 'not_an_int', self.key, self.method)
self.assertEqual(exc_manager.exception.args[0],
- 'seconds must be an integer')
+ 'seconds must be a whole number')
with self.assertRaises(ValueError) as exc_manager:
u.generate_temp_url(self.url, -1, self.key, self.method)
self.assertEqual(exc_manager.exception.args[0],
- 'seconds must be a positive integer')
+ 'seconds must be a whole number')
+
+ with self.assertRaises(ValueError) as exc_manager:
+ u.generate_temp_url(self.url, 1.1, self.key, self.method)
+ self.assertEqual(exc_manager.exception.args[0],
+ 'seconds must be a whole number')
+
+ with self.assertRaises(ValueError) as exc_manager:
+ u.generate_temp_url(self.url, '-1', self.key, self.method)
+ self.assertEqual(exc_manager.exception.args[0],
+ 'seconds must be a whole number')
+
+ with self.assertRaises(ValueError) as exc_manager:
+ u.generate_temp_url(self.url, '1.1', self.key, self.method)
+ self.assertEqual(exc_manager.exception.args[0],
+ 'seconds must be a whole number')
def test_generate_temp_url_bad_path(self):
with self.assertRaises(ValueError) as exc_manager: