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

Side by Side Diff: third_party/boto/tests/unit/glacier/test_concurrent.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved 2 # Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved
3 # 3 #
4 # Permission is hereby granted, free of charge, to any person obtaining a 4 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the 5 # copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including 6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish, dis- 7 # without limitation the rights to use, copy, modify, merge, publish, dis-
8 # tribute, sublicense, and/or sell copies of the Software, and to permit 8 # tribute, sublicense, and/or sell copies of the Software, and to permit
9 # persons to whom the Software is furnished to do so, subject to the fol- 9 # persons to whom the Software is furnished to do so, subject to the fol-
10 # lowing conditions: 10 # lowing conditions:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 def _wait_for_download_threads(self, filename, result_queue, total_parts): 52 def _wait_for_download_threads(self, filename, result_queue, total_parts):
53 pass 53 pass
54 54
55 55
56 class TestConcurrentUploader(unittest.TestCase): 56 class TestConcurrentUploader(unittest.TestCase):
57 57
58 def setUp(self): 58 def setUp(self):
59 super(TestConcurrentUploader, self).setUp() 59 super(TestConcurrentUploader, self).setUp()
60 self.stat_patch = mock.patch('os.stat') 60 self.stat_patch = mock.patch('os.stat')
61 self.addCleanup(self.stat_patch.stop)
61 self.stat_mock = self.stat_patch.start() 62 self.stat_mock = self.stat_patch.start()
62 # Give a default value for tests that don't care 63 # Give a default value for tests that don't care
63 # what the file size is. 64 # what the file size is.
64 self.stat_mock.return_value.st_size = 1024 * 1024 * 8 65 self.stat_mock.return_value.st_size = 1024 * 1024 * 8
65 66
66 def tearDown(self):
67 self.stat_mock = self.stat_patch.start()
68
69 def test_calculate_required_part_size(self): 67 def test_calculate_required_part_size(self):
70 self.stat_mock.return_value.st_size = 1024 * 1024 * 8 68 self.stat_mock.return_value.st_size = 1024 * 1024 * 8
71 uploader = ConcurrentUploader(mock.Mock(), 'vault_name') 69 uploader = ConcurrentUploader(mock.Mock(), 'vault_name')
72 total_parts, part_size = uploader._calculate_required_part_size( 70 total_parts, part_size = uploader._calculate_required_part_size(
73 1024 * 1024 * 8) 71 1024 * 1024 * 8)
74 self.assertEqual(total_parts, 2) 72 self.assertEqual(total_parts, 2)
75 self.assertEqual(part_size, 4 * 1024 * 1024) 73 self.assertEqual(part_size, 4 * 1024 * 1024)
76 74
77 def test_calculate_required_part_size_too_small(self): 75 def test_calculate_required_part_size_too_small(self):
78 too_small = 1 * 1024 * 1024 76 too_small = 1 * 1024 * 1024
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 api.upload_part.side_effect = Exception() 165 api.upload_part.side_effect = Exception()
168 job_queue.put((0, 1024)) 166 job_queue.put((0, 1024))
169 job_queue.put(_END_SENTINEL) 167 job_queue.put(_END_SENTINEL)
170 168
171 upload_thread.run() 169 upload_thread.run()
172 self.assertEqual(api.upload_part.call_count, 3) 170 self.assertEqual(api.upload_part.call_count, 3)
173 171
174 172
175 if __name__ == '__main__': 173 if __name__ == '__main__':
176 unittest.main() 174 unittest.main()
OLDNEW
« no previous file with comments | « third_party/boto/tests/unit/emr/test_connection.py ('k') | third_party/boto/tests/unit/glacier/test_layer2.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698