def test_get_commit(self): req_path = 'project/+/%s' % REVISION commit_response = { 'commit': REVISION, 'tree': '3cfb41e1c6c37e61c3eccfab2395752298a5743c', 'parents': ['4087678c002d57e1148f21da5e00867df9a7d973'], 'author': { 'name': 'John Doe', 'email': '*****@*****.**', 'time': 'Tue Apr 29 14:07:58 2014 -0700' }, 'committer': { 'name': 'John Doe', 'email': '*****@*****.**', 'time': 'Tue Apr 29 14:07:58 2014 -0700' }, 'message': 'Subject\\n\\nBody', 'tree_diff': [{ 'type': 'modify', 'old_id': 'f23dec7da271f7e9d8c55a35f32f6971b7ce486d', 'old_mode': 33188, 'old_path': 'codereview.settings', 'new_id': '0bdbda926c49aa3cc4b7248bc22cc261abff5f94', 'new_mode': 33188, 'new_path': 'codereview.settings' }, { 'type': 'add', 'old_id': '0000000000000000000000000000000000000000', 'old_mode': 0, 'old_path': '/dev/null', 'new_id': 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391', 'new_mode': 33188, 'new_path': 'x' }] } client = GitilesClient('chromium.googlesource.com') client._fetch = Mock(return_value=commit_response) commit = client.get_commit('project', REVISION) client._fetch.assert_called_once_with(req_path) self.assertIsNotNone(commit) self.assertEqual(commit.sha, REVISION) self.assertEqual(commit.committer.name, 'John Doe') self.assertEqual(commit.committer.email, '*****@*****.**') self.assertEqual(commit.author.name, 'John Doe') self.assertEqual(commit.author.email, '*****@*****.**')
def test_get_commit(self): req_path = "project/+/%s" % REVISION commit_response = { "commit": REVISION, "tree": "3cfb41e1c6c37e61c3eccfab2395752298a5743c", "parents": ["4087678c002d57e1148f21da5e00867df9a7d973"], "author": {"name": "John Doe", "email": "*****@*****.**", "time": "Tue Apr 29 14:07:58 2014 -0700"}, "committer": { "name": "John Doe", "email": "*****@*****.**", "time": "Tue Apr 29 14:07:58 2014 -0700", }, "message": "Subject\\n\\nBody", "tree_diff": [ { "type": "modify", "old_id": "f23dec7da271f7e9d8c55a35f32f6971b7ce486d", "old_mode": 33188, "old_path": "codereview.settings", "new_id": "0bdbda926c49aa3cc4b7248bc22cc261abff5f94", "new_mode": 33188, "new_path": "codereview.settings", }, { "type": "add", "old_id": "0000000000000000000000000000000000000000", "old_mode": 0, "old_path": "/dev/null", "new_id": "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "new_mode": 33188, "new_path": "x", }, ], } client = GitilesClient("chromium.googlesource.com") client._fetch = Mock(return_value=commit_response) commit = client.get_commit("project", REVISION) client._fetch.assert_called_once_with(req_path) self.assertIsNotNone(commit) self.assertEqual(commit.sha, REVISION) self.assertEqual(commit.committer.name, "John Doe") self.assertEqual(commit.committer.email, "*****@*****.**") self.assertEqual(commit.author.name, "John Doe") self.assertEqual(commit.author.email, "*****@*****.**")
def test_get_nonexistent_commit(self): client = GitilesClient("chromium.googlesource.com") commit = client.get_commit("project", REVISION) self.assertIsNone(commit)
def test_get_nonexistent_commit(self): client = GitilesClient('chromium.googlesource.com') commit = client.get_commit('project', REVISION) self.assertIsNone(commit)