OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |