| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright 2008-2009 Google Inc. All Rights Reserved. | 3 # Copyright 2008-2009 Google Inc. All Rights Reserved. |
| 4 # | 4 # |
| 5 # Licensed under the Apache License, Version 2.0 (the "License"); | 5 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 # you may not use this file except in compliance with the License. | 6 # you may not use this file except in compliance with the License. |
| 7 # You may obtain a copy of the License at | 7 # You may obtain a copy of the License at |
| 8 # | 8 # |
| 9 # http://www.apache.org/licenses/LICENSE-2.0 | 9 # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 # | 10 # |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 BaseTestCase.setUp(self) | 59 BaseTestCase.setUp(self) |
| 60 self.root_dir = self.Dir() | 60 self.root_dir = self.Dir() |
| 61 self.args = self.Args() | 61 self.args = self.Args() |
| 62 self.url = self.Url() | 62 self.url = self.Url() |
| 63 self.relpath = 'asf' | 63 self.relpath = 'asf' |
| 64 | 64 |
| 65 def testDir(self): | 65 def testDir(self): |
| 66 members = [ | 66 members = [ |
| 67 'COMMAND', 'Capture', 'CaptureHeadRevision', 'CaptureInfo', | 67 'COMMAND', 'Capture', 'CaptureHeadRevision', 'CaptureInfo', |
| 68 'CaptureStatus', 'DiffItem', 'GenerateDiff', 'GetCheckoutRoot', | 68 'CaptureStatus', 'DiffItem', 'GenerateDiff', 'GetCheckoutRoot', |
| 69 'GetEmail', 'GetFileProperty', 'IsMoved', 'ReadSimpleAuth', 'Run', | 69 'GetEmail', 'GetFileProperty', 'FullUrlForRelativeUrl', 'IsMoved', |
| 70 'RunAndFilterOutput', 'RunAndGetFileList', | 70 'ReadSimpleAuth', 'Run', 'RunAndFilterOutput', 'RunAndGetFileList', |
| 71 'RunCommand', 'cleanup', 'diff', 'export', 'pack', 'relpath', 'revert', | 71 'RunCommand', 'cleanup', 'diff', 'export', 'pack', 'relpath', 'revert', |
| 72 'revinfo', 'runhooks', 'scm_name', 'status', 'update', 'url', | 72 'revinfo', 'runhooks', 'scm_name', 'status', 'update', 'url', |
| 73 ] | 73 ] |
| 74 | 74 |
| 75 # If you add a member, be sure to add the relevant test! | 75 # If you add a member, be sure to add the relevant test! |
| 76 self.compareMembers(self._scm_wrapper(), members) | 76 self.compareMembers(self._scm_wrapper(), members) |
| 77 | 77 |
| 78 def testUnsupportedSCM(self): | 78 def testUnsupportedSCM(self): |
| 79 args = [self.url, self.root_dir, self.relpath] | 79 args = [self.url, self.root_dir, self.relpath] |
| 80 kwargs = {'scm_name' : 'foo'} | 80 kwargs = {'scm_name' : 'foo'} |
| 81 exception_msg = 'Unsupported scm %(scm_name)s' % kwargs | 81 exception_msg = 'Unsupported scm %(scm_name)s' % kwargs |
| 82 self.assertRaisesError(exception_msg, self._scm_wrapper, *args, **kwargs) | 82 self.assertRaisesError(exception_msg, self._scm_wrapper, *args, **kwargs) |
| 83 | 83 |
| 84 def testSVNFullUrlForRelativeUrl(self): |
| 85 self.url = 'svn://a/b/c/d' |
| 86 |
| 87 self.mox.ReplayAll() |
| 88 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 89 relpath=self.relpath) |
| 90 self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'svn://a/b/crap') |
| 91 |
| 92 def testGITFullUrlForRelativeUrl(self): |
| 93 self.url = 'git://a/b/c/d' |
| 94 |
| 95 self.mox.ReplayAll() |
| 96 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 97 relpath=self.relpath) |
| 98 self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'git://a/b/c/crap') |
| 99 |
| 84 def testRunCommandException(self): | 100 def testRunCommandException(self): |
| 85 options = self.Options(verbose=False) | 101 options = self.Options(verbose=False) |
| 86 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git') | 102 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git') |
| 87 gclient_scm.os.path.exists(file_path).AndReturn(False) | 103 gclient_scm.os.path.exists(file_path).AndReturn(False) |
| 88 | 104 |
| 89 self.mox.ReplayAll() | 105 self.mox.ReplayAll() |
| 90 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 106 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 91 relpath=self.relpath) | 107 relpath=self.relpath) |
| 92 exception = "Unsupported argument(s): %s" % ','.join(self.args) | 108 exception = "Unsupported argument(s): %s" % ','.join(self.args) |
| 93 self.assertRaisesError(exception, scm.RunCommand, | 109 self.assertRaisesError(exception, scm.RunCommand, |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path) | 370 self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path) |
| 355 SuperMoxBaseTestBase.setUp(self) | 371 SuperMoxBaseTestBase.setUp(self) |
| 356 | 372 |
| 357 def tearDown(self): | 373 def tearDown(self): |
| 358 SuperMoxBaseTestBase.tearDown(self) | 374 SuperMoxBaseTestBase.tearDown(self) |
| 359 shutil.rmtree(self.root_dir) | 375 shutil.rmtree(self.root_dir) |
| 360 | 376 |
| 361 def testDir(self): | 377 def testDir(self): |
| 362 members = [ | 378 members = [ |
| 363 'COMMAND', 'Capture', 'CaptureStatus', 'FetchUpstreamTuple', | 379 'COMMAND', 'Capture', 'CaptureStatus', 'FetchUpstreamTuple', |
| 364 'GenerateDiff', 'GetBranch', 'GetBranchRef', 'GetCheckoutRoot', | 380 'FullUrlForRelativeUrl', 'GenerateDiff', 'GetBranch', 'GetBranchRef', |
| 365 'GetDifferentFiles', 'GetEmail', 'GetPatchName', 'GetSVNBranch', | 381 'GetCheckoutRoot', 'GetDifferentFiles', 'GetEmail', 'GetPatchName', |
| 366 'GetUpstream', 'IsGitSvn', 'RunAndFilterOutput', 'ShortBranchName', | 382 'GetSVNBranch', 'GetUpstream', 'IsGitSvn', 'RunAndFilterOutput', |
| 367 'RunCommand', 'cleanup', 'diff', 'export', 'pack', 'relpath', 'revert', | 383 'ShortBranchName', 'RunCommand', |
| 384 'cleanup', 'diff', 'export', 'pack', 'relpath', 'revert', |
| 368 'revinfo', 'runhooks', 'scm_name', 'status', 'update', 'url', | 385 'revinfo', 'runhooks', 'scm_name', 'status', 'update', 'url', |
| 369 ] | 386 ] |
| 370 | 387 |
| 371 # If you add a member, be sure to add the relevant test! | 388 # If you add a member, be sure to add the relevant test! |
| 372 self.compareMembers(gclient_scm.CreateSCM(url=self.url), members) | 389 self.compareMembers(gclient_scm.CreateSCM(url=self.url), members) |
| 373 | 390 |
| 374 def testRevertMissing(self): | 391 def testRevertMissing(self): |
| 375 if not self.enabled: | 392 if not self.enabled: |
| 376 return | 393 return |
| 377 options = self.Options() | 394 options = self.Options() |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 relpath=self.relpath) | 549 relpath=self.relpath) |
| 533 rev_info = scm.revinfo(options, (), None) | 550 rev_info = scm.revinfo(options, (), None) |
| 534 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') | 551 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') |
| 535 | 552 |
| 536 | 553 |
| 537 if __name__ == '__main__': | 554 if __name__ == '__main__': |
| 538 import unittest | 555 import unittest |
| 539 unittest.main() | 556 unittest.main() |
| 540 | 557 |
| 541 # vim: ts=2:sw=2:tw=80:et: | 558 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |