Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: third_party/boto/tests/unit/utils/test_utils.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2010 Robert Mela 1 # Copyright (c) 2010 Robert Mela
2 # 2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a 3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the 4 # copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including 5 # "Software"), to deal in the Software without restriction, including
6 # without limitation the rights to use, copy, modify, merge, publish, dis- 6 # without limitation the rights to use, copy, modify, merge, publish, dis-
7 # tribute, sublicense, and/or sell copies of the Software, and to permit 7 # tribute, sublicense, and/or sell copies of the Software, and to permit
8 # persons to whom the Software is furnished to do so, subject to the fol- 8 # persons to whom the Software is furnished to do so, subject to the fol-
9 # lowing conditions: 9 # lowing conditions:
10 # 10 #
11 # The above copyright notice and this permission notice shall be included 11 # The above copyright notice and this permission notice shall be included
12 # in all copies or substantial portions of the Software. 12 # in all copies or substantial portions of the Software.
13 # 13 #
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 # IN THE SOFTWARE. 20 # IN THE SOFTWARE.
21 # 21 #
22 try: 22 try:
23 import unittest2 as unittest 23 import unittest2 as unittest
24 except ImportError: 24 except ImportError:
25 import unittest 25 import unittest
26 26
27 import datetime
27 import hashlib 28 import hashlib
28 import hmac 29 import hmac
30 import locale
29 import mock 31 import mock
30 import thread 32 import thread
31 import time 33 import time
32 34
33 import boto.utils 35 import boto.utils
34 from boto.utils import Password 36 from boto.utils import Password
35 from boto.utils import pythonize_name 37 from boto.utils import pythonize_name
36 from boto.utils import _build_instance_metadata_url 38 from boto.utils import _build_instance_metadata_url
37 from boto.utils import get_instance_userdata 39 from boto.utils import get_instance_userdata
38 from boto.utils import retry_url 40 from boto.utils import retry_url
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 self.set_normal_response(['foo']) 254 self.set_normal_response(['foo'])
253 255
254 userdata = get_instance_userdata() 256 userdata = get_instance_userdata()
255 257
256 self.assertEqual('foo', userdata) 258 self.assertEqual('foo', userdata)
257 259
258 boto.utils.retry_url.assert_called_with( 260 boto.utils.retry_url.assert_called_with(
259 'http://169.254.169.254/latest/user-data', 261 'http://169.254.169.254/latest/user-data',
260 retry_on_404=False) 262 retry_on_404=False)
261 263
264
265 class TestStringToDatetimeParsing(unittest.TestCase):
266 """ Test string to datetime parsing """
267 def setUp(self):
268 self._saved = locale.setlocale(locale.LC_ALL)
269 locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
270
271 def tearDown(self):
272 locale.setlocale(locale.LC_ALL, self._saved)
273
274 def test_nonus_locale(self):
275 test_string = 'Thu, 15 May 2014 09:06:03 GMT'
276
277 # Default strptime shoudl fail
278 with self.assertRaises(ValueError):
279 datetime.datetime.strptime(test_string, boto.utils.RFC1123)
280
281 # Our parser should succeed
282 result = boto.utils.parse_ts(test_string)
283
284 self.assertEqual(2014, result.year)
285 self.assertEqual(5, result.month)
286 self.assertEqual(15, result.day)
287 self.assertEqual(9, result.hour)
288 self.assertEqual(6, result.minute)
289
290
262 if __name__ == '__main__': 291 if __name__ == '__main__':
263 unittest.main() 292 unittest.main()
OLDNEW
« no previous file with comments | « third_party/boto/tests/unit/test_regioninfo.py ('k') | third_party/gcs-oauth2-boto-plugin/.gitignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698