Chromium Code Reviews| Index: tests/gclient_scm_test.py |
| diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py |
| index 92aab6cc811fe255d0fed1c35e0c85ea4081143e..52f08445d96ab228822660316b991b723ccba810 100755 |
| --- a/tests/gclient_scm_test.py |
| +++ b/tests/gclient_scm_test.py |
| @@ -1274,7 +1274,6 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase): |
| cwd=self.base_path).AndRaise(error) |
| gclient_scm.GitWrapper._Fetch(options) |
| gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) |
| - gclient_scm.GitWrapper._Fetch(options) |
| self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
| gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( |
| @@ -1285,6 +1284,8 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase): |
| ).AndReturn(True) |
| gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big |
| ).MultipleTimes(2).AndReturn(False) |
| + # pylint: disable=E1120 |
| + gclient_scm.GitWrapper._Fetch(options) |
| gclient_scm.os.path.isdir(self.base_path).AndReturn(False) |
| gclient_scm.os.path.isdir(self.base_path).MultipleTimes().AndReturn(True) |
| @@ -1572,6 +1573,99 @@ class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase): |
| self.checkstdout('________ unmanaged solution; skipping .\n') |
| +class GitRefishTestCase(unittest.TestCase): |
| + |
| + @staticmethod |
| + def parse(revision, **kwargs): |
| + kwargs.setdefault('remote', 'origin') |
| + kwargs.setdefault('other_remotes', ('server', 'backup')) |
| + return gclient_scm.GitRefish.Parse(revision, **kwargs) |
| + |
| + def testParse(self): |
| + self.assertEquals( |
|
M-A Ruel
2014/06/24 21:18:11
Use assertEqual instead
This test would maybe ben
|
| + self.parse('refs/heads/master'), |
| + gclient_scm.GitRefish( |
| + source='refs/heads/master', |
| + is_branch=True, |
| + local_ref='master', |
| + remote='origin', |
| + remote_ref='master', |
| + remote_refspec='origin/master', |
| + upstream_branch='refs/remotes/origin/master', |
| + ) |
| + ) |
| + |
| + self.assertEquals( |
| + self.parse('origin/foo/bar'), |
| + gclient_scm.GitRefish( |
| + source='origin/foo/bar', |
| + is_branch=True, |
| + local_ref='refs/remotes/origin/foo/bar', |
| + remote='origin', |
| + remote_ref='foo/bar', |
| + remote_refspec='origin/foo/bar', |
| + upstream_branch='origin/foo/bar', |
| + ) |
| + ) |
| + |
| + self.assertEquals( |
| + self.parse('server/foo/bar'), |
| + gclient_scm.GitRefish( |
| + source='server/foo/bar', |
| + is_branch=True, |
| + local_ref='refs/remotes/server/foo/bar', |
| + remote='server', |
| + remote_ref='foo/bar', |
| + remote_refspec='server/foo/bar', |
| + upstream_branch='server/foo/bar', |
| + ) |
| + ) |
| + |
| + self.assertEquals( |
| + self.parse('refs/remotes/foo/bar/baz'), |
| + gclient_scm.GitRefish( |
| + source='refs/remotes/foo/bar/baz', |
| + is_branch=True, |
| + local_ref='refs/remotes/foo/bar/baz', |
| + remote='foo', |
| + remote_ref='bar/baz', |
| + remote_refspec='foo/bar/baz', |
| + upstream_branch='refs/remotes/foo/bar/baz', |
| + ) |
| + ) |
| + |
| + hash_value = '0c745b5ff533cf50a8731e168908644a9d9be4cf' |
| + self.assertEquals( |
| + self.parse(hash_value), |
| + gclient_scm.GitRefish( |
| + source=hash_value, |
| + is_branch=False, |
| + local_ref=hash_value, |
| + remote='origin', |
| + remote_ref=hash_value, |
| + remote_refspec=hash_value, |
| + upstream_branch=None, |
| + ) |
| + ) |
| + |
| + # Short hash (consider it a hash) |
| + hash_value = '0c745b5' |
| + self.assertEquals( |
| + self.parse( |
| + hash_value, |
| + ), |
| + gclient_scm.GitRefish( |
| + source=hash_value, |
| + is_branch=False, |
| + local_ref=hash_value, |
| + remote='origin', |
| + remote_ref=hash_value, |
| + remote_refspec=hash_value, |
| + upstream_branch=None, |
| + ) |
| + ) |
| + |
| + |
| if __name__ == '__main__': |
| if '-v' in sys.argv: |
| logging.basicConfig( |