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

Side by Side Diff: tests/svn_utils_test.py

Issue 5968005: Move patch management functions into their own file, patch.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/commit-queue
Patch Set: rebase against trunk Created 9 years, 12 months 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
« no previous file with comments | « tests/checkout_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for svn_utils.py.""" 6 """Unit tests for svn_utils.py."""
7 7
8 import logging 8 import logging
9 import os 9 import os
10 import shutil 10 import shutil
11 import sys 11 import sys
12 import unittest 12 import unittest
13 13
14 ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) 14 ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
15 sys.path.append(os.path.join(ROOT_DIR, '..')) 15 sys.path.append(os.path.join(ROOT_DIR, '..'))
16 16
17 import pending_manager 17 import patch
18 import svn_utils 18 import svn_utils
19 19
20 PATCH = """\ 20 PATCH = """\
21 --- svn_utils_test.txt 21 --- svn_utils_test.txt
22 +++ svn_utils_test.txt 22 +++ svn_utils_test.txt
23 @@ -3,6 +3,7 @@ bb 23 @@ -3,6 +3,7 @@ bb
24 ccc 24 ccc
25 dd 25 dd
26 e 26 e
27 +FOO! 27 +FOO!
(...skipping 21 matching lines...) Expand all
49 if os.path.exists(self.root_dir): 49 if os.path.exists(self.root_dir):
50 shutil.rmtree(self.root_dir) 50 shutil.rmtree(self.root_dir)
51 51
52 def testModification(self): 52 def testModification(self):
53 # A bit sad as it relies on the public server. 53 # A bit sad as it relies on the public server.
54 url = ('http://src.chromium.org/svn/trunk/tools/commit-queue/tests/' 54 url = ('http://src.chromium.org/svn/trunk/tools/commit-queue/tests/'
55 'svn_utils_test_data') 55 'svn_utils_test_data')
56 svn_utils.revert(url, self.root_dir, None, None) 56 svn_utils.revert(url, self.root_dir, None, None)
57 content = read(os.path.join(self.root_dir, 'svn_utils_test.txt')) 57 content = read(os.path.join(self.root_dir, 'svn_utils_test.txt'))
58 self.assertTrue(os.path.join(self.root_dir, 'svn_utils_test.txt')) 58 self.assertTrue(os.path.join(self.root_dir, 'svn_utils_test.txt'))
59 svn_utils.apply_patch( 59 patch.apply_patch(
60 self.root_dir, pending_manager.auto_mangle_git_patch(PATCH)) 60 self.root_dir, patch.auto_mangle_git_patch(PATCH))
61 content_lines = content.splitlines(True) 61 content_lines = content.splitlines(True)
62 content_modified = ''.join(content_lines[0:5] + ['FOO!\n'] + 62 content_modified = ''.join(content_lines[0:5] + ['FOO!\n'] +
63 content_lines[5:]) 63 content_lines[5:])
64 self.assertEquals(content_modified, 64 self.assertEquals(content_modified,
65 read(os.path.join(self.root_dir, 'svn_utils_test.txt'))) 65 read(os.path.join(self.root_dir, 'svn_utils_test.txt')))
66 svn_utils.revert(url, self.root_dir, None, None) 66 svn_utils.revert(url, self.root_dir, None, None)
67 self.assertEquals(content, 67 self.assertEquals(content,
68 read(os.path.join(self.root_dir, 'svn_utils_test.txt'))) 68 read(os.path.join(self.root_dir, 'svn_utils_test.txt')))
69 69
70 70
71 if __name__ == '__main__': 71 if __name__ == '__main__':
72 logging.basicConfig(level=logging.ERROR) 72 logging.basicConfig(level=logging.ERROR)
73 unittest.main() 73 unittest.main()
OLDNEW
« no previous file with comments | « tests/checkout_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698