'Mock a login to GitHub and return the response.
Keyword Arguments:
token_data - OAuth token data, or None for default
profile_data - GitHub profile data, or None for default
email_data - GitHub email data, or None for default
process - \'login\', \'connect\', or \'redirect\''

def github_login(self, token_data=None, profile_data=None, email_data=None, process='login'):

    login_url = reverse('github_login', locale=settings.WIKI_DEFAULT_LANGUAGE)
    callback_url = reverse('github_callback', unprefixed=True)
    self.ensure_github_app()
    login_response = self.client.get(login_url, {'process': process})
    assert (login_response.status_code == 302)
    location = urlparse(login_response['location'])
    query = parse_qs(location.query)
    assert (callback_url in query['redirect_uri'][0])
    state = query['state'][0]
    with requests_mock.Mocker() as mock_requests:
        mock_requests.post(GitHubOAuth2Adapter.access_token_url, json=(token_data or self.github_token_data), headers={'content-type': 'application/json'})
        mock_requests.get(GitHubOAuth2Adapter.profile_url, json=(profile_data or self.github_profile_data))
        if (email_data is None):
            email_data = self.github_email_data
        mock_requests.get(GitHubOAuth2Adapter.emails_url, json=email_data)
        data = {'code': 'github_code', 'state': state}
        response = self.client.get(callback_url, data, follow=True)
    return response
