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

Side by Side Diff: tests/svn_utils_test.py

Issue 6020010: Destroy svn_utils.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/commit-queue
Patch Set: Rebase against trunk and include a fix to import checkout directly 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') | tests/svn_utils_test_data/codereview.settings » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
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
4 # found in the LICENSE file.
5
6 """Unit tests for svn_utils.py."""
7
8 import logging
9 import os
10 import shutil
11 import sys
12 import unittest
13
14 ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
15 sys.path.append(os.path.join(ROOT_DIR, '..'))
16
17 import patch
18 import svn_utils
19
20 PATCH = """\
21 --- svn_utils_test.txt
22 +++ svn_utils_test.txt
23 @@ -3,6 +3,7 @@ bb
24 ccc
25 dd
26 e
27 +FOO!
28 ff
29 ggg
30 hh
31 """
32
33 def read(filename):
34 f = open(filename, 'rb')
35 content = f.read()
36 f.close()
37 return content
38
39
40 class SvnUtils(unittest.TestCase):
41 def setUp(self):
42 super(SvnUtils, self).setUp()
43 self.root_dir = os.path.join(ROOT_DIR, 'foo')
44 if os.path.exists(self.root_dir):
45 shutil.rmtree(self.root_dir)
46
47 def tearDown(self):
48 super(SvnUtils, self).tearDown()
49 if os.path.exists(self.root_dir):
50 shutil.rmtree(self.root_dir)
51
52 def testModification(self):
53 # A bit sad as it relies on the public server.
54 url = ('http://src.chromium.org/svn/trunk/tools/commit-queue/tests/'
55 'svn_utils_test_data')
56 svn_utils.revert(url, self.root_dir, None, None)
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'))
59 patch.apply_patch(
60 self.root_dir, patch.auto_mangle_git_patch(PATCH))
61 content_lines = content.splitlines(True)
62 content_modified = ''.join(content_lines[0:5] + ['FOO!\n'] +
63 content_lines[5:])
64 self.assertEquals(content_modified,
65 read(os.path.join(self.root_dir, 'svn_utils_test.txt')))
66 svn_utils.revert(url, self.root_dir, None, None)
67 self.assertEquals(content,
68 read(os.path.join(self.root_dir, 'svn_utils_test.txt')))
69
70
71 if __name__ == '__main__':
72 logging.basicConfig(level=logging.ERROR)
73 unittest.main()
OLDNEW
« no previous file with comments | « tests/checkout_test.py ('k') | tests/svn_utils_test_data/codereview.settings » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698