OLD | NEW |
1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 }) | 44 }) |
45 workspace = Workspace(filesystem, None) | 45 workspace = Workspace(filesystem, None) |
46 self.assertEqual(workspace.find_unused_filename("bar", "bar", "bar"), "b
ar/bar.bar") | 46 self.assertEqual(workspace.find_unused_filename("bar", "bar", "bar"), "b
ar/bar.bar") |
47 self.assertEqual(workspace.find_unused_filename("dir", "foo", "jpg", sea
rch_limit=1), None) | 47 self.assertEqual(workspace.find_unused_filename("dir", "foo", "jpg", sea
rch_limit=1), None) |
48 self.assertEqual(workspace.find_unused_filename("dir", "foo", "jpg", sea
rch_limit=2), None) | 48 self.assertEqual(workspace.find_unused_filename("dir", "foo", "jpg", sea
rch_limit=2), None) |
49 self.assertEqual(workspace.find_unused_filename("dir", "foo", "jpg"), "d
ir/foo-3.jpg") | 49 self.assertEqual(workspace.find_unused_filename("dir", "foo", "jpg"), "d
ir/foo-3.jpg") |
50 | 50 |
51 def test_create_zip(self): | 51 def test_create_zip(self): |
52 workspace = Workspace(None, MockExecutive(should_log=True)) | 52 workspace = Workspace(None, MockExecutive(should_log=True)) |
53 expected_logs = "MOCK run_command: ['zip', '-9', '-r', '/zip/path', '.']
, cwd=/source/path\n" | 53 expected_logs = "MOCK run_command: ['zip', '-9', '-r', '/zip/path', '.']
, cwd=/source/path\n" |
| 54 |
54 class MockZipFile(object): | 55 class MockZipFile(object): |
| 56 |
55 def __init__(self, path): | 57 def __init__(self, path): |
56 self.filename = path | 58 self.filename = path |
57 archive = OutputCapture().assert_outputs(self, workspace.create_zip, ["/
zip/path", "/source/path", MockZipFile], expected_logs=expected_logs) | 59 archive = OutputCapture().assert_outputs(self, workspace.create_zip, [ |
| 60 "/zip/path", "/source/path", MockZipFile], expected_logs=expected_lo
gs) |
58 self.assertEqual(archive.filename, "/zip/path") | 61 self.assertEqual(archive.filename, "/zip/path") |
59 | 62 |
60 def test_create_zip_exception(self): | 63 def test_create_zip_exception(self): |
61 workspace = Workspace(None, MockExecutive(should_log=True, should_throw=
True)) | 64 workspace = Workspace(None, MockExecutive(should_log=True, should_throw=
True)) |
62 expected_logs = """MOCK run_command: ['zip', '-9', '-r', '/zip/path', '.
'], cwd=/source/path | 65 expected_logs = """MOCK run_command: ['zip', '-9', '-r', '/zip/path', '.
'], cwd=/source/path |
63 Workspace.create_zip failed in /source/path: | 66 Workspace.create_zip failed in /source/path: |
64 MOCK ScriptError | 67 MOCK ScriptError |
65 | 68 |
66 output: MOCK output of child process | 69 output: MOCK output of child process |
67 """ | 70 """ |
| 71 |
68 class MockZipFile(object): | 72 class MockZipFile(object): |
| 73 |
69 def __init__(self, path): | 74 def __init__(self, path): |
70 self.filename = path | 75 self.filename = path |
71 archive = OutputCapture().assert_outputs(self, workspace.create_zip, ["/
zip/path", "/source/path", MockZipFile], expected_logs=expected_logs) | 76 archive = OutputCapture().assert_outputs(self, workspace.create_zip, [ |
| 77 "/zip/path", "/source/path", MockZipFile], expected_logs=expected_lo
gs) |
72 self.assertIsNone(archive) | 78 self.assertIsNone(archive) |
OLD | NEW |