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

Side by Side Diff: third_party/gsutil/gslib/tests/test_hash.py

Issue 1380943003: Roll version of gsutil to 4.15. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: rebase Created 5 years 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
OLDNEW
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 # Copyright 2014 Google Inc. All Rights Reserved. 2 # Copyright 2014 Google Inc. All Rights Reserved.
3 # 3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License. 5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at 6 # You may obtain a copy of the License at
7 # 7 #
8 # http://www.apache.org/licenses/LICENSE-2.0 8 # http://www.apache.org/licenses/LICENSE-2.0
9 # 9 #
10 # Unless required by applicable law or agreed to in writing, software 10 # Unless required by applicable law or agreed to in writing, software
(...skipping 23 matching lines...) Expand all
34 stdout = self.RunCommand('hash', args=[tmp_file], return_stdout=True) 34 stdout = self.RunCommand('hash', args=[tmp_file], return_stdout=True)
35 self.assertIn('Hashes [base64]', stdout) 35 self.assertIn('Hashes [base64]', stdout)
36 self.assertIn('\tHash (crc32c):\t\t%s' % self._TEST_FILE_B64_CRC, stdout) 36 self.assertIn('\tHash (crc32c):\t\t%s' % self._TEST_FILE_B64_CRC, stdout)
37 self.assertIn('\tHash (md5):\t\t%s' % self._TEST_FILE_B64_MD5, stdout) 37 self.assertIn('\tHash (md5):\t\t%s' % self._TEST_FILE_B64_MD5, stdout)
38 38
39 def testHashNoMatch(self): 39 def testHashNoMatch(self):
40 try: 40 try:
41 self.RunCommand('hash', args=['non-existent-file']) 41 self.RunCommand('hash', args=['non-existent-file'])
42 self.fail('Did not get expected CommandException') 42 self.fail('Did not get expected CommandException')
43 except CommandException, e: 43 except CommandException, e:
44 self.assertRaisesRegexp(e, r'No files matched') 44 # assertRaisesRegexp causes issues with python 2.6.
45 self.assertIn('No files matched', e.reason)
45 46
46 def testHashCloudObject(self): 47 def testHashCloudObject(self):
47 try: 48 try:
48 self.RunCommand('hash', args=['gs://bucket/object']) 49 self.RunCommand('hash', args=['gs://bucket/object'])
49 self.fail('Did not get expected CommandException') 50 self.fail('Did not get expected CommandException')
50 except CommandException, e: 51 except CommandException, e:
51 self.assertEquals('"hash" command requires a file URL', e.reason) 52 self.assertEquals('"hash" command requires a file URL', e.reason)
52 53
53 def testHashHexFormat(self): 54 def testHashHexFormat(self):
54 tmp_file = self.CreateTempFile(contents=self._TEST_FILE_CONTENTS) 55 tmp_file = self.CreateTempFile(contents=self._TEST_FILE_CONTENTS)
(...skipping 19 matching lines...) Expand all
74 return_stdout=True) 75 return_stdout=True)
75 stdout_both = self.RunCommand('hash', args=['-c', '-m', tmp_file], 76 stdout_both = self.RunCommand('hash', args=['-c', '-m', tmp_file],
76 return_stdout=True) 77 return_stdout=True)
77 for stdout in (stdout_crc, stdout_both): 78 for stdout in (stdout_crc, stdout_both):
78 self.assertIn('\tHash (crc32c):\t\t%s' % self._TEST_FILE_B64_CRC, stdout) 79 self.assertIn('\tHash (crc32c):\t\t%s' % self._TEST_FILE_B64_CRC, stdout)
79 for stdout in (stdout_md5, stdout_both): 80 for stdout in (stdout_md5, stdout_both):
80 self.assertIn('\tHash (md5):\t\t%s' % self._TEST_FILE_B64_MD5, stdout) 81 self.assertIn('\tHash (md5):\t\t%s' % self._TEST_FILE_B64_MD5, stdout)
81 self.assertNotIn('md5', stdout_crc) 82 self.assertNotIn('md5', stdout_crc)
82 self.assertNotIn('crc32c', stdout_md5) 83 self.assertNotIn('crc32c', stdout_md5)
83 84
OLDNEW
« no previous file with comments | « third_party/gsutil/gslib/tests/test_defacl.py ('k') | third_party/gsutil/gslib/tests/test_mv.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698