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

Side by Side Diff: tests/gclient_scm_test.py

Issue 500015: gclient: implement a less hacky relative URL implementation (Closed)
Patch Set: Created 11 years 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
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 def setUp(self): 58 def setUp(self):
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', 'FullUrlForRelativeUrl', 'GetEmail', 68 'CaptureStatus', 'DiffItem', 'GetEmail',
69 'GetFileProperty', 'IsMoved', 'ReadSimpleAuth', 'Run', 69 'GetFileProperty', 'IsMoved', 'ReadSimpleAuth', 'Run',
70 'RunAndFilterOutput', 'RunAndGetFileList', 70 '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 testFullUrlForRelativeUrl(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 testRunCommandException(self): 84 def testRunCommandException(self):
93 options = self.Options(verbose=False) 85 options = self.Options(verbose=False)
94 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git') 86 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git')
95 gclient_scm.os.path.exists(file_path).AndReturn(False) 87 gclient_scm.os.path.exists(file_path).AndReturn(False)
96 88
97 self.mox.ReplayAll() 89 self.mox.ReplayAll()
98 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 90 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
99 relpath=self.relpath) 91 relpath=self.relpath)
100 exception = "Unsupported argument(s): %s" % ','.join(self.args) 92 exception = "Unsupported argument(s): %s" % ','.join(self.args)
101 self.assertRaisesError(exception, scm.RunCommand, 93 self.assertRaisesError(exception, scm.RunCommand,
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 self.base_path = gclient_scm.os.path.join(self.root_dir, self.relpath) 352 self.base_path = gclient_scm.os.path.join(self.root_dir, self.relpath)
361 self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path) 353 self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path)
362 SuperMoxBaseTestBase.setUp(self) 354 SuperMoxBaseTestBase.setUp(self)
363 355
364 def tearDown(self): 356 def tearDown(self):
365 SuperMoxBaseTestBase.tearDown(self) 357 SuperMoxBaseTestBase.tearDown(self)
366 shutil.rmtree(self.root_dir) 358 shutil.rmtree(self.root_dir)
367 359
368 def testDir(self): 360 def testDir(self):
369 members = [ 361 members = [
370 'COMMAND', 'Capture', 'CaptureStatus', 'FullUrlForRelativeUrl', 362 'COMMAND', 'Capture', 'CaptureStatus', 'GetEmail',
371 'GetEmail',
372 'RunCommand', 'cleanup', 'diff', 'export', 'relpath', 'revert', 363 'RunCommand', 'cleanup', 'diff', 'export', 'relpath', 'revert',
373 'revinfo', 'runhooks', 'scm_name', 'status', 'update', 'url', 364 'revinfo', 'runhooks', 'scm_name', 'status', 'update', 'url',
374 ] 365 ]
375 366
376 # If you add a member, be sure to add the relevant test! 367 # If you add a member, be sure to add the relevant test!
377 self.compareMembers(gclient_scm.CreateSCM(url=self.url), members) 368 self.compareMembers(gclient_scm.CreateSCM(url=self.url), members)
378 369
379 def testRevertMissing(self): 370 def testRevertMissing(self):
380 if not self.enabled: 371 if not self.enabled:
381 return 372 return
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 relpath=self.relpath) 528 relpath=self.relpath)
538 rev_info = scm.revinfo(options, (), None) 529 rev_info = scm.revinfo(options, (), None)
539 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') 530 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458')
540 531
541 532
542 if __name__ == '__main__': 533 if __name__ == '__main__':
543 import unittest 534 import unittest
544 unittest.main() 535 unittest.main()
545 536
546 # vim: ts=2:sw=2:tw=80:et: 537 # vim: ts=2:sw=2:tw=80:et:
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698