OLD | NEW |
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 gclient_scm.py.""" | 6 """Unit tests for gclient_scm.py.""" |
7 | 7 |
8 # Import before super_mox to keep valid references. | 8 # Import before super_mox to keep valid references. |
9 from os import rename | 9 from os import rename |
10 from shutil import rmtree | 10 from shutil import rmtree |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 BaseTestCase.setUp(self) | 63 BaseTestCase.setUp(self) |
64 self.root_dir = self.Dir() | 64 self.root_dir = self.Dir() |
65 self.args = self.Args() | 65 self.args = self.Args() |
66 self.url = self.Url() | 66 self.url = self.Url() |
67 self.relpath = 'asf' | 67 self.relpath = 'asf' |
68 | 68 |
69 def testDir(self): | 69 def testDir(self): |
70 members = [ | 70 members = [ |
71 'AddAdditionalFlags', 'FullUrlForRelativeUrl', 'RunCommand', | 71 'AddAdditionalFlags', 'FullUrlForRelativeUrl', 'RunCommand', |
72 'cleanup', 'diff', 'export', 'pack', 'relpath', 'revert', | 72 'cleanup', 'diff', 'export', 'pack', 'relpath', 'revert', |
73 'revinfo', 'runhooks', 'scm_name', 'status', 'update', | 73 'revinfo', 'runhooks', 'status', 'update', |
74 'updatesingle', 'url', | 74 'updatesingle', 'url', |
75 ] | 75 ] |
76 | 76 |
77 # If you add a member, be sure to add the relevant test! | 77 # If you add a member, be sure to add the relevant test! |
78 self.compareMembers(self._scm_wrapper(), members) | 78 self.compareMembers(self._scm_wrapper('svn://a'), members) |
79 | 79 |
80 def testUnsupportedSCM(self): | 80 def testUnsupportedSCM(self): |
81 args = [self.url, self.root_dir, self.relpath] | 81 args = ['gopher://foo', self.root_dir, self.relpath] |
82 kwargs = {'scm_name' : 'foo'} | 82 exception_msg = 'No SCM found for url gopher://foo' |
83 exception_msg = 'Unsupported scm %(scm_name)s' % kwargs | 83 self.assertRaisesError(exception_msg, self._scm_wrapper, *args) |
84 self.assertRaisesError(exception_msg, self._scm_wrapper, *args, **kwargs) | |
85 | 84 |
86 def testSVNFullUrlForRelativeUrl(self): | 85 def testSVNFullUrlForRelativeUrl(self): |
87 self.url = 'svn://a/b/c/d' | 86 self.url = 'svn://a/b/c/d' |
88 | 87 |
89 self.mox.ReplayAll() | 88 self.mox.ReplayAll() |
90 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 89 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
91 relpath=self.relpath) | 90 relpath=self.relpath) |
92 self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'svn://a/b/crap') | 91 self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'svn://a/b/crap') |
93 | 92 |
94 def testGITFullUrlForRelativeUrl(self): | 93 def testGITFullUrlForRelativeUrl(self): |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 SuperMoxBaseTestBase.setUp(self) | 520 SuperMoxBaseTestBase.setUp(self) |
522 | 521 |
523 def tearDown(self): | 522 def tearDown(self): |
524 SuperMoxBaseTestBase.tearDown(self) | 523 SuperMoxBaseTestBase.tearDown(self) |
525 rmtree(self.root_dir) | 524 rmtree(self.root_dir) |
526 | 525 |
527 def testDir(self): | 526 def testDir(self): |
528 members = [ | 527 members = [ |
529 'FullUrlForRelativeUrl', 'RunCommand', | 528 'FullUrlForRelativeUrl', 'RunCommand', |
530 'cleanup', 'diff', 'export', 'pack', 'relpath', 'revert', | 529 'cleanup', 'diff', 'export', 'pack', 'relpath', 'revert', |
531 'revinfo', 'runhooks', 'scm_name', 'status', 'update', 'url', | 530 'revinfo', 'runhooks', 'status', 'update', 'url', |
532 ] | 531 ] |
533 | 532 |
534 # If you add a member, be sure to add the relevant test! | 533 # If you add a member, be sure to add the relevant test! |
535 self.compareMembers(gclient_scm.CreateSCM(url=self.url), members) | 534 self.compareMembers(gclient_scm.CreateSCM(url=self.url), members) |
536 | 535 |
537 def testRevertMissing(self): | 536 def testRevertMissing(self): |
538 if not self.enabled: | 537 if not self.enabled: |
539 return | 538 return |
540 options = self.Options() | 539 options = self.Options() |
541 file_path = gclient_scm.os.path.join(self.base_path, 'a') | 540 file_path = gclient_scm.os.path.join(self.base_path, 'a') |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 relpath=self.relpath) | 735 relpath=self.relpath) |
737 rev_info = scm.revinfo(options, (), None) | 736 rev_info = scm.revinfo(options, (), None) |
738 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') | 737 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') |
739 | 738 |
740 | 739 |
741 if __name__ == '__main__': | 740 if __name__ == '__main__': |
742 import unittest | 741 import unittest |
743 unittest.main() | 742 unittest.main() |
744 | 743 |
745 # vim: ts=2:sw=2:tw=80:et: | 744 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |