def test_get_change(self):
        diff = (b'diff --git a/test b/test\n'
                'index 9daeafb9864cf43055ae93beb0afd6c7d144bfa4..'
                'dced80a85fe1e8f13dd5ea19923e5d2e8680020d 100644\n'
                '--- a/test\n+++ b/test\n@@ -1 +1,3 @@\n test\n+\n+test\n')

        diff_encoding = md5(diff.encode('utf-8')).hexdigest()

        change_api_response = json.dumps(
            {
                'author': 'myname',
                'id': 'bfdde95432b3af879af969bd2377dc3e55ee46e6',
                'date': '2015-02-13 22:34:01 -0700 -0700',
                'message': 'mymessage',
                'parent_id': '304c53c163aedfd0c0e0933776f09c24b87f5944',
                'diff': diff
            }
        )

        def _http_get(self, *args, **kwargs):
            return change_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)

        change = service.get_change(
            repository, 'bfdde95432b3af879af969bd2377dc3e55ee46e6')

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

        self.assertEqual(change.message, 'mymessage')
        self.assertEqual(md5(change.diff.encode('utf-8')).hexdigest(),
                         diff_encoding)
Testing ReviewBoardGateway get_change implementation
dataset/ETHPy150Open reviewboard/reviewboard/reviewboard/hostingsvcs/tests/test_rbgateway.py/ReviewBoardGatewayTests.test_get_change