def test_get_commits(self):
        commits_api_response = json.dumps([
            {
                'author': 'myname',
                'id': 'bfdde95432b3af879af969bd2377dc3e55ee46e6',
                'date': '2015-02-13 22:34:01 -0700 -0700',
                'message': 'mymessage',
                'parent_id': '304c53c163aedfd0c0e0933776f09c24b87f5944',
            },
            {
                'author': 'myname',
                'id': '304c53c163aedfd0c0e0933776f09c24b87f5944',
                'date': '2015-02-13 22:32:42 -0700 -0700',
                'message': 'mymessage',
                'parent_id': 'fa1330719893098ae397356e8125c2aa45b49221',
            },
            {
                'author': 'anothername',
                'id': 'fa1330719893098ae397356e8125c2aa45b49221',
                'date': '2015-02-12 16:01:48 -0700 -0700',
                'message': 'mymessage',
                'parent_id': '',
            }
        ])

        def _http_get(self, *args, **kwargs):
            return commits_api_response, None

        account = self._get_hosting_account()
        account.data['private_token'] = encrypt_password('abc123')

        repository = Repository(hosting_account=account)
        repository.extra_data = {
            'rbgateway_repo_name': 'myrepo',
        }

        service = account.service
        self.spy_on(service.client.http_get, call_fake=_http_get)

        commits = service.get_commits(
            repository, branch='bfdde95432b3af879af969bd2377dc3e55ee46e6')

        self.assertTrue(service.client.http_get.called)

        self.assertEqual(len(commits), 3)
        self.assertEqual(commits[0].parent, commits[1].id)
        self.assertEqual(commits[1].parent, commits[2].id)
        self.assertEqual(commits[0].date, '2015-02-13 22:34:01 -0700 -0700')
        self.assertEqual(commits[1].id,
                         '304c53c163aedfd0c0e0933776f09c24b87f5944')
        self.assertEqual(commits[2].author_name, 'anothername')
        self.assertEqual(commits[2].parent, '')
Testing ReviewBoardGateway get_commits implementation
dataset/ETHPy150Open reviewboard/reviewboard/reviewboard/hostingsvcs/tests/test_rbgateway.py/ReviewBoardGatewayTests.test_get_commits